From 8a44299b0072a8bedd1c0d74f92d258379c8447a Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Mon, 6 Jan 2020 12:57:33 +0100 Subject: Increase freshness threshold in tests --- src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java | 3 ++- src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java | 4 +++- src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java | 2 +- src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java index 0efa710..26f0e0b 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java @@ -46,7 +46,8 @@ public class Agent { HashMap modules = new HashMap(); modules.put(ModuleType.TIMER_SCHEDULER, new TimerScheduler(ModuleType.TIMER_SCHEDULER)); modules.put(ModuleType.RMI, new Remik()); - modules.put(ModuleType.STATE, new Stanik()); + Long freshnessPeriod = new Long(System.getProperty("freshness_period")); + modules.put(ModuleType.STATE, new Stanik(freshnessPeriod)); modules.put(ModuleType.QUERY, new Qurnik()); // TODO add modules as we implement them return modules; 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 6c0f380..6761c94 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 @@ -94,6 +94,8 @@ public class Stanik extends Module { private boolean pruneZMI(ZMI zmi, ValueTime time) { Value timestamp = zmi.getAttributes().get("timestamp"); + boolean isLeaf = zmi.getSons().isEmpty(); + List sonsToRemove = new LinkedList(); if (ValueUtils.valueLower(timestamp, time.subtract(new ValueDuration(freshnessPeriod)))) { if (zmi.getFather() != null) { @@ -111,7 +113,7 @@ public class Stanik extends Module { zmi.removeSon(son); } - if (zmi.getSons().isEmpty()) { + if (!isLeaf && zmi.getSons().isEmpty()) { return true; } diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java index e4684cd..f69ed8f 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java @@ -47,7 +47,7 @@ public class AgentIntegrationTest { public static void bindApi() throws Exception { registryProcess = Runtime.getRuntime().exec("./scripts/registry"); Thread.sleep(10000); - agentProcess = Runtime.getRuntime().exec("./gradlew runAgent -Dhostname=localhost"); + agentProcess = Runtime.getRuntime().exec("./gradlew runAgent -Dhostname=localhost -DfreshnessPeriod=10000000"); Thread.sleep(10000); registry = LocateRegistry.getRegistry("localhost"); diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java index 431122b..2bd63f6 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java @@ -37,7 +37,7 @@ public class ClientTest { public static void bindApi() throws Exception { registryProcess = Runtime.getRuntime().exec("./scripts/registry"); Thread.sleep(10000); - agentProcess = Runtime.getRuntime().exec("./gradlew runAgent -Dhostname=localhost"); + agentProcess = Runtime.getRuntime().exec("./gradlew runAgent -Dhostname=localhost -DfreshnessPeriod=10000000"); Thread.sleep(10000); registry = LocateRegistry.getRegistry("localhost"); -- cgit v1.2.3