Added a method to get the number of failed content lookups

This commit is contained in:
Joshua Kissoon 2014-05-12 23:46:02 +05:30
parent 42da6df375
commit a25b88a9bb
2 changed files with 22 additions and 4 deletions

View File

@ -61,6 +61,11 @@ public interface KadStatistician
*/
public int numContentLookups();
/**
* @return How many content lookups have failed.
*/
public int numFailedContentLookups();
/**
* @return The total time spent on content lookups.
*/

View File

@ -21,7 +21,7 @@ public class Statistician implements KadStatistician
private long bootstrapTime;
/* Content lookup operation timing & route length */
private int numContentLookups;
private int numContentLookups, numFailedContentLookups;
private long totalContentLookupTime;
private long totalRouteLength;
@ -76,9 +76,16 @@ public class Statistician implements KadStatistician
@Override
public void addContentLookup(long time, int routeLength, boolean isSuccessful)
{
this.numContentLookups++;
this.totalContentLookupTime += time;
this.totalRouteLength += routeLength;
if (isSuccessful)
{
this.numContentLookups++;
this.totalContentLookupTime += time;
this.totalRouteLength += routeLength;
}
else
{
this.numFailedContentLookups++;
}
}
@Override
@ -87,6 +94,12 @@ public class Statistician implements KadStatistician
return this.numContentLookups;
}
@Override
public int numFailedContentLookups()
{
return this.numFailedContentLookups;
}
@Override
public long totalContentLookupTime()
{