added Map for Key, Value pairs, FileIdentifier Class and some Methods for the Map
This commit is contained in:
parent
6c496655ef
commit
8fca6bbec2
16
ws2012/P2P/uebungen/11/src/node/FileIdentifier.java
Normal file
16
ws2012/P2P/uebungen/11/src/node/FileIdentifier.java
Normal file
@ -0,0 +1,16 @@
|
||||
package node;
|
||||
|
||||
public class FileIdentifier extends Identifier {
|
||||
|
||||
private String key;
|
||||
|
||||
public FileIdentifier(int size, byte[] bytes, String key) {
|
||||
super(size, bytes);
|
||||
this.key = key;
|
||||
// TODO: key muss noch gehasht werden
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
}
|
||||
@ -45,6 +45,7 @@ public class Node {
|
||||
private DatagramChannel channel;
|
||||
|
||||
private Map<Identifier, List<Ack>> rpcs = new HashMap<Identifier, List<Ack>>();
|
||||
private Map<Identifier, Identifier> values = new HashMap<Identifier, Identifier>();
|
||||
|
||||
private Thread thread;
|
||||
private UDPHandler udpListen;
|
||||
@ -302,6 +303,14 @@ public class Node {
|
||||
public Set<NodeIdentifier> getNeighbors() {
|
||||
return routingTable.getEntries();
|
||||
}
|
||||
|
||||
public void StorePair(FileIdentifier key, NodeIdentifier id) {
|
||||
values.put(key, id);
|
||||
}
|
||||
|
||||
public boolean hasKey(FileIdentifier key) {
|
||||
return values.containsKey(key);
|
||||
}
|
||||
|
||||
public boolean receivedRPC(NodeIdentifier fromID, Identifier rpcID) {
|
||||
List<Ack> rpcsFromID = rpcs.get(rpcID);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user