In the content lookup statistics - added a value "isContentFound" to be passed

This commit is contained in:
Joshua Kissoon 2014-05-12 23:41:45 +05:30
parent fca4a5fde5
commit 42da6df375
4 changed files with 14 additions and 5 deletions

View File

@ -52,8 +52,9 @@ public interface KadStatistician
* *
* @param time The time the content lookup took in nanoseconds * @param time The time the content lookup took in nanoseconds
* @param routeLength The length of the route it took to get the content * @param routeLength The length of the route it took to get the content
* @param isSuccessful Whether the content lookup was successful or not
*/ */
public void addContentLookup(long time, int routeLength); public void addContentLookup(long time, int routeLength, boolean isSuccessful);
/** /**
* @return The total number of content lookups performed. * @return The total number of content lookups performed.

View File

@ -347,7 +347,7 @@ public class KademliaNode
ContentLookupOperation clo = new ContentLookupOperation(server, this, param, this.config); ContentLookupOperation clo = new ContentLookupOperation(server, this, param, this.config);
clo.execute(); clo.execute();
long endTime = System.nanoTime(); long endTime = System.nanoTime();
this.statistician.addContentLookup(endTime - startTime, clo.routeLength()); this.statistician.addContentLookup(endTime - startTime, clo.routeLength(), clo.isContentFound());
return clo.getContentFound(); return clo.getContentFound();
} }

View File

@ -74,7 +74,7 @@ public class Statistician implements KadStatistician
} }
@Override @Override
public void addContentLookup(long time, int routeLength) public void addContentLookup(long time, int routeLength, boolean isSuccessful)
{ {
this.numContentLookups++; this.numContentLookups++;
this.totalContentLookupTime += time; this.totalContentLookupTime += time;

View File

@ -307,6 +307,14 @@ public class ContentLookupOperation implements Operation, Receiver
this.askNodesorFinish(); this.askNodesorFinish();
} }
/**
* @return Whether the content was found or not.
*/
public boolean isContentFound()
{
return this.isContentFound;
}
/** /**
* @return The list of all content found during the lookup operation * @return The list of all content found during the lookup operation
* *