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/find successor #33

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

Conversation

Khatwani13
Copy link
Collaborator

No description provided.

RespondTo string `json:"respond_to"`
Data Data `json:"data"`
Do string `json:"do"`
SponsoringNode string `json:"sponsoring-node"`
Copy link
Owner

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

@Khatwani13
Copy link
Collaborator Author

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"`
Copy link
Owner

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

)

//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) {
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 was thinking that you shouldnt need to know the total nodes...but again id double check the paper


func findClosestPrecedingNode(sponsoringNode *nodeDefs.Node, targetID int64, totalNodes int) (precedingNode *nodeDefs.Node) {

for i := int(math.Log2(float64(totalNodes))); i >= 0; i-- {
Copy link
Owner

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

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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) {
Copy link
Owner

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)

Copy link
Collaborator Author

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

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.

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?

Copy link
Collaborator

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

Copy link
Owner

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 {
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 based on the pseudocode in the paper, you should find the closest preceding node by starting from the end of the fingertable

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.

4 participants