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

Setting a Node involves NodeManager and NodeGraph, where NodeManager handles bucket overflow policy #359

Closed
10 tasks done
tegefaulkes opened this issue Mar 17, 2022 · 5 comments · Fixed by #378
Closed
10 tasks done
Assignees
Labels
development Standard development r&d:polykey:core activity 4 End to End Networking behind Consumer NAT Devices

Comments

@tegefaulkes
Copy link
Contributor

tegefaulkes commented Mar 17, 2022

Specification

Adding a node to a NodeGraph's bucket needs to be updated. There are 3 cases when adding a node that need to be handled

  1. If the node already exists in the bucket the last updated need to be updated.
  2. If the node is not already in the bucket AND the bucket has room. The node is added into the bucket.
  3. If the node is not in the bucket AND the bucket is full. We need to ping the oldest node in the bucket, if the old node does not respond we drop it for the new node, otherwise we drop the new node and update the last updated for the old node.

We need to add a force flag for always add the new node for manually adding nodes.

The core of the functionality needs to be moved into the NodeManager. since the NodeGraph is purely data structure the checking of the nodes before adding them should be handled inside the NodeManager.

As implemented, the NodeGraph just stores the nodes within buckets and tracks the number of nodes in the bucket. The more complex logic is handled by the NodeManager now.

Additional context

Tasks

  • 1. Remove bucket limit checking and core adding logic from NodeGraph to NodeManager.addNode method. NodeGraph is purely data-structure anything that requires complex checking or networking needs to be outside it.
  • 2. Handle cases when adding a node.
    1. Node already exists.
    2. Node exists, bucket has room.
    3. Node exist, bucket is full.
  • 3. Add force parameter to force adding a node if bucket is full.
  • Update testing.
    • fix any tests broken by logic moving to NodeManager
    • add test for the 3 cases when adding nodes.
    • add test for force parameter
@tegefaulkes tegefaulkes added the development Standard development label Mar 17, 2022
@tegefaulkes tegefaulkes self-assigned this Mar 17, 2022
@tegefaulkes tegefaulkes mentioned this issue Mar 17, 2022
29 tasks
@tegefaulkes
Copy link
Contributor Author

I'm refactoring the NodeGraph.setNode to just add a node to the bucket and increment the counter without checking. It also updates the node's lastUpdated and information without incrementing the counter if the node already exists.

However I can see an argument for having separate methods for adding and updating the node. What do you think @CMCDragonkai ?

tegefaulkes added a commit that referenced this issue Mar 17, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
tegefaulkes added a commit that referenced this issue Mar 17, 2022
Testing covers adding nodes, updating nodes, handling full buckets and force adding a node.

Relates #359
@CMCDragonkai
Copy link
Member

@tegefaulkes if this is a development issue, the tasks should be part of the PR that you're working on.

If it's a procedure, then the tasks are part of the issue.

tegefaulkes added a commit that referenced this issue Mar 23, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
tegefaulkes added a commit that referenced this issue Mar 23, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
@tegefaulkes
Copy link
Contributor Author

I just noticed that the NodeGraph.setNode uses getUnixtime which seems to be to the second resolution. It just messd with the test but isn't a problem in general. Why don't we just use the date.getTime and use millisecond resolution?

tegefaulkes added a commit that referenced this issue Mar 25, 2022
CMCDragonkai pushed a commit that referenced this issue Mar 26, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
CMCDragonkai pushed a commit that referenced this issue Mar 26, 2022
CMCDragonkai pushed a commit that referenced this issue Mar 26, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
CMCDragonkai pushed a commit that referenced this issue Mar 26, 2022
tegefaulkes added a commit that referenced this issue Mar 28, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
tegefaulkes added a commit that referenced this issue Mar 28, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
CMCDragonkai pushed a commit that referenced this issue Mar 29, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
tegefaulkes added a commit that referenced this issue Mar 29, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
tegefaulkes added a commit that referenced this issue Mar 30, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
@CMCDragonkai CMCDragonkai changed the title Refactoring setNode implementation Setting a Node involves NodeManager and NodeGraph, where NodeManager handles bucket overflow policy Mar 30, 2022
@CMCDragonkai
Copy link
Member

This functionality has to take into account the design "authenticating" nodes here: #322 (comment)

tegefaulkes added a commit that referenced this issue Apr 8, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
tegefaulkes added a commit that referenced this issue Jun 1, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
tegefaulkes added a commit that referenced this issue Jun 1, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
tegefaulkes added a commit that referenced this issue Jun 2, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
tegefaulkes added a commit that referenced this issue Jun 6, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
tegefaulkes added a commit that referenced this issue Jun 7, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
@tegefaulkes
Copy link
Contributor Author

I'm considering this one done.

tegefaulkes added a commit that referenced this issue Jun 10, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
emmacasolin pushed a commit that referenced this issue Jun 14, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
emmacasolin pushed a commit that referenced this issue Jun 14, 2022
…et is full

Logic of adding nodes has been split between `NodeManager` and `NodeGraph`. The `NodeGraph.setNode` just handles adding a node to the bucket where the `NodeManager.setNode` contains the logic of when to add the node

Relates #359
@teebirdy teebirdy added the r&d:polykey:core activity 3 Peer to Peer Federated Hierarchy label Jul 24, 2022
@CMCDragonkai CMCDragonkai added r&d:polykey:core activity 4 End to End Networking behind Consumer NAT Devices and removed r&d:polykey:core activity 3 Peer to Peer Federated Hierarchy labels Jul 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Standard development r&d:polykey:core activity 4 End to End Networking behind Consumer NAT Devices
Development

Successfully merging a pull request may close this issue.

3 participants