m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2020-01-28 02:09:08 +0000
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2020-01-28 02:09:08 +0000
commit93dd589450bb61e57588065f03d1582f0ffc2f6a (patch)
treed2b5ba4bfae5d773c95632614d61763eeafa1a7e /src/main/java/pl
parent67303cfe22770fe7110841d6d3609657fed218c0 (diff)
Fix contact selection and add excessive logs
Diffstat (limited to 'src/main/java/pl')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/HierarchyConfig.java42
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java11
2 files changed, 43 insertions, 10 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/HierarchyConfig.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/HierarchyConfig.java
index 1087b8a..11d6ef0 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/HierarchyConfig.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/HierarchyConfig.java
@@ -50,8 +50,10 @@ public class HierarchyConfig {
PathName gossipLevel = gossipGirlStrategies.selectStrategy(zoneSelectionStrategy);
ValueContact contact;
if (random.nextDouble() < 0.2) {
+ System.out.println("FORCING FALLBACK");
contact = selectFallbackContact(state.getContacts());
} else {
+ System.out.println("LOOKING FOR CONTACT");
contact = selectContactFromLevel(gossipLevel, state);
}
@@ -66,6 +68,7 @@ public class HierarchyConfig {
System.out.println("Interrupted while initiating gossip");
} catch (Exception e) {
System.out.println("ERROR: something happened " + e.toString());
+ e.printStackTrace();
}
}
};
@@ -77,13 +80,21 @@ public class HierarchyConfig {
ZMI root = state.getZMI();
List<ZMI> siblings = getSiblings(root, path);
filterEmptyContacts(siblings);
+ System.out.println("filtered siblings: " + siblings.toString());
if (siblings.isEmpty()) {
+ System.out.println("SIBLINGS IS EMPTY!!!");
return selectFallbackContact(state.getContacts());
}
ZMI zmi = selectZMI(siblings);
+ System.out.println("SELECTED: " + zmi.toString());
ValueSet contactsValue = (ValueSet) zmi.getAttributes().getOrNull("contacts");
- Set<Value> valueSet = contactsValue.getValue();
+ System.out.println("ITS CONTACTS: " + contactsValue.toString());
+ Set<Value> valueSetOrig = contactsValue.getValue();
+ System.out.println("valueSetOrig: " + valueSetOrig.toString());
+ Set<Value> valueSet = new HashSet(valueSetOrig);
+ System.out.println("valueSet: " + valueSet.toString());
filterOurContact(valueSet);
+ System.out.println("FILTERED VALUE SET: " + valueSet.toString());
return selectContactFromSet(valueSet);
}
@@ -93,7 +104,7 @@ public class HierarchyConfig {
Value value = (Value) it.next();
if (value.getType().getPrimaryType() == Type.PrimaryType.CONTACT) {
ValueContact contact = (ValueContact) value;
- if (!contact.getName().equals(ourPath)) {
+ if (contact.getName().equals(ourPath)) {
it.remove();
}
} else {
@@ -129,7 +140,12 @@ public class HierarchyConfig {
}
private <T> ValueContact selectContactFromSet(Set<T> contacts) throws Exception {
+ if (contacts.size() == 0) {
+ System.out.println("GOT EMPTY SET FOR SELECTION");
+ return null;
+ }
int i = random.nextInt(contacts.size());
+ System.out.println("ROLLED RANDOM: " + Integer.toString(i));
for (T contact : contacts) {
if (i == 0) {
return (ValueContact) contact;
@@ -142,13 +158,14 @@ public class HierarchyConfig {
private List<ZMI> getSiblings(ZMI root, PathName path) {
try {
- List<ZMI> siblingsAndI = root.findDescendant(path).getFather().getSons();
+ System.out.println("DEBUG: path in getSiblings: " + path.toString());
+ List<ZMI> siblingsImm = root.findDescendant(path).getFather().getSons();
+ System.out.println("DEBUG: siblingsImm: " + siblingsImm.toString());
List<ZMI> siblings = new ArrayList();
- for (ZMI siblingOrI : siblingsAndI) {
- if (!siblingOrI.getPathName().equals(path)) {
- siblings.add(siblingOrI);
- }
+ for (ZMI siblingOrI : siblingsImm) {
+ siblings.add(siblingOrI);
}
+ System.out.println("found siblings: " + siblings.toString());
return siblings;
} catch (ZMI.NoSuchZoneException e) {
System.out.println("ERROR: didn't find path when looking for siblings");
@@ -161,9 +178,14 @@ public class HierarchyConfig {
while (iterator.hasNext()) {
ZMI zmi = iterator.next();
ValueSet contacts = (ValueSet) zmi.getAttributes().getOrNull("contacts");
+ System.out.println("checking zmi " + zmi.toString());
+ System.out.println("its contacts: " + contacts.toString());
if (contacts == null || contacts.isNull() || contacts.isEmpty() || onlyContactIsUs(contacts)) {
+ System.out.println("Let's remove it!");
iterator.remove();
- }
+ } else {
+ System.out.println("Let's keep it!");
+ }
}
}
@@ -172,14 +194,14 @@ public class HierarchyConfig {
if (value.getType().getPrimaryType() == Type.PrimaryType.CONTACT) {
ValueContact contact = (ValueContact) value;
if (!contact.getName().equals(ourPath)) {
- return true;
+ return false;
}
} else {
System.out.println("WARN: non contact value passed to onlyContactIsUs");
}
}
- return false;
+ return true;
}
public void startQueries(long queriesPeriod) {
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java
index b11a8b7..bbdb8dc 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java
@@ -45,10 +45,21 @@ public class ClientController {
String agentHostname = System.getProperty("agent_hostname");
Registry registry = LocateRegistry.getRegistry(agentHostname);
this.agentApi = (Api) registry.lookup("Api");
+ System.out.println("agent api:");
+ System.out.println(this.agentApi);
String querySignerHostname = System.getProperty("query_signer_hostname");
Registry querySignerRegistry = LocateRegistry.getRegistry(querySignerHostname);
+ System.out.println("querySignerHostname: " + querySignerHostname);
+ System.out.println(InetAddress.getByName("localhost"));
+ System.out.println(InetAddress.getByName(querySignerHostname));
+ System.out.println("LIST:");
+ System.out.println(querySignerRegistry.list());
+ System.out.println("registry:");
+ System.out.println(querySignerRegistry);
this.querySignerApi = (QuerySignerApi) querySignerRegistry.lookup("QuerySignerApi");
+ System.out.println("api:");
+ System.out.println(this.querySignerApi);
} catch (Exception e) {
System.err.println("Client exception:");
e.printStackTrace();