mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-22 10:12:19 +00:00
Added toString to statistician
This commit is contained in:
parent
718fa78b9d
commit
70bf6044b3
@ -126,4 +126,37 @@ public class Statistician
|
|||||||
DecimalFormat df = new DecimalFormat("#.00");
|
DecimalFormat df = new DecimalFormat("#.00");
|
||||||
return new Double(df.format(avg));
|
return new Double(df.format(avg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder("Statistician: [");
|
||||||
|
|
||||||
|
sb.append("Bootstrap Time: ");
|
||||||
|
sb.append(this.getBootstrapTime());
|
||||||
|
sb.append("; ");
|
||||||
|
|
||||||
|
sb.append("Data Sent: ");
|
||||||
|
sb.append(this.getTotalDataSent());
|
||||||
|
sb.append("; ");
|
||||||
|
|
||||||
|
sb.append("Data Received: ");
|
||||||
|
sb.append(this.getTotalDataReceived());
|
||||||
|
sb.append("; ");
|
||||||
|
|
||||||
|
sb.append("Num Content Lookups: ");
|
||||||
|
sb.append(this.numContentLookups());
|
||||||
|
sb.append("; ");
|
||||||
|
|
||||||
|
sb.append("Avg Content Lookup Time: ");
|
||||||
|
sb.append(this.averageContentLookupTime());
|
||||||
|
sb.append("; ");
|
||||||
|
|
||||||
|
sb.append("Avg Content Lookup Route Lth: ");
|
||||||
|
sb.append(this.averageContentLookupRouteLength());
|
||||||
|
sb.append("; ");
|
||||||
|
|
||||||
|
sb.append("]");
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ public class KadServer
|
|||||||
/**
|
/**
|
||||||
* Internal sendMessage method called by the public sendMessage method after a communicationId is generated
|
* Internal sendMessage method called by the public sendMessage method after a communicationId is generated
|
||||||
*/
|
*/
|
||||||
private synchronized void sendMessage(Node to, Message msg, int comm) throws IOException
|
private void sendMessage(Node to, Message msg, int comm) throws IOException
|
||||||
{
|
{
|
||||||
/* Use a try-with resource to auto-close streams after usage */
|
/* Use a try-with resource to auto-close streams after usage */
|
||||||
try (ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream dout = new DataOutputStream(bout);)
|
try (ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream dout = new DataOutputStream(bout);)
|
||||||
@ -192,7 +192,7 @@ public class KadServer
|
|||||||
/**
|
/**
|
||||||
* Listen for incoming messages in a separate thread
|
* Listen for incoming messages in a separate thread
|
||||||
*/
|
*/
|
||||||
private synchronized void listen()
|
private void listen()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user