mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-25 03:32:19 +00:00
Added synchronization to prevent concurrency exceptions
This commit is contained in:
parent
0c4a40d9ca
commit
d920f2621e
@ -10,11 +10,11 @@ import java.io.File;
|
||||
public class DefaultConfiguration implements KadConfiguration
|
||||
{
|
||||
|
||||
private final static long RESTORE_INTERVAL = 10 * 1000; // Default at 1 hour
|
||||
private final static long RESTORE_INTERVAL = 5 * 1000; // Default at 1 hour
|
||||
private final static long RESPONSE_TIMEOUT = 1500;
|
||||
private final static long OPERATION_TIMEOUT = 3000;
|
||||
private final static int CONCURRENCY = 10;
|
||||
private final static int K = 10;
|
||||
private final static int K = 4;
|
||||
private final static int RCSIZE = 3;
|
||||
private final static int STALE = 1;
|
||||
private final static String LOCAL_FOLDER = "kademlia";
|
||||
|
@ -100,7 +100,7 @@ public class DHT
|
||||
/* We have this content, but not the latest version, lets delete it so the new version will be added below */
|
||||
try
|
||||
{
|
||||
System.out.println("Removing older content to update it");
|
||||
//System.out.println("Removing older content to update it");
|
||||
this.remove(content.getContentMetadata());
|
||||
}
|
||||
catch (ContentNotFoundException ex)
|
||||
@ -116,7 +116,7 @@ public class DHT
|
||||
*/
|
||||
try
|
||||
{
|
||||
System.out.println("Adding new content.");
|
||||
//System.out.println("Adding new content.");
|
||||
/* Keep track of this content in the entries manager */
|
||||
StorageEntryMetadata sEntry = this.entriesManager.put(content.getContentMetadata());
|
||||
|
||||
@ -292,7 +292,7 @@ public class DHT
|
||||
/**
|
||||
* @return A List of all StorageEntries for this node
|
||||
*/
|
||||
public List<StorageEntryMetadata> getStorageEntries()
|
||||
public synchronized List<StorageEntryMetadata> getStorageEntries()
|
||||
{
|
||||
return entriesManager.getAllEntries();
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ class StoredContentManager
|
||||
/**
|
||||
* @return A list of all storage entries
|
||||
*/
|
||||
public List<StorageEntryMetadata> getAllEntries()
|
||||
public synchronized List<StorageEntryMetadata> getAllEntries()
|
||||
{
|
||||
List<StorageEntryMetadata> entriesRet = new ArrayList<>();
|
||||
|
||||
|
@ -35,8 +35,8 @@ public class ContentLookupReceiver implements Receiver
|
||||
ContentLookupMessage msg = (ContentLookupMessage) incoming;
|
||||
this.localNode.getRoutingTable().insert(msg.getOrigin());
|
||||
|
||||
System.out.println("Received request for content with GetParameter" + msg.getParameters());
|
||||
System.out.println("Have Content? " + this.dht.contains(msg.getParameters()));
|
||||
//System.out.println("Received request for content with GetParameter" + msg.getParameters());
|
||||
//System.out.println("Have Content? " + this.dht.contains(msg.getParameters()));
|
||||
|
||||
/* Check if we can have this data */
|
||||
if (this.dht.contains(msg.getParameters()))
|
||||
|
@ -57,7 +57,7 @@ public class BucketRefreshOperation implements Operation
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
System.err.println("Bucket Refresh Operation Failed. Msg: " + e.getMessage());
|
||||
//System.err.println("Bucket Refresh Operation Failed. Msg: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
|
Loading…
Reference in New Issue
Block a user