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;
@ -76,9 +76,16 @@ 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)
{ {
this.numContentLookups++; if (isSuccessful)
this.totalContentLookupTime += time; {
this.totalRouteLength += routeLength; this.numContentLookups++;
this.totalContentLookupTime += time;
this.totalRouteLength += routeLength;
}
else
{
this.numFailedContentLookups++;
}
} }
@Override @Override
@ -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()
{ {