mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-12-22 15:51:46 +00:00
KadBucket
- Updated toString to display stale count of a contact DHT - Updated toString to print a count of content.
This commit is contained in:
parent
58696d627a
commit
111cdc9e05
@ -10,7 +10,7 @@ import java.io.File;
|
||||
public class DefaultConfiguration implements KadConfiguration
|
||||
{
|
||||
|
||||
private final static long RESTORE_INTERVAL = 60 * 1000; // in milliseconds
|
||||
private final static long RESTORE_INTERVAL = 20 * 1000; // in milliseconds
|
||||
private final static long RESPONSE_TIMEOUT = 1500;
|
||||
private final static long OPERATION_TIMEOUT = 3000;
|
||||
private final static int CONCURRENCY = 10;
|
||||
|
@ -179,6 +179,7 @@ class StoredContentManager
|
||||
public synchronized String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder("Stored Content: \n");
|
||||
int count = 0;
|
||||
for (List<StorageEntryMetadata> es : this.entries.values())
|
||||
{
|
||||
if (entries.size() < 1)
|
||||
@ -188,6 +189,8 @@ class StoredContentManager
|
||||
|
||||
for (StorageEntryMetadata e : es)
|
||||
{
|
||||
sb.append(++count);
|
||||
sb.append(". ");
|
||||
sb.append(e);
|
||||
sb.append("\n");
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class NodeLookupOperation implements Operation, Receiver
|
||||
|
||||
/* If we haven't finished as yet, wait for a maximum of config.operationTimeout() time */
|
||||
int totalTimeWaited = 0;
|
||||
int timeInterval = 10; // We re-check every 300 milliseconds
|
||||
int timeInterval = 10; // We re-check every n milliseconds
|
||||
while (totalTimeWaited < this.config.operationTimeout())
|
||||
{
|
||||
if (!this.askNodesorFinish())
|
||||
@ -113,10 +113,10 @@ public class NodeLookupOperation implements Operation, Receiver
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* There is no need to throw an exception here!
|
||||
* If the operation times out means we didn't get replies from all nodes,
|
||||
* There is no need to throw an exception here!
|
||||
* If the operation times out means we didn't get replies from all nodes,
|
||||
* so lets just simply return the K-Closest nodes we knoe
|
||||
*/
|
||||
// if (error)
|
||||
@ -273,6 +273,11 @@ public class NodeLookupOperation implements Operation, Receiver
|
||||
@Override
|
||||
public synchronized void receive(Message incoming, int comm) throws IOException
|
||||
{
|
||||
if (!(incoming instanceof NodeReplyMessage))
|
||||
{
|
||||
/* Not sure why we get a message of a different type here... @todo Figure it out. */
|
||||
return;
|
||||
}
|
||||
/* We receive a NodeReplyMessage with a set of nodes, read this message */
|
||||
NodeReplyMessage msg = (NodeReplyMessage) incoming;
|
||||
|
||||
|
@ -248,6 +248,9 @@ public class KadBucketImpl implements KadBucket
|
||||
{
|
||||
sb.append("Node: ");
|
||||
sb.append(n.getNode().getNodeId().toString());
|
||||
sb.append(" (stale: ");
|
||||
sb.append(n.staleCount());
|
||||
sb.append(")");
|
||||
sb.append("\n");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user