mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-21 17:52:21 +00:00
From now on we'll name the interfaces properly and name the implementation with a J as prefix since this is the J Kademlia implementation
Renamed the KademliaNode class to JKademliaNode
This commit is contained in:
parent
ce5c49d46d
commit
451cba4be9
@ -40,7 +40,7 @@ import kademlia.util.serializer.JsonSerializer;
|
|||||||
* @todo Handle IPv6 Addresses
|
* @todo Handle IPv6 Addresses
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class KademliaNode
|
public class JKademliaNode
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Kademlia Attributes */
|
/* Kademlia Attributes */
|
||||||
@ -86,7 +86,7 @@ public class KademliaNode
|
|||||||
* from disk <i>or</i> a network error occurred while
|
* from disk <i>or</i> a network error occurred while
|
||||||
* attempting to bootstrap to the network
|
* attempting to bootstrap to the network
|
||||||
* */
|
* */
|
||||||
public KademliaNode(String ownerId, Node localNode, int udpPort, DHT dht, RoutingTable routingTable, KadConfiguration config) throws IOException
|
public JKademliaNode(String ownerId, Node localNode, int udpPort, DHT dht, RoutingTable routingTable, KadConfiguration config) throws IOException
|
||||||
{
|
{
|
||||||
this.ownerId = ownerId;
|
this.ownerId = ownerId;
|
||||||
this.udpPort = udpPort;
|
this.udpPort = udpPort;
|
||||||
@ -113,7 +113,7 @@ public class KademliaNode
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Runs a DHT RefreshOperation */
|
/* Runs a DHT RefreshOperation */
|
||||||
KademliaNode.this.refresh();
|
JKademliaNode.this.refresh();
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@ -132,7 +132,7 @@ public class KademliaNode
|
|||||||
this.refreshOperationTimer.purge();
|
this.refreshOperationTimer.purge();
|
||||||
}
|
}
|
||||||
|
|
||||||
public KademliaNode(String ownerId, Node node, int udpPort, RoutingTable routingTable, KadConfiguration config) throws IOException
|
public JKademliaNode(String ownerId, Node node, int udpPort, RoutingTable routingTable, KadConfiguration config) throws IOException
|
||||||
{
|
{
|
||||||
this(
|
this(
|
||||||
ownerId,
|
ownerId,
|
||||||
@ -144,7 +144,7 @@ public class KademliaNode
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KademliaNode(String ownerId, Node node, int udpPort, KadConfiguration config) throws IOException
|
public JKademliaNode(String ownerId, Node node, int udpPort, KadConfiguration config) throws IOException
|
||||||
{
|
{
|
||||||
this(
|
this(
|
||||||
ownerId,
|
ownerId,
|
||||||
@ -155,7 +155,7 @@ public class KademliaNode
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KademliaNode(String ownerId, KademliaId defaultId, int udpPort) throws IOException
|
public JKademliaNode(String ownerId, KademliaId defaultId, int udpPort) throws IOException
|
||||||
{
|
{
|
||||||
this(
|
this(
|
||||||
ownerId,
|
ownerId,
|
||||||
@ -175,9 +175,9 @@ public class KademliaNode
|
|||||||
* @throws java.io.FileNotFoundException
|
* @throws java.io.FileNotFoundException
|
||||||
* @throws java.lang.ClassNotFoundException
|
* @throws java.lang.ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
public static KademliaNode loadFromFile(String ownerId) throws FileNotFoundException, IOException, ClassNotFoundException
|
public static JKademliaNode loadFromFile(String ownerId) throws FileNotFoundException, IOException, ClassNotFoundException
|
||||||
{
|
{
|
||||||
return KademliaNode.loadFromFile(ownerId, new DefaultConfiguration());
|
return JKademliaNode.loadFromFile(ownerId, new DefaultConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -191,7 +191,7 @@ public class KademliaNode
|
|||||||
* @throws java.io.FileNotFoundException
|
* @throws java.io.FileNotFoundException
|
||||||
* @throws java.lang.ClassNotFoundException
|
* @throws java.lang.ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
public static KademliaNode loadFromFile(String ownerId, KadConfiguration iconfig) throws FileNotFoundException, IOException, ClassNotFoundException
|
public static JKademliaNode loadFromFile(String ownerId, KadConfiguration iconfig) throws FileNotFoundException, IOException, ClassNotFoundException
|
||||||
{
|
{
|
||||||
DataInputStream din;
|
DataInputStream din;
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ public class KademliaNode
|
|||||||
* @section Read Basic Kad data
|
* @section Read Basic Kad data
|
||||||
*/
|
*/
|
||||||
din = new DataInputStream(new FileInputStream(getStateStorageFolderName(ownerId, iconfig) + File.separator + "kad.kns"));
|
din = new DataInputStream(new FileInputStream(getStateStorageFolderName(ownerId, iconfig) + File.separator + "kad.kns"));
|
||||||
KademliaNode ikad = new JsonSerializer<KademliaNode>().read(din);
|
JKademliaNode ikad = new JsonSerializer<JKademliaNode>().read(din);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @section Read the routing table
|
* @section Read the routing table
|
||||||
@ -220,7 +220,7 @@ public class KademliaNode
|
|||||||
DHT idht = new JsonDHTSerializer().read(din);
|
DHT idht = new JsonDHTSerializer().read(din);
|
||||||
idht.setConfiguration(iconfig);
|
idht.setConfiguration(iconfig);
|
||||||
|
|
||||||
return new KademliaNode(ownerId, inode, ikad.getPort(), idht, irtbl, iconfig);
|
return new JKademliaNode(ownerId, inode, ikad.getPort(), idht, irtbl, iconfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -409,7 +409,7 @@ public class KademliaNode
|
|||||||
* @section Store Basic Kad data
|
* @section Store Basic Kad data
|
||||||
*/
|
*/
|
||||||
dout = new DataOutputStream(new FileOutputStream(getStateStorageFolderName(this.ownerId, this.config) + File.separator + "kad.kns"));
|
dout = new DataOutputStream(new FileOutputStream(getStateStorageFolderName(this.ownerId, this.config) + File.separator + "kad.kns"));
|
||||||
new JsonSerializer<KademliaNode>().write(this, dout);
|
new JsonSerializer<JKademliaNode>().write(this, dout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @section Save the node state
|
* @section Save the node state
|
@ -68,7 +68,7 @@ public class KadServer
|
|||||||
*
|
*
|
||||||
* @throws java.net.SocketException
|
* @throws java.net.SocketException
|
||||||
*/
|
*/
|
||||||
public KadServer(int udpPort, MessageFactory mFactory, Node localNode, KadConfiguration config, KadStatistician statistician) throws SocketException
|
public KadServer(int udpPort, KademliaMessageFactory mFactory, Node localNode, KadConfiguration config, KadStatistician statistician) throws SocketException
|
||||||
{
|
{
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.socket = new DatagramSocket(udpPort);
|
this.socket = new DatagramSocket(udpPort);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package kademlia.message;
|
package kademlia.message;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadServer;
|
import kademlia.KadServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,9 +14,9 @@ public class ConnectReceiver implements Receiver
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final KadServer server;
|
private final KadServer server;
|
||||||
private final KademliaNode localNode;
|
private final JKademliaNode localNode;
|
||||||
|
|
||||||
public ConnectReceiver(KadServer server, KademliaNode local)
|
public ConnectReceiver(KadServer server, JKademliaNode local)
|
||||||
{
|
{
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.localNode = local;
|
this.localNode = local;
|
||||||
|
@ -2,7 +2,7 @@ package kademlia.message;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadConfiguration;
|
import kademlia.KadConfiguration;
|
||||||
import kademlia.KadServer;
|
import kademlia.KadServer;
|
||||||
import kademlia.dht.DHT;
|
import kademlia.dht.DHT;
|
||||||
@ -18,11 +18,11 @@ public class ContentLookupReceiver implements Receiver
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final KadServer server;
|
private final KadServer server;
|
||||||
private final KademliaNode localNode;
|
private final JKademliaNode localNode;
|
||||||
private final DHT dht;
|
private final DHT dht;
|
||||||
private final KadConfiguration config;
|
private final KadConfiguration config;
|
||||||
|
|
||||||
public ContentLookupReceiver(KadServer server, KademliaNode localNode, DHT dht, KadConfiguration config)
|
public ContentLookupReceiver(KadServer server, JKademliaNode localNode, DHT dht, KadConfiguration config)
|
||||||
{
|
{
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.localNode = localNode;
|
this.localNode = localNode;
|
||||||
|
@ -2,7 +2,7 @@ package kademlia.message;
|
|||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadConfiguration;
|
import kademlia.KadConfiguration;
|
||||||
import kademlia.KadServer;
|
import kademlia.KadServer;
|
||||||
import kademlia.dht.DHT;
|
import kademlia.dht.DHT;
|
||||||
@ -16,11 +16,11 @@ import kademlia.dht.DHT;
|
|||||||
public class MessageFactory implements KademliaMessageFactory
|
public class MessageFactory implements KademliaMessageFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
private final KademliaNode localNode;
|
private final JKademliaNode localNode;
|
||||||
private final DHT dht;
|
private final DHT dht;
|
||||||
private final KadConfiguration config;
|
private final KadConfiguration config;
|
||||||
|
|
||||||
public MessageFactory(KademliaNode local, DHT dht, KadConfiguration config)
|
public MessageFactory(JKademliaNode local, DHT dht, KadConfiguration config)
|
||||||
{
|
{
|
||||||
this.localNode = local;
|
this.localNode = local;
|
||||||
this.dht = dht;
|
this.dht = dht;
|
||||||
|
@ -2,7 +2,7 @@ package kademlia.message;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadConfiguration;
|
import kademlia.KadConfiguration;
|
||||||
import kademlia.KadServer;
|
import kademlia.KadServer;
|
||||||
import kademlia.node.Node;
|
import kademlia.node.Node;
|
||||||
@ -17,10 +17,10 @@ public class NodeLookupReceiver implements Receiver
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final KadServer server;
|
private final KadServer server;
|
||||||
private final KademliaNode localNode;
|
private final JKademliaNode localNode;
|
||||||
private final KadConfiguration config;
|
private final KadConfiguration config;
|
||||||
|
|
||||||
public NodeLookupReceiver(KadServer server, KademliaNode local, KadConfiguration config)
|
public NodeLookupReceiver(KadServer server, JKademliaNode local, KadConfiguration config)
|
||||||
{
|
{
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.localNode = local;
|
this.localNode = local;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package kademlia.message;
|
package kademlia.message;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadServer;
|
import kademlia.KadServer;
|
||||||
import kademlia.dht.DHT;
|
import kademlia.dht.DHT;
|
||||||
|
|
||||||
@ -15,10 +15,10 @@ public class StoreContentReceiver implements Receiver
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final KadServer server;
|
private final KadServer server;
|
||||||
private final KademliaNode localNode;
|
private final JKademliaNode localNode;
|
||||||
private final DHT dht;
|
private final DHT dht;
|
||||||
|
|
||||||
public StoreContentReceiver(KadServer server, KademliaNode localNode, DHT dht)
|
public StoreContentReceiver(KadServer server, JKademliaNode localNode, DHT dht)
|
||||||
{
|
{
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.localNode = localNode;
|
this.localNode = localNode;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package kademlia.operation;
|
package kademlia.operation;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadConfiguration;
|
import kademlia.KadConfiguration;
|
||||||
import kademlia.KadServer;
|
import kademlia.KadServer;
|
||||||
import kademlia.node.KademliaId;
|
import kademlia.node.KademliaId;
|
||||||
@ -17,10 +17,10 @@ public class BucketRefreshOperation implements Operation
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final KadServer server;
|
private final KadServer server;
|
||||||
private final KademliaNode localNode;
|
private final JKademliaNode localNode;
|
||||||
private final KadConfiguration config;
|
private final KadConfiguration config;
|
||||||
|
|
||||||
public BucketRefreshOperation(KadServer server, KademliaNode localNode, KadConfiguration config)
|
public BucketRefreshOperation(KadServer server, JKademliaNode localNode, KadConfiguration config)
|
||||||
{
|
{
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.localNode = localNode;
|
this.localNode = localNode;
|
||||||
|
@ -7,7 +7,7 @@ package kademlia.operation;
|
|||||||
|
|
||||||
import kademlia.message.Receiver;
|
import kademlia.message.Receiver;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadConfiguration;
|
import kademlia.KadConfiguration;
|
||||||
import kademlia.KadServer;
|
import kademlia.KadServer;
|
||||||
import kademlia.exceptions.RoutingException;
|
import kademlia.exceptions.RoutingException;
|
||||||
@ -22,7 +22,7 @@ public class ConnectOperation implements Operation, Receiver
|
|||||||
public static final int MAX_CONNECT_ATTEMPTS = 5; // Try 5 times to connect to a node
|
public static final int MAX_CONNECT_ATTEMPTS = 5; // Try 5 times to connect to a node
|
||||||
|
|
||||||
private final KadServer server;
|
private final KadServer server;
|
||||||
private final KademliaNode localNode;
|
private final JKademliaNode localNode;
|
||||||
private final Node bootstrapNode;
|
private final Node bootstrapNode;
|
||||||
private final KadConfiguration config;
|
private final KadConfiguration config;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class ConnectOperation implements Operation, Receiver
|
|||||||
* @param bootstrap Node to use to bootstrap the local node onto the network
|
* @param bootstrap Node to use to bootstrap the local node onto the network
|
||||||
* @param config
|
* @param config
|
||||||
*/
|
*/
|
||||||
public ConnectOperation(KadServer server, KademliaNode local, Node bootstrap, KadConfiguration config)
|
public ConnectOperation(KadServer server, JKademliaNode local, Node bootstrap, KadConfiguration config)
|
||||||
{
|
{
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.localNode = local;
|
this.localNode = local;
|
||||||
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.dht.GetParameter;
|
import kademlia.dht.GetParameter;
|
||||||
import kademlia.KadConfiguration;
|
import kademlia.KadConfiguration;
|
||||||
import kademlia.KadServer;
|
import kademlia.KadServer;
|
||||||
@ -42,7 +42,7 @@ public class ContentLookupOperation implements Operation, Receiver
|
|||||||
private static final Byte FAILED = (byte) 0x03;
|
private static final Byte FAILED = (byte) 0x03;
|
||||||
|
|
||||||
private final KadServer server;
|
private final KadServer server;
|
||||||
private final KademliaNode localNode;
|
private final JKademliaNode localNode;
|
||||||
private StorageEntry contentFound = null;
|
private StorageEntry contentFound = null;
|
||||||
private final KadConfiguration config;
|
private final KadConfiguration config;
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public class ContentLookupOperation implements Operation, Receiver
|
|||||||
* @param params The parameters to search for the content which we need to find
|
* @param params The parameters to search for the content which we need to find
|
||||||
* @param config
|
* @param config
|
||||||
*/
|
*/
|
||||||
public ContentLookupOperation(KadServer server, KademliaNode localNode, GetParameter params, KadConfiguration config)
|
public ContentLookupOperation(KadServer server, JKademliaNode localNode, GetParameter params, KadConfiguration config)
|
||||||
{
|
{
|
||||||
/* Construct our lookup message */
|
/* Construct our lookup message */
|
||||||
this.lookupMessage = new ContentLookupMessage(localNode.getNode(), params);
|
this.lookupMessage = new ContentLookupMessage(localNode.getNode(), params);
|
||||||
|
@ -2,7 +2,7 @@ package kademlia.operation;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadConfiguration;
|
import kademlia.KadConfiguration;
|
||||||
import kademlia.KadServer;
|
import kademlia.KadServer;
|
||||||
import kademlia.dht.DHT;
|
import kademlia.dht.DHT;
|
||||||
@ -22,11 +22,11 @@ public class ContentRefreshOperation implements Operation
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final KadServer server;
|
private final KadServer server;
|
||||||
private final KademliaNode localNode;
|
private final JKademliaNode localNode;
|
||||||
private final DHT dht;
|
private final DHT dht;
|
||||||
private final KadConfiguration config;
|
private final KadConfiguration config;
|
||||||
|
|
||||||
public ContentRefreshOperation(KadServer server, KademliaNode localNode, DHT dht, KadConfiguration config)
|
public ContentRefreshOperation(KadServer server, JKademliaNode localNode, DHT dht, KadConfiguration config)
|
||||||
{
|
{
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.localNode = localNode;
|
this.localNode = localNode;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package kademlia.operation;
|
package kademlia.operation;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadConfiguration;
|
import kademlia.KadConfiguration;
|
||||||
import kademlia.KadServer;
|
import kademlia.KadServer;
|
||||||
import kademlia.dht.DHT;
|
import kademlia.dht.DHT;
|
||||||
@ -16,11 +16,11 @@ public class KadRefreshOperation implements Operation
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final KadServer server;
|
private final KadServer server;
|
||||||
private final KademliaNode localNode;
|
private final JKademliaNode localNode;
|
||||||
private final DHT dht;
|
private final DHT dht;
|
||||||
private final KadConfiguration config;
|
private final KadConfiguration config;
|
||||||
|
|
||||||
public KadRefreshOperation(KadServer server, KademliaNode localNode, DHT dht, KadConfiguration config)
|
public KadRefreshOperation(KadServer server, JKademliaNode localNode, DHT dht, KadConfiguration config)
|
||||||
{
|
{
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.localNode = localNode;
|
this.localNode = localNode;
|
||||||
|
@ -8,7 +8,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadConfiguration;
|
import kademlia.KadConfiguration;
|
||||||
import kademlia.KadServer;
|
import kademlia.KadServer;
|
||||||
import kademlia.exceptions.RoutingException;
|
import kademlia.exceptions.RoutingException;
|
||||||
@ -37,7 +37,7 @@ public class NodeLookupOperation implements Operation, Receiver
|
|||||||
private static final String FAILED = "Failed";
|
private static final String FAILED = "Failed";
|
||||||
|
|
||||||
private final KadServer server;
|
private final KadServer server;
|
||||||
private final KademliaNode localNode;
|
private final JKademliaNode localNode;
|
||||||
private final KadConfiguration config;
|
private final KadConfiguration config;
|
||||||
|
|
||||||
private final Message lookupMessage; // Message sent to each peer
|
private final Message lookupMessage; // Message sent to each peer
|
||||||
@ -60,7 +60,7 @@ public class NodeLookupOperation implements Operation, Receiver
|
|||||||
* @param lookupId The ID for which to find nodes close to
|
* @param lookupId The ID for which to find nodes close to
|
||||||
* @param config
|
* @param config
|
||||||
*/
|
*/
|
||||||
public NodeLookupOperation(KadServer server, KademliaNode localNode, KademliaId lookupId, KadConfiguration config)
|
public NodeLookupOperation(KadServer server, JKademliaNode localNode, KademliaId lookupId, KadConfiguration config)
|
||||||
{
|
{
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.localNode = localNode;
|
this.localNode = localNode;
|
||||||
|
@ -2,7 +2,7 @@ package kademlia.operation;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadConfiguration;
|
import kademlia.KadConfiguration;
|
||||||
import kademlia.KadServer;
|
import kademlia.KadServer;
|
||||||
import kademlia.dht.DHT;
|
import kademlia.dht.DHT;
|
||||||
@ -22,7 +22,7 @@ public class StoreOperation implements Operation
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final KadServer server;
|
private final KadServer server;
|
||||||
private final KademliaNode localNode;
|
private final JKademliaNode localNode;
|
||||||
private final StorageEntry storageEntry;
|
private final StorageEntry storageEntry;
|
||||||
private final DHT localDht;
|
private final DHT localDht;
|
||||||
private final KadConfiguration config;
|
private final KadConfiguration config;
|
||||||
@ -34,7 +34,7 @@ public class StoreOperation implements Operation
|
|||||||
* @param localDht The local DHT
|
* @param localDht The local DHT
|
||||||
* @param config
|
* @param config
|
||||||
*/
|
*/
|
||||||
public StoreOperation(KadServer server, KademliaNode localNode, StorageEntry storageEntry, DHT localDht, KadConfiguration config)
|
public StoreOperation(KadServer server, JKademliaNode localNode, StorageEntry storageEntry, DHT localDht, KadConfiguration config)
|
||||||
{
|
{
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.localNode = localNode;
|
this.localNode = localNode;
|
||||||
|
@ -3,7 +3,7 @@ package kademlia.simulations;
|
|||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import kademlia.DefaultConfiguration;
|
import kademlia.DefaultConfiguration;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadConfiguration;
|
import kademlia.KadConfiguration;
|
||||||
import kademlia.node.KademliaId;
|
import kademlia.node.KademliaId;
|
||||||
|
|
||||||
@ -22,11 +22,11 @@ public class AutoRefreshOperation implements Simulation
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Setting up 2 Kad networks */
|
/* Setting up 2 Kad networks */
|
||||||
final KademliaNode kad1 = new KademliaNode("JoshuaK", new KademliaId("ASF456789djem45674DH"), 12049);
|
final JKademliaNode kad1 = new JKademliaNode("JoshuaK", new KademliaId("ASF456789djem45674DH"), 12049);
|
||||||
final KademliaNode kad2 = new KademliaNode("Crystal", new KademliaId("AJDHR678947584567464"), 4585);
|
final JKademliaNode kad2 = new JKademliaNode("Crystal", new KademliaId("AJDHR678947584567464"), 4585);
|
||||||
final KademliaNode kad3 = new KademliaNode("Shameer", new KademliaId("AS84k6789KRNS45KFJ8W"), 8104);
|
final JKademliaNode kad3 = new JKademliaNode("Shameer", new KademliaId("AS84k6789KRNS45KFJ8W"), 8104);
|
||||||
final KademliaNode kad4 = new KademliaNode("Lokesh.", new KademliaId("ASF45678947A845674GG"), 8335);
|
final JKademliaNode kad4 = new JKademliaNode("Lokesh.", new KademliaId("ASF45678947A845674GG"), 8335);
|
||||||
final KademliaNode kad5 = new KademliaNode("Chandu.", new KademliaId("AS84kUD894758456dyrj"), 13345);
|
final JKademliaNode kad5 = new JKademliaNode("Chandu.", new KademliaId("AS84kUD894758456dyrj"), 13345);
|
||||||
|
|
||||||
/* Connecting nodes */
|
/* Connecting nodes */
|
||||||
System.out.println("Connecting Nodes");
|
System.out.println("Connecting Nodes");
|
||||||
|
@ -3,7 +3,7 @@ package kademlia.simulations;
|
|||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import kademlia.DefaultConfiguration;
|
import kademlia.DefaultConfiguration;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.KadConfiguration;
|
import kademlia.KadConfiguration;
|
||||||
import kademlia.node.KademliaId;
|
import kademlia.node.KademliaId;
|
||||||
|
|
||||||
@ -22,9 +22,9 @@ public class AutoRefreshOperation2 implements Simulation
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Setting up 2 Kad networks */
|
/* Setting up 2 Kad networks */
|
||||||
final KademliaNode kad1 = new KademliaNode("JoshuaK", new KademliaId("ASF456789djem4567463"), 12049);
|
final JKademliaNode kad1 = new JKademliaNode("JoshuaK", new KademliaId("ASF456789djem4567463"), 12049);
|
||||||
final KademliaNode kad2 = new KademliaNode("Crystal", new KademliaId("AS84k678DJRW84567465"), 4585);
|
final JKademliaNode kad2 = new JKademliaNode("Crystal", new KademliaId("AS84k678DJRW84567465"), 4585);
|
||||||
final KademliaNode kad3 = new KademliaNode("Shameer", new KademliaId("AS84k67894758456746A"), 8104);
|
final JKademliaNode kad3 = new JKademliaNode("Shameer", new KademliaId("AS84k67894758456746A"), 8104);
|
||||||
|
|
||||||
/* Connecting nodes */
|
/* Connecting nodes */
|
||||||
System.out.println("Connecting Nodes");
|
System.out.println("Connecting Nodes");
|
||||||
|
@ -3,7 +3,7 @@ package kademlia.simulations;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import kademlia.dht.GetParameter;
|
import kademlia.dht.GetParameter;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.dht.StorageEntry;
|
import kademlia.dht.StorageEntry;
|
||||||
import kademlia.exceptions.ContentNotFoundException;
|
import kademlia.exceptions.ContentNotFoundException;
|
||||||
import kademlia.node.KademliaId;
|
import kademlia.node.KademliaId;
|
||||||
@ -22,9 +22,9 @@ public class ContentSendingTest
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Setting up 2 Kad networks */
|
/* Setting up 2 Kad networks */
|
||||||
KademliaNode kad1 = new KademliaNode("JoshuaK", new KademliaId("ASF45678947584567467"), 7574);
|
JKademliaNode kad1 = new JKademliaNode("JoshuaK", new KademliaId("ASF45678947584567467"), 7574);
|
||||||
System.out.println("Created Node Kad 1: " + kad1.getNode().getNodeId());
|
System.out.println("Created Node Kad 1: " + kad1.getNode().getNodeId());
|
||||||
KademliaNode kad2 = new KademliaNode("Crystal", new KademliaId("ASERTKJDHGVHERJHGFLK"), 7572);
|
JKademliaNode kad2 = new JKademliaNode("Crystal", new KademliaId("ASERTKJDHGVHERJHGFLK"), 7572);
|
||||||
System.out.println("Created Node Kad 2: " + kad2.getNode().getNodeId());
|
System.out.println("Created Node Kad 2: " + kad2.getNode().getNodeId());
|
||||||
kad2.bootstrap(kad1.getNode());
|
kad2.bootstrap(kad1.getNode());
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package kademlia.simulations;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import kademlia.dht.GetParameter;
|
import kademlia.dht.GetParameter;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.dht.StorageEntry;
|
import kademlia.dht.StorageEntry;
|
||||||
import kademlia.exceptions.ContentNotFoundException;
|
import kademlia.exceptions.ContentNotFoundException;
|
||||||
import kademlia.node.KademliaId;
|
import kademlia.node.KademliaId;
|
||||||
@ -21,9 +21,9 @@ public class ContentUpdatingTest
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Setting up 2 Kad networks */
|
/* Setting up 2 Kad networks */
|
||||||
KademliaNode kad1 = new KademliaNode("JoshuaK", new KademliaId("ASF45678947584567467"), 7574);
|
JKademliaNode kad1 = new JKademliaNode("JoshuaK", new KademliaId("ASF45678947584567467"), 7574);
|
||||||
System.out.println("Created Node Kad 1: " + kad1.getNode().getNodeId());
|
System.out.println("Created Node Kad 1: " + kad1.getNode().getNodeId());
|
||||||
KademliaNode kad2 = new KademliaNode("Crystal", new KademliaId("ASERTKJDHGVHERJHGFLK"), 7572);
|
JKademliaNode kad2 = new JKademliaNode("Crystal", new KademliaId("ASERTKJDHGVHERJHGFLK"), 7572);
|
||||||
System.out.println("Created Node Kad 2: " + kad2.getNode().getNodeId());
|
System.out.println("Created Node Kad 2: " + kad2.getNode().getNodeId());
|
||||||
kad2.bootstrap(kad1.getNode());
|
kad2.bootstrap(kad1.getNode());
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package kademlia.simulations;
|
package kademlia.simulations;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.node.KademliaId;
|
import kademlia.node.KademliaId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,10 +18,10 @@ public class NodeConnectionTest
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Setting up 2 Kad networks */
|
/* Setting up 2 Kad networks */
|
||||||
KademliaNode kad1 = new KademliaNode("JoshuaK", new KademliaId("ASF45678947584567467"), 7574);
|
JKademliaNode kad1 = new JKademliaNode("JoshuaK", new KademliaId("ASF45678947584567467"), 7574);
|
||||||
System.out.println("Created Node Kad 1: " + kad1.getNode().getNodeId());
|
System.out.println("Created Node Kad 1: " + kad1.getNode().getNodeId());
|
||||||
|
|
||||||
KademliaNode kad2 = new KademliaNode("Crystal", new KademliaId("ASERTKJDHGVHERJHGFLK"), 7572);
|
JKademliaNode kad2 = new JKademliaNode("Crystal", new KademliaId("ASERTKJDHGVHERJHGFLK"), 7572);
|
||||||
//NodeId diff12 = kad1.getNode().getNodeId().xor(kad2.getNode().getNodeId());
|
//NodeId diff12 = kad1.getNode().getNodeId().xor(kad2.getNode().getNodeId());
|
||||||
System.out.println("Created Node Kad 2: " + kad2.getNode().getNodeId());
|
System.out.println("Created Node Kad 2: " + kad2.getNode().getNodeId());
|
||||||
// System.out.println(kad1.getNode().getNodeId() + " ^ " + kad2.getNode().getNodeId() + " = " + diff12);
|
// System.out.println(kad1.getNode().getNodeId() + " ^ " + kad2.getNode().getNodeId() + " = " + diff12);
|
||||||
@ -37,7 +37,7 @@ public class NodeConnectionTest
|
|||||||
// System.out.println(kad2.getNode().getRoutingTable());
|
// System.out.println(kad2.getNode().getRoutingTable());
|
||||||
|
|
||||||
/* Creating a new node 3 and connecting it to 1, hoping it'll get onto 2 also */
|
/* Creating a new node 3 and connecting it to 1, hoping it'll get onto 2 also */
|
||||||
KademliaNode kad3 = new KademliaNode("Jessica", new KademliaId("ASERTKJDOLKMNBVFR45G"), 7783);
|
JKademliaNode kad3 = new JKademliaNode("Jessica", new KademliaId("ASERTKJDOLKMNBVFR45G"), 7783);
|
||||||
System.out.println("\n\n\n\n\n\nCreated Node Kad 3: " + kad3.getNode().getNodeId());
|
System.out.println("\n\n\n\n\n\nCreated Node Kad 3: " + kad3.getNode().getNodeId());
|
||||||
|
|
||||||
System.out.println("Connecting Kad 3 and Kad 2");
|
System.out.println("Connecting Kad 3 and Kad 2");
|
||||||
@ -47,7 +47,7 @@ public class NodeConnectionTest
|
|||||||
// NodeId diff31 = kad1.getNode().getNodeId().xor(kad3.getNode().getNodeId());
|
// NodeId diff31 = kad1.getNode().getNodeId().xor(kad3.getNode().getNodeId());
|
||||||
// System.out.println("Kad 3 - Kad 1 distance: " + diff31.getFirstSetBitIndex());
|
// System.out.println("Kad 3 - Kad 1 distance: " + diff31.getFirstSetBitIndex());
|
||||||
// System.out.println("Kad 3 - Kad 2 distance: " + diff32.getFirstSetBitIndex());
|
// System.out.println("Kad 3 - Kad 2 distance: " + diff32.getFirstSetBitIndex());
|
||||||
KademliaNode kad4 = new KademliaNode("Sandy", new KademliaId("ASERTK85OLKMN85FR4SS"), 7789);
|
JKademliaNode kad4 = new JKademliaNode("Sandy", new KademliaId("ASERTK85OLKMN85FR4SS"), 7789);
|
||||||
System.out.println("\n\n\n\n\n\nCreated Node Kad 4: " + kad4.getNode().getNodeId());
|
System.out.println("\n\n\n\n\n\nCreated Node Kad 4: " + kad4.getNode().getNodeId());
|
||||||
|
|
||||||
System.out.println("Connecting Kad 4 and Kad 2");
|
System.out.println("Connecting Kad 4 and Kad 2");
|
||||||
|
@ -2,7 +2,7 @@ package kademlia.simulations;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import kademlia.dht.GetParameter;
|
import kademlia.dht.GetParameter;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.dht.StorageEntry;
|
import kademlia.dht.StorageEntry;
|
||||||
import kademlia.exceptions.ContentNotFoundException;
|
import kademlia.exceptions.ContentNotFoundException;
|
||||||
import kademlia.node.KademliaId;
|
import kademlia.node.KademliaId;
|
||||||
@ -21,8 +21,8 @@ public class RefreshOperationTest
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Setting up 2 Kad networks */
|
/* Setting up 2 Kad networks */
|
||||||
KademliaNode kad1 = new KademliaNode("JoshuaK", new KademliaId("ASF45678947584567467"), 7574);
|
JKademliaNode kad1 = new JKademliaNode("JoshuaK", new KademliaId("ASF45678947584567467"), 7574);
|
||||||
KademliaNode kad2 = new KademliaNode("Crystal", new KademliaId("ASERTKJDHGVHERJHGFLK"), 7572);
|
JKademliaNode kad2 = new JKademliaNode("Crystal", new KademliaId("ASERTKJDHGVHERJHGFLK"), 7572);
|
||||||
kad2.bootstrap(kad1.getNode());
|
kad2.bootstrap(kad1.getNode());
|
||||||
|
|
||||||
/* Lets create the content and share it */
|
/* Lets create the content and share it */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package kademlia.simulations;
|
package kademlia.simulations;
|
||||||
|
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.node.KademliaId;
|
import kademlia.node.KademliaId;
|
||||||
import kademlia.routing.RoutingTable;
|
import kademlia.routing.RoutingTable;
|
||||||
|
|
||||||
@ -18,11 +18,11 @@ public class RoutingTableSimulation
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Setting up 2 Kad networks */
|
/* Setting up 2 Kad networks */
|
||||||
KademliaNode kad1 = new KademliaNode("JoshuaK", new KademliaId("ASF45678947584567463"), 12049);
|
JKademliaNode kad1 = new JKademliaNode("JoshuaK", new KademliaId("ASF45678947584567463"), 12049);
|
||||||
KademliaNode kad2 = new KademliaNode("Crystal", new KademliaId("ASF45678947584567464"), 4585);
|
JKademliaNode kad2 = new JKademliaNode("Crystal", new KademliaId("ASF45678947584567464"), 4585);
|
||||||
KademliaNode kad3 = new KademliaNode("Shameer", new KademliaId("ASF45678947584567465"), 8104);
|
JKademliaNode kad3 = new JKademliaNode("Shameer", new KademliaId("ASF45678947584567465"), 8104);
|
||||||
KademliaNode kad4 = new KademliaNode("Lokesh", new KademliaId("ASF45678947584567466"), 8335);
|
JKademliaNode kad4 = new JKademliaNode("Lokesh", new KademliaId("ASF45678947584567466"), 8335);
|
||||||
KademliaNode kad5 = new KademliaNode("Chandu", new KademliaId("ASF45678947584567467"), 13345);
|
JKademliaNode kad5 = new JKademliaNode("Chandu", new KademliaId("ASF45678947584567467"), 13345);
|
||||||
|
|
||||||
RoutingTable rt = kad1.getRoutingTable();
|
RoutingTable rt = kad1.getRoutingTable();
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package kademlia.simulations;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.dht.KadContent;
|
import kademlia.dht.KadContent;
|
||||||
import kademlia.node.KademliaId;
|
import kademlia.node.KademliaId;
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ import kademlia.node.KademliaId;
|
|||||||
public class RoutingTableStateTesting
|
public class RoutingTableStateTesting
|
||||||
{
|
{
|
||||||
|
|
||||||
KademliaNode[] kads;
|
JKademliaNode[] kads;
|
||||||
|
|
||||||
public int numKads = 10;
|
public int numKads = 10;
|
||||||
|
|
||||||
@ -24,18 +24,18 @@ public class RoutingTableStateTesting
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Setting up Kad networks */
|
/* Setting up Kad networks */
|
||||||
kads = new KademliaNode[numKads];
|
kads = new JKademliaNode[numKads];
|
||||||
|
|
||||||
kads[0] = new KademliaNode("user0", new KademliaId("HRF456789SD584567460"), 1334);
|
kads[0] = new JKademliaNode("user0", new KademliaId("HRF456789SD584567460"), 1334);
|
||||||
kads[1] = new KademliaNode("user1", new KademliaId("ASF456789475DS567461"), 1209);
|
kads[1] = new JKademliaNode("user1", new KademliaId("ASF456789475DS567461"), 1209);
|
||||||
kads[2] = new KademliaNode("user2", new KademliaId("AFG45678947584567462"), 4585);
|
kads[2] = new JKademliaNode("user2", new KademliaId("AFG45678947584567462"), 4585);
|
||||||
kads[3] = new KademliaNode("user3", new KademliaId("FSF45J38947584567463"), 8104);
|
kads[3] = new JKademliaNode("user3", new KademliaId("FSF45J38947584567463"), 8104);
|
||||||
kads[4] = new KademliaNode("user4", new KademliaId("ASF45678947584567464"), 8335);
|
kads[4] = new JKademliaNode("user4", new KademliaId("ASF45678947584567464"), 8335);
|
||||||
kads[5] = new KademliaNode("user5", new KademliaId("GHF4567894DR84567465"), 13345);
|
kads[5] = new JKademliaNode("user5", new KademliaId("GHF4567894DR84567465"), 13345);
|
||||||
kads[6] = new KademliaNode("user6", new KademliaId("ASF45678947584567466"), 12049);
|
kads[6] = new JKademliaNode("user6", new KademliaId("ASF45678947584567466"), 12049);
|
||||||
kads[7] = new KademliaNode("user7", new KademliaId("AE345678947584567467"), 14585);
|
kads[7] = new JKademliaNode("user7", new KademliaId("AE345678947584567467"), 14585);
|
||||||
kads[8] = new KademliaNode("user8", new KademliaId("ASAA5678947584567468"), 18104);
|
kads[8] = new JKademliaNode("user8", new KademliaId("ASAA5678947584567468"), 18104);
|
||||||
kads[9] = new KademliaNode("user9", new KademliaId("ASF456789475845674U9"), 18335);
|
kads[9] = new JKademliaNode("user9", new KademliaId("ASF456789475845674U9"), 18335);
|
||||||
|
|
||||||
for (int i = 1; i < numKads; i++)
|
for (int i = 1; i < numKads; i++)
|
||||||
{
|
{
|
||||||
@ -50,7 +50,7 @@ public class RoutingTableStateTesting
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public KadContent putContent(String content, KademliaNode owner)
|
public KadContent putContent(String content, JKademliaNode owner)
|
||||||
{
|
{
|
||||||
DHTContentImpl c = null;
|
DHTContentImpl c = null;
|
||||||
try
|
try
|
||||||
@ -67,7 +67,7 @@ public class RoutingTableStateTesting
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdownKad(KademliaNode kad)
|
public void shutdownKad(JKademliaNode kad)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package kademlia.simulations;
|
package kademlia.simulations;
|
||||||
|
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.node.KademliaId;
|
import kademlia.node.KademliaId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,11 +17,11 @@ public class SaveStateTest
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Setting up 2 Kad networks */
|
/* Setting up 2 Kad networks */
|
||||||
KademliaNode kad1 = new KademliaNode("JoshuaK", new KademliaId("ASF45678947584567463"), 12049);
|
JKademliaNode kad1 = new JKademliaNode("JoshuaK", new KademliaId("ASF45678947584567463"), 12049);
|
||||||
KademliaNode kad2 = new KademliaNode("Crystal", new KademliaId("ASF45678947584567464"), 4585);
|
JKademliaNode kad2 = new JKademliaNode("Crystal", new KademliaId("ASF45678947584567464"), 4585);
|
||||||
KademliaNode kad3 = new KademliaNode("Shameer", new KademliaId("ASF45678947584567465"), 8104);
|
JKademliaNode kad3 = new JKademliaNode("Shameer", new KademliaId("ASF45678947584567465"), 8104);
|
||||||
KademliaNode kad4 = new KademliaNode("Lokesh", new KademliaId("ASF45678947584567466"), 8335);
|
JKademliaNode kad4 = new JKademliaNode("Lokesh", new KademliaId("ASF45678947584567466"), 8335);
|
||||||
KademliaNode kad5 = new KademliaNode("Chandu", new KademliaId("ASF45678947584567467"), 13345);
|
JKademliaNode kad5 = new JKademliaNode("Chandu", new KademliaId("ASF45678947584567467"), 13345);
|
||||||
|
|
||||||
/* Connecting 2 to 1 */
|
/* Connecting 2 to 1 */
|
||||||
System.out.println("Connecting Nodes 1 & 2");
|
System.out.println("Connecting Nodes 1 & 2");
|
||||||
@ -76,7 +76,7 @@ public class SaveStateTest
|
|||||||
kad1.shutdown(true);
|
kad1.shutdown(true);
|
||||||
|
|
||||||
System.out.println("\n\n\nReloading Kad instance from file");
|
System.out.println("\n\n\nReloading Kad instance from file");
|
||||||
KademliaNode kadR2 = KademliaNode.loadFromFile("JoshuaK");
|
JKademliaNode kadR2 = JKademliaNode.loadFromFile("JoshuaK");
|
||||||
System.out.println(kadR2);
|
System.out.println(kadR2);
|
||||||
}
|
}
|
||||||
catch (IllegalStateException e)
|
catch (IllegalStateException e)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package kademlia.simulations;
|
package kademlia.simulations;
|
||||||
|
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.dht.GetParameter;
|
import kademlia.dht.GetParameter;
|
||||||
import kademlia.dht.StorageEntry;
|
import kademlia.dht.StorageEntry;
|
||||||
import kademlia.node.KademliaId;
|
import kademlia.node.KademliaId;
|
||||||
@ -20,8 +20,8 @@ public class SaveStateTest2
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Setting up 2 Kad networks */
|
/* Setting up 2 Kad networks */
|
||||||
KademliaNode kad1 = new KademliaNode("JoshuaK", new KademliaId("ASF45678947584567463"), 12049);
|
JKademliaNode kad1 = new JKademliaNode("JoshuaK", new KademliaId("ASF45678947584567463"), 12049);
|
||||||
KademliaNode kad2 = new KademliaNode("Crystal", new KademliaId("ASF45678947584567464"), 4585);
|
JKademliaNode kad2 = new JKademliaNode("Crystal", new KademliaId("ASF45678947584567464"), 4585);
|
||||||
|
|
||||||
/* Connecting 2 to 1 */
|
/* Connecting 2 to 1 */
|
||||||
System.out.println("Connecting Nodes 1 & 2");
|
System.out.println("Connecting Nodes 1 & 2");
|
||||||
@ -46,7 +46,7 @@ public class SaveStateTest2
|
|||||||
kad1.shutdown(true);
|
kad1.shutdown(true);
|
||||||
|
|
||||||
System.out.println("\n\n\nReloading Kad instance from file");
|
System.out.println("\n\n\nReloading Kad instance from file");
|
||||||
kad1 = KademliaNode.loadFromFile("JoshuaK");
|
kad1 = JKademliaNode.loadFromFile("JoshuaK");
|
||||||
kad1.bootstrap(kad2.getNode());
|
kad1.bootstrap(kad2.getNode());
|
||||||
System.out.println(kad2);
|
System.out.println(kad2);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package kademlia.simulations;
|
package kademlia.simulations;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import kademlia.KademliaNode;
|
import kademlia.JKademliaNode;
|
||||||
import kademlia.message.SimpleMessage;
|
import kademlia.message.SimpleMessage;
|
||||||
import kademlia.node.KademliaId;
|
import kademlia.node.KademliaId;
|
||||||
import kademlia.message.SimpleReceiver;
|
import kademlia.message.SimpleReceiver;
|
||||||
@ -19,8 +19,8 @@ public class SimpleMessageTest
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
KademliaNode kad1 = new KademliaNode("Joshua", new KademliaId("12345678901234567890"), 7574);
|
JKademliaNode kad1 = new JKademliaNode("Joshua", new KademliaId("12345678901234567890"), 7574);
|
||||||
KademliaNode kad2 = new KademliaNode("Crystal", new KademliaId("12345678901234567891"), 7572);
|
JKademliaNode kad2 = new JKademliaNode("Crystal", new KademliaId("12345678901234567891"), 7572);
|
||||||
|
|
||||||
kad1.getServer().sendMessage(kad2.getNode(), new SimpleMessage("Some Message"), new SimpleReceiver());
|
kad1.getServer().sendMessage(kad2.getNode(), new SimpleMessage("Some Message"), new SimpleReceiver());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user