mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-22 02:02:21 +00:00
Stop shutting down the server when we catch an exception
Catch a content not found exception in ContentLookupReceiver
This commit is contained in:
parent
72048ad8a1
commit
98fc727cbe
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user