m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/agent/messages')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/AgentMessage.java57
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/TimerSchedulerMessage.java57
2 files changed, 114 insertions, 0 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/AgentMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/AgentMessage.java
new file mode 100644
index 0000000..b71831f
--- /dev/null
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/AgentMessage.java
@@ -0,0 +1,57 @@
+package pl.edu.mimuw.cloudatlas.agent.messages;
+
+public abstract class AgentMessage {
+
+ public enum AgentModule {
+ TIMER_SCHEDULER,
+ TIMER_GTP,
+ RMI,
+ UDP,
+ GOSSIP_IN,
+ GOSSIP_OUT,
+ STATE,
+ QUERY
+ }
+
+ private String messageId;
+ private AgentModule destinationModule;
+ private long timestamp;
+
+ public AgentMessage(String messageId, AgentModule destinationModule, long timestamp) {
+ this.messageId = messageId;
+ this.destinationModule = destinationModule;
+ this.timestamp = timestamp;
+ }
+
+ public AgentMessage(String messageId, AgentModule destinationModule) {
+ this.messageId = messageId;
+ this.destinationModule = destinationModule;
+ this.timestamp = System.currentTimeMillis() / 1000L;
+ }
+
+ public abstract AgentModule getCorrectMessageType();
+
+ public String getMessageId() {
+ return messageId;
+ }
+
+ public void setMessageId(String messageId) {
+ this.messageId = messageId;
+ }
+
+ public AgentModule getDestinationModule() {
+ return destinationModule;
+ }
+
+ public void setDestinationModule(AgentModule destinationModule) {
+ this.destinationModule = destinationModule;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+}
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/TimerSchedulerMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/TimerSchedulerMessage.java
new file mode 100644
index 0000000..333b381
--- /dev/null
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/TimerSchedulerMessage.java
@@ -0,0 +1,57 @@
+package pl.edu.mimuw.cloudatlas.agent.messages;
+
+import pl.edu.mimuw.cloudatlas.agent.modules.TimerScheduledTask;
+
+public class TimerSchedulerMessage extends AgentMessage {
+ private String requestId;
+ private long delay;
+ private long baseTime;
+ private TimerScheduledTask task;
+
+ public TimerSchedulerMessage(String messageId,
+ AgentModule destinationModule,
+ long timestamp,
+ String requestId,
+ long delay,
+ long baseTime,
+ TimerScheduledTask task) {
+ super(messageId, destinationModule, timestamp);
+ this.requestId = requestId;
+ this.delay = delay;
+ this.baseTime = baseTime;
+ this.task = task;
+ }
+
+ public long getDelay() {
+ return delay;
+ }
+
+ public void setDelay(long delay) {
+ this.delay = delay;
+ }
+
+ public long getBaseTime() {
+ return baseTime;
+ }
+
+ public void setBaseTime(long baseTime) {
+ this.baseTime = baseTime;
+ }
+
+ public TimerScheduledTask getTask() {
+ return task;
+ }
+
+ public void setTask(TimerScheduledTask task) {
+ this.task = task;
+ }
+
+ public String getRequestId() { return requestId; }
+
+ public void setRequestId(String requestId) { this.requestId = requestId; }
+
+ @Override
+ public AgentModule getCorrectMessageType() {
+ return AgentModule.TIMER_SCHEDULER;
+ }
+}