diff --git a/src/kademlia/dht/StorageEntry.java b/src/kademlia/dht/StorageEntry.java index 5d6b422..2bdb94d 100644 --- a/src/kademlia/dht/StorageEntry.java +++ b/src/kademlia/dht/StorageEntry.java @@ -64,7 +64,7 @@ public class StorageEntry { return false; } - + /* Check that type matches */ if ((params.getType() != null) && (!params.getType().equals(this.type))) { @@ -72,7 +72,7 @@ public class StorageEntry } /* Check that key matches */ - return ((params.getKey() != null) && (!params.getKey().equals(this.key))); + return (params.getKey() != null) && (params.getKey().equals(this.key)); } @Override diff --git a/src/kademlia/dht/StorageEntryManager.java b/src/kademlia/dht/StorageEntryManager.java index 70bec3f..27fa91e 100644 --- a/src/kademlia/dht/StorageEntryManager.java +++ b/src/kademlia/dht/StorageEntryManager.java @@ -76,6 +76,7 @@ class StorageEntryManager { if (this.entries.containsKey(param.getKey())) { + System.out.println("Does contain the key"); /* Content with this key exist, check if any match the rest of the search criteria */ for (StorageEntry e : this.entries.get(param.getKey())) { @@ -86,6 +87,11 @@ class StorageEntryManager } } } + else + { + System.out.println("Does not contain the key"); + System.out.println(this); + } return false; } diff --git a/src/kademlia/message/ContentLookupReceiver.java b/src/kademlia/message/ContentLookupReceiver.java index baa6cee..7e52f14 100644 --- a/src/kademlia/message/ContentLookupReceiver.java +++ b/src/kademlia/message/ContentLookupReceiver.java @@ -35,6 +35,9 @@ 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())); /* Check if we can have this data */ if (this.dht.contains(msg.getParameters())) @@ -49,6 +52,7 @@ public class ContentLookupReceiver implements Receiver * Return a the K closest nodes to this content identifier * We create a NodeLookupReceiver and let this receiver handle this operation */ + System.out.println("We do not have this content"); NodeLookupMessage lkpMsg = new NodeLookupMessage(msg.getOrigin(), msg.getParameters().getKey()); new NodeLookupReceiver(server, localNode, this.config).receive(lkpMsg, comm); } diff --git a/src/kademlia/operation/ConnectOperation.java b/src/kademlia/operation/ConnectOperation.java index b41e25b..2519dab 100644 --- a/src/kademlia/operation/ConnectOperation.java +++ b/src/kademlia/operation/ConnectOperation.java @@ -6,7 +6,6 @@ package kademlia.operation; import java.io.IOException; -import kademlia.core.DefaultConfiguration; import kademlia.core.KadConfiguration; import kademlia.core.KadServer; import kademlia.exceptions.RoutingException; diff --git a/src/kademlia/operation/ContentLookupOperation.java b/src/kademlia/operation/ContentLookupOperation.java index 78fad0b..fcb2cb3 100644 --- a/src/kademlia/operation/ContentLookupOperation.java +++ b/src/kademlia/operation/ContentLookupOperation.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; -import kademlia.core.DefaultConfiguration; import kademlia.core.GetParameter; import kademlia.core.KadConfiguration; import kademlia.core.KadServer; @@ -35,10 +34,10 @@ public class ContentLookupOperation implements Operation, Receiver { /* Constants */ - private static final Byte UNASKED = new Byte((byte) 0x00); - private static final Byte AWAITING = new Byte((byte) 0x01); - private static final Byte ASKED = new Byte((byte) 0x02); - private static final Byte FAILED = new Byte((byte) 0x03); + private static final Byte UNASKED = (byte) 0x00; + private static final Byte AWAITING = (byte) 0x01; + private static final Byte ASKED = (byte) 0x02; + private static final Byte FAILED = (byte) 0x03; private final KadServer server; private final Node localNode; @@ -194,7 +193,7 @@ public class ContentLookupOperation implements Operation, Receiver int comm = server.sendMessage(n, lookupMessage, this); this.nodes.put(n, AWAITING); - this.messagesTransiting.put(new Integer(comm), n); + this.messagesTransiting.put(comm, n); } /* We're not finished as yet, return false */ @@ -277,7 +276,7 @@ public class ContentLookupOperation implements Operation, Receiver this.nodes.put(origin, ASKED); /* Remove this msg from messagesTransiting since it's completed now */ - this.messagesTransiting.remove(new Integer(comm)); + this.messagesTransiting.remove(comm); /* Add the received nodes to our nodes list to query */ this.addNodes(msg.getNodes()); @@ -306,7 +305,7 @@ public class ContentLookupOperation implements Operation, Receiver /* Mark this node as failed */ this.nodes.put(n, FAILED); this.localNode.getRoutingTable().remove(n); - this.messagesTransiting.remove(new Integer(comm)); + this.messagesTransiting.remove(comm); this.askNodesorFinish(); }