diff --git a/src/kademlia/KadStatistician.java b/src/kademlia/KadStatistician.java index 2f409e1..1a8231d 100644 --- a/src/kademlia/KadStatistician.java +++ b/src/kademlia/KadStatistician.java @@ -50,10 +50,11 @@ public interface KadStatistician /** * Add the timing for a new content lookup operation that took place * - * @param time The time the content lookup took in nanoseconds - * @param routeLength The length of the route it took to get the content + * @param time The time the content lookup took in nanoseconds + * @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. diff --git a/src/kademlia/KademliaNode.java b/src/kademlia/KademliaNode.java index 586e94c..4dfbf89 100644 --- a/src/kademlia/KademliaNode.java +++ b/src/kademlia/KademliaNode.java @@ -347,7 +347,7 @@ public class KademliaNode ContentLookupOperation clo = new ContentLookupOperation(server, this, param, this.config); clo.execute(); long endTime = System.nanoTime(); - this.statistician.addContentLookup(endTime - startTime, clo.routeLength()); + this.statistician.addContentLookup(endTime - startTime, clo.routeLength(), clo.isContentFound()); return clo.getContentFound(); } diff --git a/src/kademlia/Statistician.java b/src/kademlia/Statistician.java index 679dd29..f2c7573 100644 --- a/src/kademlia/Statistician.java +++ b/src/kademlia/Statistician.java @@ -74,7 +74,7 @@ public class Statistician implements KadStatistician } @Override - public void addContentLookup(long time, int routeLength) + public void addContentLookup(long time, int routeLength, boolean isSuccessful) { this.numContentLookups++; this.totalContentLookupTime += time; diff --git a/src/kademlia/operation/ContentLookupOperation.java b/src/kademlia/operation/ContentLookupOperation.java index a9189be..75e689b 100644 --- a/src/kademlia/operation/ContentLookupOperation.java +++ b/src/kademlia/operation/ContentLookupOperation.java @@ -306,6 +306,14 @@ public class ContentLookupOperation implements Operation, Receiver 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