find_value finished i guess, but not tested yet
This commit is contained in:
parent
790fb3540d
commit
f5664fa49f
@ -13,4 +13,5 @@ public class MessageType {
|
||||
public final static byte STORE = 5;
|
||||
public final static byte DATA = 6;
|
||||
public final static byte VALUE_NODES = 7;
|
||||
public final static byte FOUND_VALUE = 8;
|
||||
}
|
||||
|
||||
@ -149,6 +149,16 @@ public class Node {
|
||||
new Object[] { idToFind, receiver });
|
||||
}
|
||||
}
|
||||
|
||||
void sendFoundValue(NodeIdentifier receiver, Identifier idToFind) {
|
||||
boolean successful = send(receiver, MessageType.FOUND_VALUE,
|
||||
values.get(idToFind).getBytes(), true, null);
|
||||
|
||||
if (successful) {
|
||||
LOGGER.log(Level.INFO, "Sending [FOUND_VALUE {0}] to node {1}",
|
||||
new Object[] { values.get(idToFind), receiver });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all nodes of this nodes routing table, that are close to a given node/fileID
|
||||
|
||||
@ -130,6 +130,9 @@ public class UDPHandler implements Runnable {
|
||||
case MessageType.VALUE_NODES:
|
||||
receiveValueNodes(fromID, rpcID);
|
||||
break;
|
||||
case MessageType.FOUND_VALUE:
|
||||
receiveFoundValue(fromID, rpcID);
|
||||
break;
|
||||
case MessageType.STORE:
|
||||
receiveStore(fromID, rpcID);
|
||||
break;
|
||||
@ -168,6 +171,11 @@ public class UDPHandler implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private void receiveFoundValue(NodeIdentifier fromID, Identifier rpcID) {
|
||||
// TODO Auto-generated method stub
|
||||
// Node kontaktieren, damit Datei gesendet werden kann.
|
||||
}
|
||||
|
||||
private void receiveValueNodes(NodeIdentifier fromID, Identifier rpcID) {
|
||||
int numReceived = 0;
|
||||
|
||||
@ -274,7 +282,8 @@ public class UDPHandler implements Runnable {
|
||||
new Object[] { fileID, fromID });
|
||||
|
||||
if (node.hasKey(fileID)) {
|
||||
//TODO: NodeID, welche das File hat, schicken
|
||||
node.sendFoundValue(fromID, fileID);
|
||||
node.receivedRPC(fromID, rpcID);
|
||||
} else {
|
||||
node.sendClosestNodesTo(fromID, fileID, rpcID, false);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user