m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMagdalena GrodziƄska <mag.grodzinska@gmail.com>2020-01-11 12:59:05 +0100
committerGitHub <noreply@github.com>2020-01-11 12:59:05 +0100
commitf54068421c2b4883b3fbcc4e003d83ff528b5cc4 (patch)
treef51ff1d4dfe7599eb513b093a27674cd20f78888 /src
parentea35ef1c86401257d82daf978d5870285f7c163e (diff)
parentfb16df8494e39327038a78b768538fefa3025337 (diff)
Merge pull request #95 from m-chrzan/small_fixes
Small fixes
Diffstat (limited to 'src')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java13
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java7
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java1
-rw-r--r--src/main/resources/application.properties4
-rw-r--r--src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html10
-rw-r--r--src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/home.html2
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java1
7 files changed, 25 insertions, 13 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("/")
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index bb48ff5..ee983e2 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,7 +1,7 @@
-server.port=0
+server.port=8082
spring.application.name=CloudAtlas Client
-spring.thymeleaf.cache=false
+spring.thymeleaf.cache=true
spring.thymeleaf.enabled=true
spring.thymeleaf.prefix=classpath:/pl/edu/mimuw/cloudatlas/client/templates/
spring.thymeleaf.suffix=.html
diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html
index ab83053..841d995 100644
--- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html
+++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html
@@ -4,8 +4,11 @@
<head>
<meta charset="UTF-8">
<title>Attributes chart</title>
+ <link rel="preload" href="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" as="script">
+ <link rel="preload" href="https://www.gstatic.com/charts/loader.js" as="script">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
- <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
+ <script async type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
+ <script async type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart', 'table', 'controls', 'charteditor']});
google.charts.setOnLoadCallback(refreshChart());
@@ -13,6 +16,8 @@
var chartState = [];
function refreshChart() {
+ setTimeout(getData(), 500);
+ setTimeout(getData(), 1500);
setInterval(getData, 5000);
}
@@ -101,7 +106,7 @@
data.addColumn('string', col);
}
jsonData.shift();
- data.addRow(jsonData[0]);
+ data.addRow(jsonData[jsonData.length - 1]);
var table = new google.visualization.Table(document.getElementById('table_div'));
@@ -135,7 +140,6 @@
<div id="table_div" class="d-flex justify-content-center mt-5"></div>
</div>
-<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/home.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/home.html
index 47b19af..043ac76 100644
--- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/home.html
+++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/home.html
@@ -6,6 +6,8 @@
<meta charset="UTF-8">
<title>CloudAtlas Client - home</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
+ <link rel="preload" href="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" as="script">
+ <link rel="preload" href="https://www.gstatic.com/charts/loader.js" as="script">
</head>
<body>
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java
index 681483d..8fba76e 100644
--- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java
@@ -26,6 +26,7 @@ public class GossipGirlStrategyTest {
gossipGirlStrategies.selectStrategy(GossipGirlStrategies.ZoneSelectionStrategy.ROUND_ROBIN_EXP_FREQ);
freqs.put(selectedPath, freqs.get(selectedPath) + 1);
System.out.println(selectedPath);
+ System.out.println(freqs);
}
}
}