From aaafdf783f765f581e723536c08d0675cc8df133 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Mon, 30 Dec 2019 14:46:06 +0100 Subject: Add new modules to Agent --- src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas') 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 1b078cf..ce92873 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java @@ -7,7 +7,9 @@ import java.util.Map; import pl.edu.mimuw.cloudatlas.agent.modules.Module; import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType; +import pl.edu.mimuw.cloudatlas.agent.modules.Qurnik; import pl.edu.mimuw.cloudatlas.agent.modules.RMI; +import pl.edu.mimuw.cloudatlas.agent.modules.Stanik; import pl.edu.mimuw.cloudatlas.agent.modules.TimerScheduler; public class Agent { @@ -16,6 +18,8 @@ public class Agent { HashMap modules = new HashMap(); modules.put(ModuleType.TIMER_SCHEDULER, new TimerScheduler(ModuleType.TIMER_SCHEDULER)); modules.put(ModuleType.RMI, new RMI(ModuleType.RMI)); + modules.put(ModuleType.STATE, new Stanik()); + modules.put(ModuleType.QUERY, new Qurnik()); // TODO add modules as we implement them return modules; } -- cgit v1.2.3 From 9e047485e990bd5dabbee4f1e9cf58489da964df Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Mon, 30 Dec 2019 14:50:42 +0100 Subject: Refactor iterable loops --- src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java | 11 ++--------- src/main/java/pl/edu/mimuw/cloudatlas/agent/EventBus.java | 6 +----- .../java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java | 1 - 3 files changed, 3 insertions(+), 15 deletions(-) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas') 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 ce92873..392e0a1 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java @@ -2,7 +2,6 @@ package pl.edu.mimuw.cloudatlas.agent; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import pl.edu.mimuw.cloudatlas.agent.modules.Module; @@ -27,11 +26,8 @@ public class Agent { public static HashMap initializeExecutors( HashMap modules) { HashMap executors = new HashMap(); - Iterator it = modules.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry moduleEntry = - (Map.Entry) it.next(); + for (Map.Entry moduleEntry : modules.entrySet()) { Module module = moduleEntry.getValue(); Executor executor = new Executor(module); executors.put(moduleEntry.getKey(), executor); @@ -42,11 +38,8 @@ public class Agent { public static ArrayList initializeExecutorThreads(HashMap executors) { ArrayList executorThreads = new ArrayList(); - Iterator it = executors.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry executorEntry = - (Map.Entry) it.next(); + for (Map.Entry executorEntry : executors.entrySet()) { Thread thread = new Thread(executorEntry.getValue()); thread.setDaemon(true); System.out.println("Initializing executor " + executorEntry.getKey()); diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/EventBus.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/EventBus.java index 4f939b6..5b09253 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/EventBus.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/EventBus.java @@ -4,7 +4,6 @@ import pl.edu.mimuw.cloudatlas.agent.messages.AgentMessage; import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.concurrent.LinkedBlockingQueue; @@ -16,10 +15,7 @@ public class EventBus implements Runnable { private HashMap executors; void setEventBusReference() { - Iterator it = this.executors.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry executorEntry = - (Map.Entry) it.next(); + for (Map.Entry executorEntry : this.executors.entrySet()) { executorEntry.getValue().setEventBus(this); } } 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 ea893d9..b030901 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,6 +1,5 @@ package pl.edu.mimuw.cloudatlas.agent.modules; -import java.util.Iterator; import java.util.HashMap; import java.util.Map.Entry; -- cgit v1.2.3