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
This commit is contained in:
Joshua Kissoon 2014-05-10 23:34:17 +05:30
parent d242e0a13a
commit 210e3842ca
3 changed files with 6 additions and 5 deletions

View File

@ -10,7 +10,7 @@ import java.io.File;
public class DefaultConfiguration implements KadConfiguration 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 RESPONSE_TIMEOUT = 1500;
private final static long OPERATION_TIMEOUT = 3000; private final static long OPERATION_TIMEOUT = 3000;
private final static int CONCURRENCY = 10; private final static int CONCURRENCY = 10;

View File

@ -272,11 +272,11 @@ public class DHT
private String getContentStorageFolderName(KademliaId key) 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 * 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); File contentStorageFolder = new File(this.config.getNodeDataFolder(ownerId) + File.separator + folderName);
/* Create the content folder if it doesn't exist */ /* Create the content folder if it doesn't exist */

View File

@ -58,12 +58,13 @@ public class ContentLookupOperation implements Operation, Receiver
private final Comparator comparator; private final Comparator comparator;
/* Statistical information */ /* Statistical information */
private RouteLengthChecker routeLengthChecker; private final RouteLengthChecker routeLengthChecker;
{ {
messagesTransiting = new HashMap<>(); messagesTransiting = new HashMap<>();
isContentFound = false; isContentFound = false;
routeLengthChecker = new RouteLengthChecker();
} }
/** /**
@ -116,7 +117,7 @@ public class ContentLookupOperation implements Operation, Receiver
* keey trying until config.operationTimeout() time has expired * keey trying until config.operationTimeout() time has expired
*/ */
int totalTimeWaited = 0; 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()) while (totalTimeWaited < this.config.operationTimeout())
{ {
if (!this.askNodesorFinish() && !isContentFound) if (!this.askNodesorFinish() && !isContentFound)