diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2020-01-11 13:08:21 +0100 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2020-01-11 13:08:21 +0100 |
commit | b87f3adc2dd665b186866d2fb345819dba2d1f35 (patch) | |
tree | 6845a53aab8b5f2f54db15364afcc8efb181c605 /src/main/java/pl | |
parent | f624f7350e0018060ad3f38be1c3988bc3fb0545 (diff) | |
parent | f54068421c2b4883b3fbcc4e003d83ff528b5cc4 (diff) |
Merge branch 'master' into gossip-girl-2
Diffstat (limited to 'src/main/java/pl')
3 files changed, 13 insertions, 8 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java index 4cd534e..79efe39 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java @@ -34,7 +34,6 @@ public class GossipGirlStrategies { ArrayList<Pair<String, Double>> zoneProbabilities; zoneProbabilities = new ArrayList<>(fullPathLength); - // TODO check if we decrease in good direction for (int i = 0; i < fullPathLength; i++) { Pair<String, Double> probPair = new Pair<String, Double>(fullPathComponents.get(i), Math.exp((double) i+1)); zoneProbabilities.add(probPair); @@ -48,7 +47,6 @@ public class GossipGirlStrategies { zoneProbabilities = new ArrayList<>(fullPathLength); Double uniformProb = 1.0/fullPathLength; - // TODO good direction for (int i = 0; i < fullPathLength; i++) { Pair<String, Double> probPair = new Pair<String, Double>(fullPathComponents.get(i), uniformProb); zoneProbabilities.add(probPair); @@ -72,10 +70,9 @@ public class GossipGirlStrategies { } private String updateRoundRobinExpFreqs() { - // TODO good direction - for (int i = roundRobinExpFreqs.size() - 1; i > 0; i--) { + for (int i = 0; i < roundRobinExpFreqs.size() - 1; i++) { Pair<String, Integer> p = roundRobinExpFreqs.get(i); - Pair<String, Integer> nextP = roundRobinExpFreqs.get(i-1); + Pair<String, Integer> nextP = roundRobinExpFreqs.get(i+1); if (2 * p.getSecond() < nextP.getSecond()) { roundRobinExpFreqs.set(i, new Pair<String, Integer>(p.getFirst(), p.getSecond() + 1)); @@ -83,8 +80,10 @@ public class GossipGirlStrategies { } } - Pair<String, Integer> rootPath = roundRobinExpFreqs.get(0); - roundRobinExpFreqs.set(0, new Pair<String, Integer>(rootPath.getFirst(), rootPath.getSecond() + 1)); + Pair<String, Integer> rootPath = roundRobinExpFreqs.get(roundRobinExpFreqs.size() - 1); + roundRobinExpFreqs.set( + roundRobinExpFreqs.size() - 1, + new Pair<String, Integer>(rootPath.getFirst(), rootPath.getSecond() + 1)); return rootPath.getFirst(); } diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java index 6761c94..3fca1d5 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java @@ -1,5 +1,6 @@ package pl.edu.mimuw.cloudatlas.agent.modules; +import java.nio.file.Path; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -141,7 +142,11 @@ public class Stanik extends Module { */ public void handleSetAttribte(SetAttributeMessage message) { try { - ZMI zmi = hierarchy.findDescendant(new PathName(message.getPathName())); + PathName descendantPath = new PathName(message.getPathName()); + if (!hierarchy.descendantExists(descendantPath)) { + addMissingZones(descendantPath); + } + ZMI zmi = hierarchy.findDescendant(descendantPath); ValueTime updateTimestamp = message.getUpdateTimestamp(); ValueTime currentTimestamp = (ValueTime) zmi.getAttributes().getOrNull("timestamp"); if (ValueUtils.valueLower(currentTimestamp, updateTimestamp)) { 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 120d80d..0715af5 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java @@ -53,6 +53,7 @@ public class ClientController { } }; this.currentZoneName = "/uw/violet07"; + fetchAttributeData(); // fetch attribute data as early as possible } @GetMapping("/") |