Stop shutting down the server when we catch an exception

Catch a content not found exception in ContentLookupReceiver
This commit is contained in:
Joshua Kissoon 2014-05-08 18:41:07 +05:30
parent 72048ad8a1
commit 98fc727cbe
3 changed files with 13 additions and 8 deletions

View File

@ -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;

View File

@ -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());
}
}

View File

@ -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;
@ -35,16 +36,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()))
{
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
{
/**