From af6f6f37403d0e23a09a6ba4476271c2a0eaf623 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 29 Dec 2019 14:12:31 +0100 Subject: Include timestamped queries in state --- .../agent/messages/GetHierarchyMessage.java | 22 ---------------- .../cloudatlas/agent/messages/GetStateMessage.java | 22 ++++++++++++++++ .../agent/messages/HierarchyMessage.java | 17 ------------- .../cloudatlas/agent/messages/ResponseMessage.java | 2 +- .../cloudatlas/agent/messages/StanikMessage.java | 2 +- .../cloudatlas/agent/messages/StateMessage.java | 29 ++++++++++++++++++++++ .../edu/mimuw/cloudatlas/agent/modules/Stanik.java | 22 ++++++++++------ 7 files changed, 68 insertions(+), 48 deletions(-) delete mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/GetHierarchyMessage.java create mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/GetStateMessage.java delete mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/HierarchyMessage.java create mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StateMessage.java (limited to 'src/main/java/pl/edu/mimuw/cloudatlas') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/GetHierarchyMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/GetHierarchyMessage.java deleted file mode 100644 index d3c749d..0000000 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/GetHierarchyMessage.java +++ /dev/null @@ -1,22 +0,0 @@ -package pl.edu.mimuw.cloudatlas.agent.messages; - -import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType; - -public class GetHierarchyMessage extends StanikMessage { - private ModuleType requestingModule; - private long requestId; - - public GetHierarchyMessage(String messageId, long timestamp, ModuleType requestingModule, long requestId) { - super(messageId, timestamp, Type.GET_HIERARCHY); - this.requestingModule = requestingModule; - this.requestId = requestId; - } - - public ModuleType getRequestingModule() { - return requestingModule; - } - - public long getRequestId() { - return requestId; - } -} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/GetStateMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/GetStateMessage.java new file mode 100644 index 0000000..63392e8 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/GetStateMessage.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.agent.messages; + +import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType; + +public class GetStateMessage extends StanikMessage { + private ModuleType requestingModule; + private long requestId; + + public GetStateMessage(String messageId, long timestamp, ModuleType requestingModule, long requestId) { + super(messageId, timestamp, Type.GET_STATE); + this.requestingModule = requestingModule; + this.requestId = requestId; + } + + public ModuleType getRequestingModule() { + return requestingModule; + } + + public long getRequestId() { + return requestId; + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/HierarchyMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/HierarchyMessage.java deleted file mode 100644 index 9f7ca70..0000000 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/HierarchyMessage.java +++ /dev/null @@ -1,17 +0,0 @@ -package pl.edu.mimuw.cloudatlas.agent.messages; - -import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType; -import pl.edu.mimuw.cloudatlas.model.ZMI; - -public class HierarchyMessage extends ResponseMessage { - private ZMI zmi; - - public HierarchyMessage(String messageId, ModuleType destinationModule, long timestamp, long requestId, ZMI zmi) { - super(messageId, destinationModule, timestamp, Type.HIERARCHY, requestId); - this.zmi = zmi; - } - - public ZMI getZMI() { - return zmi; - } -} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/ResponseMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/ResponseMessage.java index 171cf07..02b3337 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/ResponseMessage.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/ResponseMessage.java @@ -5,7 +5,7 @@ import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType; public abstract class ResponseMessage extends AgentMessage { public enum Type { - HIERARCHY + STATE } Type type; diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StanikMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StanikMessage.java index 8661c90..da35f2d 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StanikMessage.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StanikMessage.java @@ -5,7 +5,7 @@ import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType; public abstract class StanikMessage extends AgentMessage { public enum Type { - GET_HIERARCHY, + GET_STATE, UPDATE_ATTRIBUTES } diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StateMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StateMessage.java new file mode 100644 index 0000000..f7f490b --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StateMessage.java @@ -0,0 +1,29 @@ +package pl.edu.mimuw.cloudatlas.agent.messages; + +import java.util.Map; +import java.util.Map.Entry; + +import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType; +import pl.edu.mimuw.cloudatlas.model.Attribute; +import pl.edu.mimuw.cloudatlas.model.ValueQuery; +import pl.edu.mimuw.cloudatlas.model.ValueTime; +import pl.edu.mimuw.cloudatlas.model.ZMI; + +public class StateMessage extends ResponseMessage { + private ZMI zmi; + private Map> queries; + + public StateMessage(String messageId, ModuleType destinationModule, long timestamp, long requestId, ZMI zmi, Map> queries) { + super(messageId, destinationModule, timestamp, Type.STATE, requestId); + this.zmi = zmi; + this.queries = queries; + } + + public ZMI getZMI() { + return zmi; + } + + public Map> getQueries() { + return queries; + } +} 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 76ca0b6..a31f265 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,20 +1,22 @@ package pl.edu.mimuw.cloudatlas.agent.modules; import java.util.Iterator; +import java.util.HashMap; import java.util.Map.Entry; import pl.edu.mimuw.cloudatlas.agent.messages.AgentMessage; -import pl.edu.mimuw.cloudatlas.agent.messages.GetHierarchyMessage; -import pl.edu.mimuw.cloudatlas.agent.messages.HierarchyMessage; +import pl.edu.mimuw.cloudatlas.agent.messages.GetStateMessage; +import pl.edu.mimuw.cloudatlas.agent.messages.StateMessage; import pl.edu.mimuw.cloudatlas.agent.messages.StanikMessage; import pl.edu.mimuw.cloudatlas.agent.messages.UpdateAttributesMessage; -import pl.edu.mimuw.cloudatlas.model.AttributesMap; import pl.edu.mimuw.cloudatlas.model.Attribute; +import pl.edu.mimuw.cloudatlas.model.AttributesMap; import pl.edu.mimuw.cloudatlas.model.PathName; import pl.edu.mimuw.cloudatlas.model.Type; import pl.edu.mimuw.cloudatlas.model.TypePrimitive; import pl.edu.mimuw.cloudatlas.model.Value; import pl.edu.mimuw.cloudatlas.model.ValueBoolean; +import pl.edu.mimuw.cloudatlas.model.ValueQuery; import pl.edu.mimuw.cloudatlas.model.ValueString; import pl.edu.mimuw.cloudatlas.model.ValueTime; import pl.edu.mimuw.cloudatlas.model.ZMI; @@ -27,17 +29,19 @@ public class Stanik extends Module { } private ZMI hierarchy; + private HashMap> queries; public Stanik() { super(ModuleType.STATE); hierarchy = new ZMI(); + queries = new HashMap>(); hierarchy.getAttributes().add("timestamp", new ValueTime(0l)); } public void handleTyped(StanikMessage message) throws InterruptedException, InvalidMessageType { switch(message.getType()) { - case GET_HIERARCHY: - handleGetHierarchy((GetHierarchyMessage) message); + case GET_STATE: + handleGetState((GetStateMessage) message); break; case UPDATE_ATTRIBUTES: handleUpdateAttributes((UpdateAttributesMessage) message); @@ -47,8 +51,8 @@ public class Stanik extends Module { } } - public void handleGetHierarchy(GetHierarchyMessage message) throws InterruptedException { - HierarchyMessage response = new HierarchyMessage("", message.getRequestingModule(), 0, message.getRequestId(), hierarchy.clone()); + public void handleGetState(GetStateMessage message) throws InterruptedException { + StateMessage response = new StateMessage("", message.getRequestingModule(), 0, message.getRequestId(), hierarchy.clone(), (HashMap>) queries.clone()); sendMessage(response); } @@ -141,4 +145,8 @@ public class Stanik extends Module { public ZMI getHierarchy() { return hierarchy; } + + public HashMap> getQueries() { + return queries; + } } -- cgit v1.2.3