m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/agent/modules')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirl.java10
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlState.java1
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPServer.java2
3 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirl.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirl.java
index dd8f0b7..fb721dc 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirl.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirl.java
@@ -36,6 +36,7 @@ public class GossipGirl extends Module {
public void handleTyped(GossipGirlMessage message) throws InterruptedException, InvalidMessageType {
switch(message.getType()) {
+ System.out.println("INFO: got GossipGirlMessage " + message.getType());
case INITIATE:
initiateGossip((InitiateGossipMessage) message);
break;
@@ -59,6 +60,7 @@ public class GossipGirl extends Module {
public void handleTyped(ResponseMessage message) throws InterruptedException, InvalidMessageType {
switch(message.getType()) {
case STATE:
+ System.out.println("INFO: GossipGirl got a StateMessage");
setState((StateMessage) message);
break;
default:
@@ -72,6 +74,7 @@ public class GossipGirl extends Module {
gossipStates.put(gossipId, new GossipGirlState(gossipId, message.getOurPath(), message.getTheirContact(), true));
GetStateMessage getState = new GetStateMessage("", 0, ModuleType.GOSSIP, gossipId);
+ System.out.println("INFO: GossipGirl sending GetStateMessage when initiating");
sendMessage(getState);
}
@@ -89,6 +92,7 @@ public class GossipGirl extends Module {
gossipStates.get(gossipId).handleHejka(message);
GetStateMessage getState = new GetStateMessage("", 0, ModuleType.GOSSIP, gossipId);
+ System.out.println("INFO: GossipGirl sending GetStateMessage when responding");
sendMessage(getState);
}
@@ -107,6 +111,7 @@ public class GossipGirl extends Module {
state.getQueryTimestampsToSend()
);
UDUPMessage udupMessage = new UDUPMessage("", 0, state.theirContact, hejka);
+ System.out.println("INFO: GossipGirl sending HejkaMessage");
sendMessage(udupMessage);
state.sentHejka();
} else if (state.state == GossipGirlState.State.SEND_NO_CO_TAM) {
@@ -121,6 +126,7 @@ public class GossipGirl extends Module {
state.hejkaReceiveTimestamp
);
UDUPMessage udupMessage = new UDUPMessage("", 0, state.theirContact, noCoTam);
+ System.out.println("INFO: GossipGirl sending NoCoTamMessage");
sendMessage(udupMessage);
state.sentNoCoTam();
}
@@ -143,12 +149,14 @@ public class GossipGirl extends Module {
for (ZMI zmi : state.getZMIsToSend()) {
AttributesMessage attributesMessage = new AttributesMessage("", 0, zmi.getPathName(), zmi.getAttributes(), state.theirGossipId);
UDUPMessage udupMessage = new UDUPMessage("", 0, state.theirContact, attributesMessage);
+ System.out.println("INFO: GossipGirl sending AttributesMessage");
sendMessage(udupMessage);
}
for (Entry<Attribute, ValueQuery> query : state.getQueriesToSend()) {
QueryMessage queryMessage = new QueryMessage("", 0, query.getKey(), query.getValue(), state.theirGossipId);
UDUPMessage udupMessage = new UDUPMessage("", 0, state.theirContact, queryMessage);
+ System.out.println("INFO: GossipGirl sending QueryMessage");
sendMessage(udupMessage);
}
state.sentInfo();
@@ -162,6 +170,7 @@ public class GossipGirl extends Module {
sendInfo(state);
}
UpdateAttributesMessage updateMessage = new UpdateAttributesMessage("", 0, message.getPath().toString(), message.getAttributes());
+ System.out.println("INFO: GossipGirl sending UpdateAttributesMessage");
sendMessage(updateMessage);
if (state.state == GossipGirlState.State.FINISHED) {
gossipStates.remove(message.getReceiverGossipId());
@@ -181,6 +190,7 @@ public class GossipGirl extends Module {
new SimpleImmutableEntry(message.getQuery(), state.getTheirQueryTimestamp(message.getName()))
);
UpdateQueriesMessage updateMessage = new UpdateQueriesMessage("", 0, queries);
+ System.out.println("INFO: GossipGirl sending UpdateQueriesMessage");
sendMessage(updateMessage);
if (state.state == GossipGirlState.State.FINISHED) {
gossipStates.remove(message.getReceiverGossipId());
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlState.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlState.java
index eafbcca..81cb9f2 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlState.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlState.java
@@ -59,6 +59,7 @@ public class GossipGirlState {
this.gossipId = gossipId;
this.ourPath = ourPath;
this.theirContact = theirContact;
+ System.out.println("INFO: initializing Gossip state, their contact " + theirContact.toString());
if (initiating) {
state = State.WAIT_FOR_STATE_INITIALIZER;
} else {
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPServer.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPServer.java
index 0c5bc86..3da380c 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPServer.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPServer.java
@@ -23,7 +23,7 @@ public class UDUPServer implements Runnable {
private final AtomicBoolean running;
public UDUPServer(InetAddress addr, int port, int bufSize) throws SocketException {
- this.socket = new DatagramSocket(port, addr);
+ this.socket = new DatagramSocket(port);
this.address = addr;
this.bufSize = bufSize;
this.partialPackets = new HashMap<>();