From 054c14ae3d1c2f02d6012c6133fa78c5a1a15c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Mon, 23 Dec 2019 23:22:57 +0100 Subject: Make scheduled task abstract --- src/main/java/pl/edu/mimuw/cloudatlas/agent/EventBus.java | 2 ++ .../java/pl/edu/mimuw/cloudatlas/agent/messages/AgentMessage.java | 1 + .../pl/edu/mimuw/cloudatlas/agent/modules/TimerScheduledTask.java | 8 ++------ 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/EventBus.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/EventBus.java index 8cdda62..b84d693 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/EventBus.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/EventBus.java @@ -43,11 +43,13 @@ public class EventBus implements Runnable { } public void routeMessage(AgentMessage msg) throws InterruptedException { + assert msg.correctType == msg.getDestinationModule(); System.out.println("Event bus routing message"); executors.get(msg.getDestinationModule()).addMessage(msg); } public void addMessage(AgentMessage msg) throws InterruptedException { + assert msg.correctType == msg.getDestinationModule(); this.events.put(msg); } } 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 index 31fc6f8..ba15a7a 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/AgentMessage.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/AgentMessage.java @@ -1,6 +1,7 @@ package pl.edu.mimuw.cloudatlas.agent.messages; public class AgentMessage { + public AgentModule correctType; public enum AgentModule { TIMER_SCHEDULER, diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/TimerScheduledTask.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/TimerScheduledTask.java index db9dd26..4b933b5 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/TimerScheduledTask.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/TimerScheduledTask.java @@ -2,10 +2,6 @@ package pl.edu.mimuw.cloudatlas.agent.modules; import java.util.TimerTask; -public class TimerScheduledTask extends TimerTask { - - @Override - public void run() { - - } +public abstract class TimerScheduledTask extends TimerTask { + public abstract void run(); } -- cgit v1.2.3