From 67c12438d1f440c5359e5c1f16dc3aab0c5984fb Mon Sep 17 00:00:00 2001 From: Joshua Kissoon Date: Sat, 26 Apr 2014 22:21:51 +0530 Subject: [PATCH] Few minor updates and removal of completed @todos --- src/kademlia/Kademlia.java | 2 - src/kademlia/dht/DHT.java | 8 +- .../message/StoreContentReceiver.java | 5 +- src/kademlia/operation/PingOperation.java | 75 ++++++++++--------- 4 files changed, 49 insertions(+), 41 deletions(-) diff --git a/src/kademlia/Kademlia.java b/src/kademlia/Kademlia.java index 1eac5f2..810878f 100644 --- a/src/kademlia/Kademlia.java +++ b/src/kademlia/Kademlia.java @@ -41,8 +41,6 @@ import kademlia.util.serializer.JsonSerializer; * * @todo When we receive a store message - if we have a newer version of the content, re-send this newer version to that node so as to update their version * @todo Handle IPv6 Addresses - * @todo Handle compressing data - * @todo Implement Kademlia.ping() operation. * */ public class Kademlia diff --git a/src/kademlia/dht/DHT.java b/src/kademlia/dht/DHT.java index 1716217..2ad1c80 100644 --- a/src/kademlia/dht/DHT.java +++ b/src/kademlia/dht/DHT.java @@ -101,7 +101,7 @@ public class DHT } catch (ContentNotFoundException ex) { - /* @todo Log an error here */ + /* This won't ever happen at this point since we only get here if the content is found, lets ignore it */ } } } @@ -128,7 +128,11 @@ public class DHT } catch (ContentExistException e) { - /* @todo Content already exist on the DHT, log an error here */ + /** + * Content already exist on the DHT + * This won't happen because above takes care of removing the content if it's older and needs to be updated, + * or returning if we already have the current content version. + */ return false; } diff --git a/src/kademlia/message/StoreContentReceiver.java b/src/kademlia/message/StoreContentReceiver.java index f161b5b..49facb6 100644 --- a/src/kademlia/message/StoreContentReceiver.java +++ b/src/kademlia/message/StoreContentReceiver.java @@ -49,6 +49,9 @@ public class StoreContentReceiver implements Receiver @Override public void timeout(int comm) { - /* @todo Do something if the request times out */ + /** + * This receiver only handles Receiving content when we've received the message, + * so no timeout will happen with this receiver. + */ } } diff --git a/src/kademlia/operation/PingOperation.java b/src/kademlia/operation/PingOperation.java index ee9e870..6cfe352 100644 --- a/src/kademlia/operation/PingOperation.java +++ b/src/kademlia/operation/PingOperation.java @@ -1,36 +1,39 @@ -///** -// * @author Joshua Kissoon -// * @created 20140218 -// * @desc Implementation of the Kademlia Ping operation -// */ -//package kademlia.operation; -// -//import kademlia.core.KadServer; -//import kademlia.node.Node; -// -//public class PingOperation implements Operation -//{ -// -// private final KadServer server; -// private final Node localNode; -// private final Node toPing; -// -// /** -// * @param server The Kademlia server used to send & receive messages -// * @param local The local node -// * @param toPing The node to send the ping message to -// */ -// public PingOperation(KadServer server, Node local, Node toPing) -// { -// this.server = server; -// this.localNode = local; -// this.toPing = toPing; -// } -// -// @Override -// public Object execute() -// { -// /* @todo Create a pingmessage and send this message to the toPing node, -// then handle the reply from this node using a reciever */ -// } -//} +/** + * Implementation of the Kademlia Ping operation, + * This is on hold at the moment since I'm not sure if we'll use ping given the improvements mentioned in the paper. + * + * @author Joshua Kissoon + * @since 20140218 + */ +package kademlia.operation; + +import java.io.IOException; +import kademlia.core.KadServer; +import kademlia.exceptions.RoutingException; +import kademlia.node.Node; + +public class PingOperation implements Operation +{ + + private final KadServer server; + private final Node localNode; + private final Node toPing; + + /** + * @param server The Kademlia server used to send & receive messages + * @param local The local node + * @param toPing The node to send the ping message to + */ + public PingOperation(KadServer server, Node local, Node toPing) + { + this.server = server; + this.localNode = local; + this.toPing = toPing; + } + + @Override + public void execute() throws IOException, RoutingException + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } +}