KadBucket

- Updated toString to display stale count of a contact

DHT
- Updated toString to print a count of content.
This commit is contained in:
Joshua Kissoon 2014-05-10 19:28:19 +05:30
parent 58696d627a
commit 111cdc9e05
4 changed files with 16 additions and 5 deletions

View File

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

View File

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

View File

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

View File

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