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(); public int numContentLookups();
/**
* @return How many content lookups have failed.
*/
public int numFailedContentLookups();
/** /**
* @return The total time spent on content lookups. * @return The total time spent on content lookups.
*/ */

View File

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