[go: nahoru, domu]

Skip to content

Commit

Permalink
cleaned up some of the code and moved the README
Browse files Browse the repository at this point in the history
  • Loading branch information
myou11 committed Feb 26, 2018
1 parent 10ce1ba commit 81325fb
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 61 deletions.
File renamed without changes.
57 changes: 0 additions & 57 deletions src/cs455/overlay/node/MessagingNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,59 +229,6 @@ private int selectRandomDstID() {
ID that is less than the destination ID, and that is the closest node.
Special case for when no IDs less than destination ID are found. See comments below. */
private TCPConnection findClosestNode(int dstID, Event event) {
/*String closestIPportNumStr;
if (routingTable.contains(dstID)) {
closestIPportNumStr = routingTable.getEntry(dstID);
return connectionsCache.getConnection(closestIPportNumStr);
}
int currNodeID = this.ID;
int currRoutingID;
int closestID = -1;
for (Map.Entry<Integer, String> entry : routingTable.getEntrySet()) {
currRoutingID = entry.getKey();
// Overshot and wrapped around the ID space
/* This means this entry can't be a possible relay since
the closestID must be between the currNodeID and
dstID. Therefore, currRoutingID cannot be < currNodeID *
if (currNodeID < dstID && currRoutingID < currNodeID)
break;
// currID < dst ID && this condition
// on the right path to finding the closest node,
// will get the largest ID less than the dst ID
if (currRoutingID < dstID)
closestID = currRoutingID;
/* Case when the currNodeID is already greater than the sink
As long as the currRoutingID is also greater than the currNodeID,
then it is a valid ID between the currNodeID and dstID.
Basically finds the largest routingID to send packet to
*
else if (currNodeID > dstID && currRoutingID > currNodeID)
closestID = currRoutingID;
}
// If closest ID is not assigned after loop, then routing algorithm is wrong
if (closestID == -1) {
System.out.println("Something went wrong with the routing algorithm...");
System.exit(1);
}
if (DEBUG) {
if (event instanceof OverlayNodeSendsData) {
OverlayNodeSendsData sendsData = (OverlayNodeSendsData)event;
System.out.printf("My ID: %d\nList of all nodes: %s\nSrc: %d\nDst: %d\nRouting to: %d\nRouting Trace: %s\n\n",
this.ID, registeredNodeIDs.toString(), sendsData.getSrcID(), sendsData.getDstID(), closestID, sendsData.getRoutingTrace().toString());
} else {
System.out.printf("My ID: %d\nList of all nodes: %s\nSrc: %d\nDst: %d\nRouting to: %d\nRouting Trace: %s\n\n",
this.ID, registeredNodeIDs.toString(), this.ID, dstID, closestID, (new ArrayList<Integer>()).toString());
}
}
closestIPportNumStr = routingTable.getEntry(closestID);
return connectionsCache.getConnection(closestIPportNumStr); */

// Get the IDs in the routing table and sort them
ArrayList<Integer> sortedIDs = routingTable.getKeys();
Collections.sort(sortedIDs);
Expand Down Expand Up @@ -411,10 +358,6 @@ private void processNodeSendsData(OverlayNodeSendsData event) throws IOException
// also update the relayTracker
routingTrace.add(this.ID);

/*if (DEBUG) {
System.out.printf("My ID: %d\nList of all nodes: %s\nSrc: %d\nDst: %d\nRouting Trace: %s\n\n",
this.ID, registeredNodeIDs.toString(), event.getSrcID(), event.getDstID(), event.getRoutingTrace().toString());
}*/
synchronized (trackersLock) {
++this.relayTracker;
}
Expand Down
4 changes: 0 additions & 4 deletions src/cs455/overlay/node/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,6 @@ private synchronized void deregisterNode(OverlayNodeSendsDeregistration event, T
String IPportNumStr = connectionSocket.getInetAddress().getHostAddress() + ':' + connectionSocket.getPort();
connectionsCache.removeConnection(IPportNumStr);

// Keep track of the number of nodes registered for the routing packet runs
// Useful for commands to know how many nodes are registered at time of overlay setup
--this.numNodesRegistered;

System.out.printf("Removed node with ID [%d] and IP:port [%s] from registeredNodes\n" +
"Removed its entry in the routing table list as well:\n%s", idToRemove, removedIPportNumStr, removedTable);

Expand Down

0 comments on commit 81325fb

Please sign in to comment.