From afa32431d242d60471e5431d654784ee64b63bbf Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Fri, 27 Dec 2019 11:28:46 +0100 Subject: Begin Stanik impelementation * Get cloned hierarchy * Test on empty hierarchy --- .../agent/messages/GetHierarchyMessage.java | 22 +++++++++++++++ .../agent/messages/HierarchyMessage.java | 17 ++++++++++++ .../cloudatlas/agent/messages/ResponseMessage.java | 31 ++++++++++++++++++++++ .../cloudatlas/agent/messages/StanikMessage.java | 25 +++++++++++++++++ 4 files changed, 95 insertions(+) create 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/HierarchyMessage.java create mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/ResponseMessage.java create mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StanikMessage.java (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/agent/messages') 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 new file mode 100644 index 0000000..d3c749d --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/GetHierarchyMessage.java @@ -0,0 +1,22 @@ +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/HierarchyMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/HierarchyMessage.java new file mode 100644 index 0000000..9f7ca70 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/HierarchyMessage.java @@ -0,0 +1,17 @@ +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 new file mode 100644 index 0000000..171cf07 --- /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 { + HIERARCHY + } + + 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..d2b3064 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/StanikMessage.java @@ -0,0 +1,25 @@ +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_HIERARCHY + } + + 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); + } +} -- cgit v1.2.3