From 84df6c11a868e8cd98fa14455456d313e25234db Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 12 Jan 2020 21:52:38 +0100 Subject: Set zone levels --- .../java/pl/edu/mimuw/cloudatlas/agent/modules/Stanik.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/agent') 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 999c193..f572efe 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 @@ -61,6 +61,7 @@ public class Stanik extends Module { public void handleGetState(GetStateMessage message) throws InterruptedException { pruneHierarchy(); + addLevels(); StateMessage response = new StateMessage( "", message.getRequestingModule(), @@ -78,6 +79,17 @@ public class Stanik extends Module { pruneZMI(hierarchy, now); } + private void addLevels() { + addLevelsRecursive(hierarchy, 0); + } + + private void addLevelsRecursive(ZMI zmi, long level) { + zmi.getAttributes().addOrChange("level", new ValueInt(level)); + for (ZMI son : zmi.getSons()) { + addLevelsRecursive(son, level + 1); + } + } + private boolean pruneZMI(ZMI zmi, ValueTime time) { Value timestamp = zmi.getAttributes().get("timestamp"); -- cgit v1.2.3