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.java7
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlState.java10
2 files changed, 17 insertions, 0 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 02b69c8..0ec9d6c 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
@@ -99,6 +99,7 @@ public class GossipGirl extends Module {
private void setState(StateMessage message) throws InterruptedException {
GossipGirlState state = gossipStates.get(message.getRequestId());
if (state != null) {
+ System.out.println("INFO: setting state in gossip " + Long.toString(message.getRequestId()));
state.setState(message.getZMI(), message.getQueries());
if (state.state == GossipGirlState.State.SEND_HEJKA) {
HejkaMessage hejka = new HejkaMessage(
@@ -138,14 +139,18 @@ public class GossipGirl extends Module {
private void handleNoCoTam(NoCoTamMessage message) throws InterruptedException {
GossipGirlState state = gossipStates.get(message.getReceiverGossipId());
if (state != null) {
+ System.out.println("INFO: handling NoCoTamMessage in" + Long.toString(message.getReceiverGossipId()));
state.handleNoCoTam(message);
+ System.out.println("DEBUG: handled NoCoTam in GossipGirlState");
sendInfo(state);
+ System.out.println("DEBUG: sent info after NoCoTam");
} else {
System.out.println("ERROR: GossipGirl got state for a nonexistent gossip");
}
}
private void sendInfo(GossipGirlState state) throws InterruptedException {
+ System.out.println("DEBUG: about to send info");
for (ZMI zmi : state.getZMIsToSend()) {
AttributesMessage attributesMessage = new AttributesMessage("", 0, zmi.getPathName(), zmi.getAttributes(), state.theirGossipId);
UDUPMessage udupMessage = new UDUPMessage("", 0, state.theirContact, attributesMessage);
@@ -165,6 +170,7 @@ public class GossipGirl extends Module {
private void handleAttributes(AttributesMessage message) throws InterruptedException {
GossipGirlState state = gossipStates.get(message.getReceiverGossipId());
if (state != null) {
+ System.out.println("INFO: handling Attributes in " + Long.toString(message.getReceiverGossipId()));
state.gotAttributes(message);
if (state.state == GossipGirlState.State.SEND_INFO) {
sendInfo(state);
@@ -183,6 +189,7 @@ public class GossipGirl extends Module {
private void handleQuery(QueryMessage message) throws InterruptedException {
GossipGirlState state = gossipStates.get(message.getReceiverGossipId());
if (state != null) {
+ System.out.println("INFO: handling Query in " + Long.toString(message.getReceiverGossipId()));
state.gotQuery(message.getName());
Map<Attribute, Entry<ValueQuery, ValueTime>> queries = new HashMap();
queries.put(
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 81cb9f2..6ee7474 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
@@ -124,16 +124,20 @@ public class GossipGirlState {
}
public void handleNoCoTam(NoCoTamMessage message) {
+ System.out.println("DEBUG: in GossipGirlState handleNoCoTam");
switch (state) {
case WAIT_FOR_NO_CO_TAM:
+ System.out.println("DEBUG: lets do this");
theirGossipId = message.getSenderGossipId();
theirZoneTimestamps = message.getZoneTimestamps();
theirQueryTimestamps = message.getQueryTimestamps();
hejkaSendTimestamp = message.getHejkaSendTimestamp();
hejkaReceiveTimestamp = message.getHejkaReceiveTimestamp();
+ System.out.println("DEBUG: set basic stuff");
setZonesToSend();
setQueriesToSend();
setWaitingFor();
+ System.out.println("DEBUG: set big stuff");
state = State.SEND_INFO;
break;
default:
@@ -163,6 +167,8 @@ public class GossipGirlState {
public Map<PathName, ValueTime> getZoneTimestampsToSend() {
Map<PathName, ValueTime> timestamps = new HashMap();
+ System.out.println("Getting zone timestamps to send to " + theirContact.getName().toString());
+ System.out.println("hierarchy is " + hierarchy.toString());
collectZoneTimestamps(timestamps, hierarchy, theirContact.getName());
return timestamps;
}
@@ -178,12 +184,14 @@ public class GossipGirlState {
public void setZonesToSend() {
zonesToSend = new LinkedList();
+ System.out.println("DEBUG: timestamps to send: " + getZoneTimestampsToSend().toString());
for (Entry<PathName, ValueTime> timestampedPath : getZoneTimestampsToSend().entrySet()) {
ValueTime theirTimestamp = theirZoneTimestamps.get(timestampedPath.getKey());
if (theirTimestamp == null || ValueUtils.valueLower(theirTimestamp, timestampedPath.getValue())) {
zonesToSend.add(timestampedPath.getKey());
}
}
+ System.out.println("DEBUG: zones to send: " + zonesToSend.toString());
}
public void setQueriesToSend() {
@@ -194,6 +202,7 @@ public class GossipGirlState {
queriesToSend.add(timestampedQuery.getKey());
}
}
+ System.out.println("DEBUG: Queries to send: " + queriesToSend.toString());
}
public List<ZMI> getZMIsToSend() {
@@ -222,6 +231,7 @@ public class GossipGirlState {
}
public void collectZoneTimestamps(Map<PathName, ValueTime> timestamps, ZMI currentZMI, PathName recipientPath) {
+ System.out.println("collecting timestamps, on " + currentZMI.getPathName().toString());
for (ZMI zmi : currentZMI.getSons()) {
if (interestedIn(recipientPath, zmi.getPathName())) {
ValueTime timestamp = (ValueTime) zmi.getAttributes().getOrNull("timestamp");