-
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/find successor #33
base: project1-master
Are you sure you want to change the base?
Conversation
…nto project1-master
…nto project1-master
…nto project1-master
…nto project1-master
RespondTo string `json:"respond_to"` | ||
Data Data `json:"data"` | ||
Do string `json:"do"` | ||
SponsoringNode string `json:"sponsoring-node"` |
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 sponsor node id should be int64
okay I have changed message_defs and put all id's as int64 |
Mode string `json:"mode"` | ||
RespondTo string `json:"respond-to"` | ||
Data Data `json:"data"` | ||
TargetID string `json:"target-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 target id is also int64
PROJ1/findSuccessor/findSuccessor.go
Outdated
) | ||
|
||
//FindSuccessor ... This function is used to find successor of node with ID targetID | ||
func FindSuccessor(sponsoringNode *nodeDefs.Node, targetID int64, totalNodes int) (successor *nodeDefs.Node) { |
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 was thinking that you shouldnt need to know the total nodes...but again id double check the paper
PROJ1/findSuccessor/findSuccessor.go
Outdated
|
||
func findClosestPrecedingNode(sponsoringNode *nodeDefs.Node, targetID int64, totalNodes int) (precedingNode *nodeDefs.Node) { | ||
|
||
for i := int(math.Log2(float64(totalNodes))); i >= 0; i-- { |
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.
Why are you taking the log? The finger table entries are in increments of i + 2^i from what i have read. Double check with the chord paper
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'm taking that log just to know what is the size of fingerTable.
So if totalNumberofNodes is 16: Log2 = 4 (Size of fingerTable) I need this to iterate over finger Table
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.
Ohh now that I see it. It should start from int(math.Log2(float64(totalNodes))) - 1
) | ||
|
||
//FindSuccessor ... This function is used to find successor of node with ID targetID | ||
func FindSuccessor(sponsoringNode *nodeDefs.Node, targetID int64) (successor *nodeDefs.Node) { |
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 sponsoring node is represented as an int64 (if you look at the join ring function in the code, the *node object is the node that needs a successor...that way you wont have to return a successor object. You will already have the node object that needs a successor, and can assign the correct successor to that node object directly)
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.
Yeah I thought passing Node instead of only its ID would be nice because FindSucc needs access to successor of sponsoring node which will be available in its node structure.
If we pass only ID then we will need the information of nodes_in_ring so that we can link that ID with its node and then find the 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.
Oh ok. I think then that passing the sponsoring node as a node object is fine then here. Do you think though that the node that needs the successor should also be an argument so that you can update its successor once you find it?
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 by the notes in the HW it says it's only responding to a node ID.. which is then used to lookup the specific node in ring_nodes which can also be used to look up the node's successor/predecessor..etc
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.
Oh ok. I think that is fine then. respond-to is the node that needs a successor right? The function would just need to be in the main file so that you can use the respond-to id to lookup the node respond-to object to update its successor.
|
||
func findClosestPrecedingNode(sponsoringNode *nodeDefs.Node, targetID int64) (precedingNode *nodeDefs.Node) { | ||
|
||
for i := range sponsoringNode.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 based on the pseudocode in the paper, you should find the closest preceding node by starting from the end of the fingertable
No description provided.