diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java | 36 | ||||
-rw-r--r-- | src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java | 3 |
2 files changed, 34 insertions, 5 deletions
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 52bd395..429346c 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,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import pl.edu.mimuw.cloudatlas.agent.ApiImplementation; +import pl.edu.mimuw.cloudatlas.agent.NewApiImplementation; +import pl.edu.mimuw.cloudatlas.agent.messages.UpdateAttributesMessage; import pl.edu.mimuw.cloudatlas.agent.modules.Module; import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType; import pl.edu.mimuw.cloudatlas.agent.modules.Qurnik; @@ -16,6 +17,7 @@ import pl.edu.mimuw.cloudatlas.agent.modules.Stanik; import pl.edu.mimuw.cloudatlas.agent.modules.TimerScheduler; import pl.edu.mimuw.cloudatlas.api.Api; import pl.edu.mimuw.cloudatlas.interpreter.Main; +import pl.edu.mimuw.cloudatlas.model.PathName; import pl.edu.mimuw.cloudatlas.model.ZMI; public class Agent { @@ -23,8 +25,7 @@ public class Agent { public static void runRegistry() { try { - ZMI root = Main.createTestHierarchy2(); - ApiImplementation api = new ApiImplementation(root); + NewApiImplementation api = new NewApiImplementation(eventBus); Api apiStub = (Api) UnicastRemoteObject.exportObject(api, 0); Registry registry = LocateRegistry.getRegistry(); @@ -89,12 +90,37 @@ public class Agent { System.out.println("Initializing event bus"); eventBusThread.start(); - System.out.println("Closing executors"); - closeExecutors(executorThreads); + // System.out.println("Closing executors"); + // closeExecutors(executorThreads); + } + + private static void initZones() { + try { + ZMI root = Main.createTestHierarchy2(); + addZoneAndChildren(root, new PathName("")); + System.out.println("Initialized with test hierarchy"); + } catch (Exception e) { + System.out.println("ERROR: failed to create test hierarchy"); + } + } + + private static void addZoneAndChildren(ZMI zmi, PathName pathName) { + try { + System.out.println("trying to add " + pathName.toString()); + UpdateAttributesMessage message = new UpdateAttributesMessage("", 0, pathName.toString(), zmi.getAttributes()); + System.out.println("added it!"); + eventBus.addMessage(message); + for (ZMI son : zmi.getSons()) { + addZoneAndChildren(son, pathName.levelDown(son.getAttributes().getOrNull("name").toString())); + } + } catch (Exception e) { + System.out.println("ERROR: failed to add zone"); + } } public static void main(String[] args) { runModulesAsThreads(); runRegistry(); + initZones(); } } diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java index f91f25e..288087d 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java @@ -277,16 +277,19 @@ public class Main { ZMI root = new ZMI(); root.getAttributes().add("level", new ValueInt(0l)); root.getAttributes().add("name", new ValueString(null)); + root.getAttributes().add("timestamp", new ValueTime(0l)); ZMI uw = new ZMI(root); root.addSon(uw); uw.getAttributes().add("level", new ValueInt(1l)); uw.getAttributes().add("name", new ValueString("uw")); + uw.getAttributes().add("timestamp", new ValueTime(0l)); ZMI pjwstk = new ZMI(root); root.addSon(pjwstk); pjwstk.getAttributes().add("level", new ValueInt(1l)); pjwstk.getAttributes().add("name", new ValueString("pjwstk")); + pjwstk.getAttributes().add("timestamp", new ValueTime(0l)); ZMI violet07 = new ZMI(uw); uw.addSon(violet07); |