Content Lookup wasn't working! Fixed the issue! stupid "!" in the damn statement!

This commit is contained in:
Joshua Kissoon 2014-03-31 21:28:45 +05:30
parent a259579f4a
commit b1ab1be760
5 changed files with 19 additions and 11 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -36,6 +36,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);
}

View File

@ -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;

View File

@ -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();
}