Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/put #36

Open
wants to merge 18 commits into
base: project1-master
Choose a base branch
from
Open

Feature/put #36

wants to merge 18 commits into from

Conversation

drnickallgood
Copy link
Collaborator

No description provided.

PROJ1/put/put.go Outdated
func Put(data *msg.Data, respond_to int64) {

// Node gets data
ring_nodes[respond_to].Data = data
Copy link
Owner

@bama4 bama4 Apr 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be the right code if you were already at the node that is supposed to store the data.
The data I believe is supposed to be forwarded through the ring until it reaches the correct node that is supposed to store the data.
With "put" you are supposed to create a function that maps the "key" to a node that is supposed to store that key,value pair. The next step is to find the node that is supposed to store the data...at least thats what I got when I asked the processor

PROJ1/put/put.go Outdated
// Node gets data
ring_nodes[respond_to].Data = data

// network[respond_to] <- "Put"
Copy link
Owner

@bama4 bama4 Apr 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the first part which is the mapping function that maps the string data key to a node id, there are several ways of doing it. Below is just an example of one way of doing it but there could be better ways:
You could just add up all of the ascii values of the data keys' characters and then mod that by the number of nodes that we set in the program
`
num_of_nodes
.
.
data_mapping_function(key):
//get the sum of all of the characters in the key

char_sum = sum_of_all_chars(key)

node_id = char_sum % num_of_nodes

return node_id
`

The second part is finding the node that can store the data by passing it along the ring

PROJ1/put/put.go Outdated
var node_id = map_to_string_id(data.Key, respond_to)

// Node gets data
ring_nodes[node_id].Value = data.Value
Copy link
Owner

@bama4 bama4 Apr 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remember you need to know where in the ring data that maps to node_id should go. This is done through routing NOT through using the ring_nodes map (the node id may not even be existing in the ring)
Also the data is stored in the DataTable entry in the node struct definition if you look in the node_defs package

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DataTable entry is fixed, but I can't seem to really understand the first part of the comment.. i know ring_nodes[node_id] probably isn't sufficient.. right?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ring_nodes[node_id] is a shortcut in my opinion. As i mentioned before, you need to find the correct spot to put the data through routing, not by using ring nodes for this particular instruction. If we could simply store the data using just the ring_nodes map, then that would defeat the purpose of using chord to store data in a distributed way

PROJ1/put/put.go Outdated
func Put(data *msg.Data, respond_to int64) {

// Get the node ID for data string
var node_id = map_to_string_id(data.Key, respond_to)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map_to_string_id function just takes in a string, nothing else

PROJ1/put/put.go Outdated
// map key from data.key to noe ID that is supposed to store
// Find specific node in ring , if doesn't exist, map to successor

// network[respond_to] <- "Put"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like due to the way that we implemented our program, respond-to seems like an extra field so I am still not sure how to incorporate it in

PROJ1/put/put.go Outdated
ring_nodes[node_id].Value = data.Value

// map key from data.key to noe ID that is supposed to store
// Find specific node in ring , if doesn't exist, map to successor
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the node that first received the put message should check to see if the node id is in its routing fingertable table...if it is not in the table, then you should forward the data to the node in the table that is the closest to where the node_id would be.
If the node_id is bigger than the node that recieved the data, then maybe pass the data to the nodes predecessor and have the predecessor look up where to find node id.

PROJ1/put/put.go Outdated

// Get the node ID for data string
var node_id = map_to_string_id(data.Key)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may also want to look at the current node first to see if you are already at the node that should store the data

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

PROJ1/put/put.go Outdated
// Node gets this message
// Use all the nodes fields

func find_biggest_node(finger_table *map[int64]*Node, node_id int64)(biggest int64) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can use the ClosestPrecedingNode function that is already in master that will find the closest node that comes before a given node id

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

PROJ1/put/put.go Outdated
// It's not in our finger table
// Go to the biggest node without overshooting
// ClosestPrecedingNode function in master
var biggest = find_biggest_node(&FingerTable, node_id)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for having both find biggest node and ClosestPRecedingNode?

PROJ1/put/put.go Outdated
var node_id = map_to_string_id(data.Key)

// Check to see if this is the right node to store data
if ChannelId == node_id {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The channel id may not necessarily equal the node id

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was my attempt at looking at the current node to see if it's the correct one or not.. but i guess if i remember right.. the first entry in the node's fingertable is always itself i think?

PROJ1/put/put.go Outdated
DataTable[data.Key] := data.Value
return
} else {
for k, v := range FingerTable {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think youd want either the closest preceeding node or youd want to start from the end of the table and work your way down...remeber, the ith index of node n's table represents where ids = i + 2^i should be routed to.

PROJ1/put/put.go Outdated
DataTable[data.Key] := data.Value
} else {
// FindPReceedingNode
var closest_node = FindClosestPreceedingNode(&node_obj.FingerTable, data.Key)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function sends the closest proceeding node to a bucket..
You meed to do GetDataFromBucket to retrieve the message...and then ExtractIdFromBucketData to get the value there are examples in the main code

nallg00d and others added 18 commits April 16, 2018 23:11
…ctions correctly and getting it, but for whatever reason it still isn't showing up in the logs as being recieved
…nstructions nad utilizing check_error(err). Right now doesn't seem to find the closest node correct
… it doesn't do anything. For some reason even when it works I'm not seeing any of the log messages on the console
… found. Also a check to avoid looping if the current node is it's own successor
@drnickallgood
Copy link
Collaborator Author

Need to fix some things based on conversations:

  1. Modify closet > key_id to use between func
  2. format actual message to send to Successor instead of raw values (use JSON)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants