diff --git a/src/kademlia/core/DefaultConfiguration.java b/src/kademlia/core/DefaultConfiguration.java index eba0cdb..cf97bfc 100644 --- a/src/kademlia/core/DefaultConfiguration.java +++ b/src/kademlia/core/DefaultConfiguration.java @@ -10,7 +10,7 @@ import java.io.File; public class DefaultConfiguration implements KadConfiguration { - private final static long RESTORE_INTERVAL = 60 * 1000; // Default at 1 hour + private final static long RESTORE_INTERVAL = 30 * 1000; // in milliseconds private final static long RESPONSE_TIMEOUT = 1500; private final static long OPERATION_TIMEOUT = 3000; private final static int CONCURRENCY = 10; diff --git a/src/kademlia/core/KadServer.java b/src/kademlia/core/KadServer.java index 0e82a18..fe1a846 100644 --- a/src/kademlia/core/KadServer.java +++ b/src/kademlia/core/KadServer.java @@ -267,7 +267,7 @@ public class KadServer } catch (IOException e) { - this.isRunning = false; + //this.isRunning = false; System.err.println("Server ran into a problem in listener method. Message: " + e.getMessage()); } } diff --git a/src/kademlia/message/ContentLookupReceiver.java b/src/kademlia/message/ContentLookupReceiver.java index f0212d3..26aedf9 100644 --- a/src/kademlia/message/ContentLookupReceiver.java +++ b/src/kademlia/message/ContentLookupReceiver.java @@ -1,6 +1,7 @@ package kademlia.message; import java.io.IOException; +import java.util.NoSuchElementException; import kademlia.KademliaNode; import kademlia.core.KadConfiguration; import kademlia.core.KadServer; @@ -34,16 +35,20 @@ public class ContentLookupReceiver implements Receiver { ContentLookupMessage msg = (ContentLookupMessage) incoming; this.localNode.getRoutingTable().insert(msg.getOrigin()); - - //System.out.println("Received request for content with GetParameter" + msg.getParameters()); - //System.out.println("Have Content? " + this.dht.contains(msg.getParameters())); /* Check if we can have this data */ if (this.dht.contains(msg.getParameters())) { - /* Return a ContentMessage with the required data */ - ContentMessage cMsg = new ContentMessage(localNode.getNode(), this.dht.get(msg.getParameters())); - server.reply(msg.getOrigin(), cMsg, comm); + try + { + /* Return a ContentMessage with the required data */ + ContentMessage cMsg = new ContentMessage(localNode.getNode(), this.dht.get(msg.getParameters())); + server.reply(msg.getOrigin(), cMsg, comm); + } + catch (NoSuchElementException ex) + { + /* @todo Not sure why this exception is thrown here, checkup the system when tests are writtem*/ + } } else {