diff src/main/java/alice/topology/manager/keeparive/RemoveTask.java @ 345:8f71c3e6f11d

Change directory structure Maven standard
author sugi
date Wed, 16 Apr 2014 18:26:07 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/RemoveTask.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,33 @@
+package alice.topology.manager.keeparive;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class RemoveTask extends CodeSegment {
+	private Receiver info1 = ids.create(CommandType.TAKE); // list
+	private Receiver info2 = ids.create(CommandType.TAKE); // remove task
+
+	public RemoveTask(){
+		info1.setKey("_WAITINGLIST");
+		info2.setKey("_REMOVETASK");
+	}
+
+	@Override
+	public void run() {
+		ListManager list = info1.asClass(ListManager.class); // explicit cast
+		TaskInfo task = info2.asClass(TaskInfo.class);
+		TaskExecuter exec = TaskExecuter.getInstance();
+		if (exec.compareNowTask(task)){
+			// case: remove task is state countdown.
+			exec.skip();
+		} else {
+			// case: remove task is still in the waiting queue.
+			boolean removeFlag = list.deleteTask(task);
+			if (!removeFlag){
+				ods.put("_REMOVETASK", task);
+			}
+		}
+		ods.update("_WAITINGLIST", list);
+	}
+}