m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages
diff options
context:
space:
mode:
authorMartin <marcin.j.chrzanowski@gmail.com>2019-12-29 16:50:05 +0100
committerGitHub <noreply@github.com>2019-12-29 16:50:05 +0100
commit7f03e1ddbd73831499d63eee1075b0b1226fa173 (patch)
tree55bd25630a090c91e1a4362b68e32da22389dd1d /src/main/java/pl/edu/mimuw/cloudatlas/agent/messages
parent8b076ed54b692381a3c1410b704bdad33ad5ca0b (diff)
parentc3121bfa6c00682173a7f1fba9d4c524b8ef517e (diff)
Merge pull request #77 from m-chrzan/stanik
Stanik
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/agent/messages')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/GetStateMessage.java22
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/ResponseMessage.java31
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StanikMessage.java27
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StateMessage.java29
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/UpdateAttributesMessage.java23
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/UpdateQueriesMessage.java21
6 files changed, 153 insertions, 0 deletions
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/ResponseMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/ResponseMessage.java
new file mode 100644
index 0000000..02b3337
--- /dev/null
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/ResponseMessage.java
@@ -0,0 +1,31 @@
+package pl.edu.mimuw.cloudatlas.agent.messages;
+
+import pl.edu.mimuw.cloudatlas.agent.modules.Module;
+import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType;
+
+public abstract class ResponseMessage extends AgentMessage {
+ public enum Type {
+ STATE
+ }
+
+ Type type;
+ long requestId;
+
+ public ResponseMessage(String messageId, ModuleType destinationModule, long timestamp, Type type, long requestId) {
+ super(messageId, destinationModule, timestamp);
+ this.type = type;
+ this.requestId = requestId;
+ }
+
+ public void callMe(Module module) throws InterruptedException, Module.InvalidMessageType {
+ module.handleTyped(this);
+ }
+
+ public long getRequestId() {
+ return requestId;
+ }
+
+ public Type getType() {
+ return 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
new file mode 100644
index 0000000..b23f6e0
--- /dev/null
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StanikMessage.java
@@ -0,0 +1,27 @@
+package pl.edu.mimuw.cloudatlas.agent.messages;
+
+import pl.edu.mimuw.cloudatlas.agent.modules.Module;
+import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType;
+
+public abstract class StanikMessage extends AgentMessage {
+ public enum Type {
+ GET_STATE,
+ UPDATE_ATTRIBUTES,
+ UPDATE_QUERIES
+ }
+
+ private Type type;
+
+ public StanikMessage(String messageId, long timestamp, Type type) {
+ super(messageId, ModuleType.STATE, timestamp);
+ this.type = type;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void callMe(Module module) throws InterruptedException, Module.InvalidMessageType {
+ module.handleTyped(this);
+ }
+}
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<Attribute, Entry<ValueQuery, ValueTime>> queries;
+
+ public StateMessage(String messageId, ModuleType destinationModule, long timestamp, long requestId, ZMI zmi, Map<Attribute, Entry<ValueQuery, ValueTime>> queries) {
+ super(messageId, destinationModule, timestamp, Type.STATE, requestId);
+ this.zmi = zmi;
+ this.queries = queries;
+ }
+
+ public ZMI getZMI() {
+ return zmi;
+ }
+
+ public Map<Attribute, Entry<ValueQuery, ValueTime>> getQueries() {
+ return queries;
+ }
+}
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/UpdateAttributesMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/UpdateAttributesMessage.java
new file mode 100644
index 0000000..7e41631
--- /dev/null
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/UpdateAttributesMessage.java
@@ -0,0 +1,23 @@
+package pl.edu.mimuw.cloudatlas.agent.messages;
+
+import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType;
+import pl.edu.mimuw.cloudatlas.model.AttributesMap;
+
+public class UpdateAttributesMessage extends StanikMessage {
+ private String pathName;
+ private AttributesMap attributes;
+
+ public UpdateAttributesMessage(String messageId, long timestamp, String pathName, AttributesMap attributes) {
+ super(messageId, timestamp, Type.UPDATE_ATTRIBUTES);
+ this.pathName = pathName;
+ this.attributes = attributes;
+ }
+
+ public String getPathName() {
+ return pathName;
+ }
+
+ public AttributesMap getAttributes() {
+ return attributes;
+ }
+}
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/UpdateQueriesMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/UpdateQueriesMessage.java
new file mode 100644
index 0000000..58ad55a
--- /dev/null
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/UpdateQueriesMessage.java
@@ -0,0 +1,21 @@
+package pl.edu.mimuw.cloudatlas.agent.messages;
+
+import java.util.Map;
+import java.util.Map.Entry;
+
+import pl.edu.mimuw.cloudatlas.model.Attribute;
+import pl.edu.mimuw.cloudatlas.model.ValueQuery;
+import pl.edu.mimuw.cloudatlas.model.ValueTime;
+
+public class UpdateQueriesMessage extends StanikMessage {
+ private Map<Attribute, Entry<ValueQuery, ValueTime>> queries;
+
+ public UpdateQueriesMessage(String messageId, long timestamp, Map<Attribute, Entry<ValueQuery, ValueTime>> queries) {
+ super(messageId, timestamp, Type.UPDATE_QUERIES);
+ this.queries = queries;
+ }
+
+ public Map<Attribute, Entry<ValueQuery, ValueTime>> getQueries() {
+ return queries;
+ }
+}