Added toString to statistician

This commit is contained in:
Joshua Kissoon 2014-05-07 21:23:04 +05:30
parent 718fa78b9d
commit 70bf6044b3
2 changed files with 35 additions and 2 deletions

View File

@ -126,4 +126,37 @@ public class Statistician
DecimalFormat df = new DecimalFormat("#.00");
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();
}
}

View File

@ -161,7 +161,7 @@ public class KadServer
/**
* 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 */
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
*/
private synchronized void listen()
private void listen()
{
try
{