From 210e3842cab43567fdde092eea23c7d5ed464e31 Mon Sep 17 00:00:00 2001 From: Joshua Kissoon Date: Sat, 10 May 2014 23:34:17 +0530 Subject: [PATCH] ContentLookupOperation - Forgot to initialize the route length checker DHT - Setup the subfolder for content to be 2 digits in length instead of 10 -- With 10, we only have 1 content in a folder, 2 will be better since > 1 content will be in a folder -- Content with similar key tend to be in the same user, so they'll be alot in the same folder --- src/kademlia/core/DefaultConfiguration.java | 2 +- src/kademlia/dht/DHT.java | 4 ++-- src/kademlia/operation/ContentLookupOperation.java | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/kademlia/core/DefaultConfiguration.java b/src/kademlia/core/DefaultConfiguration.java index cb2e1b3..8782d59 100644 --- a/src/kademlia/core/DefaultConfiguration.java +++ b/src/kademlia/core/DefaultConfiguration.java @@ -10,7 +10,7 @@ import java.io.File; public class DefaultConfiguration implements KadConfiguration { - private final static long RESTORE_INTERVAL = 20 * 1000; // in milliseconds + private final static long RESTORE_INTERVAL = 60 * 1000; // in milliseconds private final static long RESPONSE_TIMEOUT = 1500; private final static long OPERATION_TIMEOUT = 3000; private final static int CONCURRENCY = 10; diff --git a/src/kademlia/dht/DHT.java b/src/kademlia/dht/DHT.java index d2f87ea..051387d 100644 --- a/src/kademlia/dht/DHT.java +++ b/src/kademlia/dht/DHT.java @@ -272,11 +272,11 @@ public class DHT private String getContentStorageFolderName(KademliaId key) { /** - * Each content is stored in a folder named after the first 10 characters of the NodeId + * Each content is stored in a folder named after the first 2 characters of the NodeId * * The name of the file containing the content is the hash of this content */ - String folderName = key.hexRepresentation().substring(0, 10); + String folderName = key.hexRepresentation().substring(0, 2); File contentStorageFolder = new File(this.config.getNodeDataFolder(ownerId) + File.separator + folderName); /* Create the content folder if it doesn't exist */ diff --git a/src/kademlia/operation/ContentLookupOperation.java b/src/kademlia/operation/ContentLookupOperation.java index 2bf14f5..a9189be 100644 --- a/src/kademlia/operation/ContentLookupOperation.java +++ b/src/kademlia/operation/ContentLookupOperation.java @@ -58,12 +58,13 @@ public class ContentLookupOperation implements Operation, Receiver private final Comparator comparator; /* Statistical information */ - private RouteLengthChecker routeLengthChecker; + private final RouteLengthChecker routeLengthChecker; { messagesTransiting = new HashMap<>(); isContentFound = false; + routeLengthChecker = new RouteLengthChecker(); } /** @@ -116,7 +117,7 @@ public class ContentLookupOperation implements Operation, Receiver * keey trying until config.operationTimeout() time has expired */ int totalTimeWaited = 0; - int timeInterval = 10; // We re-check every 10 milliseconds + int timeInterval = 10; // We re-check every n milliseconds while (totalTimeWaited < this.config.operationTimeout()) { if (!this.askNodesorFinish() && !isContentFound)