fixed find value. -> there was a problem with the routing table

lot more debug symbols
This commit is contained in:
Ulf Gebhardt 2013-02-10 18:39:30 +01:00
parent 72408bb79b
commit 576dced42f
3 changed files with 14 additions and 8 deletions

View File

@ -109,6 +109,7 @@ public class Ack {
Level.FINE,
"Didn't receive RPC Ack {0} by now. Resending... ",
new Object[] { rpcId });
LOGGER.log(Level.INFO, receiver.getAddress().toString());
channel.send(buffer, receiver.getAddress());
} catch (IOException e) {
e.printStackTrace();

View File

@ -137,15 +137,16 @@ public class Node {
}
}
void sendFindValue(NodeIdentifier receiver, Identifier idToFind) {
void sendFindValue(NodeIdentifier receiver, Identifier idToFind) {
// need to save the fileID because we need it for future searches
this.searchID = idToFind;
LOGGER.log(Level.INFO, "Sending [FIND_VALUE {0}] to node {1}",new Object[] { idToFind, receiver });
boolean successful = send(receiver, MessageType.FIND_VALUE,
idToFind.getBytes(), true, null);
if (successful) {
LOGGER.log(Level.INFO, "Sending [FIND_VALUE {0}] to node {1}",
LOGGER.log(Level.INFO, "Sent [FIND_VALUE {0}] to node {1}",
new Object[] { idToFind, receiver });
}
}
@ -293,10 +294,11 @@ public class Node {
*/
private boolean send(NodeIdentifier to, byte messageType, Identifier rpcID,
byte[] data, boolean reliable, MessageCallback cb) {
boolean successful = true;
ByteBuffer buffer = ByteBuffer.allocate(BUFFER_SIZE);
buffer.put(messageType);
buffer.put(this.nodeID.getBytes());
buffer.put(rpcID.getBytes());
@ -305,6 +307,8 @@ public class Node {
buffer.put(data);
}
LOGGER.log(Level.INFO, "Sending Data to:{0} with MT:"+messageType+" data:"+buffer.toString(), to.getAddress().toString());
buffer.flip();
try {
@ -313,7 +317,7 @@ public class Node {
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Failed to write to channel", e);
LOGGER.log(Level.SEVERE, "Failed to write to channel. To:"+to.getAddress().toString()+" buffer: "+buffer.toString(), e);
successful = false;
} finally {
@ -371,8 +375,8 @@ public class Node {
public void findValue(Identifier key) {
Set<NodeIdentifier> nodes = routingTable.getClosestNodesTo(key);
for (NodeIdentifier node : nodes) {
sendFindValue(node, key);
for (NodeIdentifier node : nodes) {
sendFindValue(node, key);
}
}

View File

@ -195,8 +195,9 @@ public class UDPHandler implements Runnable {
while (buffer.hasRemaining()) {
NodeIdentifier newID = getNodeTripleFromBuffer();
node.sendFindValue(newID, node.getSearchID());
nodes.append(newID).append(", ");
//TODO I commented this - im not sure thats right, but the sendFindValue fails!
//node.sendFindValue(newID, node.getSearchID());
//nodes.append(newID).append(", ");
numReceived++;
}