mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-22 02:02:21 +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
|
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 RESPONSE_TIMEOUT = 1500;
|
||||||
private final static long OPERATION_TIMEOUT = 3000;
|
private final static long OPERATION_TIMEOUT = 3000;
|
||||||
private final static int CONCURRENCY = 10;
|
private final static int CONCURRENCY = 10;
|
||||||
|
@ -179,6 +179,7 @@ class StoredContentManager
|
|||||||
public synchronized String toString()
|
public synchronized String toString()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder("Stored Content: \n");
|
StringBuilder sb = new StringBuilder("Stored Content: \n");
|
||||||
|
int count = 0;
|
||||||
for (List<StorageEntryMetadata> es : this.entries.values())
|
for (List<StorageEntryMetadata> es : this.entries.values())
|
||||||
{
|
{
|
||||||
if (entries.size() < 1)
|
if (entries.size() < 1)
|
||||||
@ -188,6 +189,8 @@ class StoredContentManager
|
|||||||
|
|
||||||
for (StorageEntryMetadata e : es)
|
for (StorageEntryMetadata e : es)
|
||||||
{
|
{
|
||||||
|
sb.append(++count);
|
||||||
|
sb.append(". ");
|
||||||
sb.append(e);
|
sb.append(e);
|
||||||
sb.append("\n");
|
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 */
|
/* If we haven't finished as yet, wait for a maximum of config.operationTimeout() time */
|
||||||
int totalTimeWaited = 0;
|
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())
|
while (totalTimeWaited < this.config.operationTimeout())
|
||||||
{
|
{
|
||||||
if (!this.askNodesorFinish())
|
if (!this.askNodesorFinish())
|
||||||
@ -273,6 +273,11 @@ public class NodeLookupOperation implements Operation, Receiver
|
|||||||
@Override
|
@Override
|
||||||
public synchronized void receive(Message incoming, int comm) throws IOException
|
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 */
|
/* We receive a NodeReplyMessage with a set of nodes, read this message */
|
||||||
NodeReplyMessage msg = (NodeReplyMessage) incoming;
|
NodeReplyMessage msg = (NodeReplyMessage) incoming;
|
||||||
|
|
||||||
|
@ -248,6 +248,9 @@ public class KadBucketImpl implements KadBucket
|
|||||||
{
|
{
|
||||||
sb.append("Node: ");
|
sb.append("Node: ");
|
||||||
sb.append(n.getNode().getNodeId().toString());
|
sb.append(n.getNode().getNodeId().toString());
|
||||||
|
sb.append(" (stale: ");
|
||||||
|
sb.append(n.staleCount());
|
||||||
|
sb.append(")");
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user