-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: project1-master
Are you sure you want to change the base?
Feature/put #36
Conversation
PROJ1/put/put.go
Outdated
func Put(data *msg.Data, respond_to int64) { | ||
|
||
// Node gets data | ||
ring_nodes[respond_to].Data = data |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
…nto project1-master
…nto project1-master
…nto project1-master
…nto project1-master
…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
Need to fix some things based on conversations:
|
No description provided.