annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
1 package alice.topology.manager.keeparive;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
2
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
3 import alice.codesegment.CodeSegment;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
4 import alice.datasegment.CommandType;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
5 import alice.datasegment.Receiver;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
6
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
7 public class RemoveTask extends CodeSegment {
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
8 private Receiver info1 = ids.create(CommandType.TAKE); // list
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
9 private Receiver info2 = ids.create(CommandType.TAKE); // remove task
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
10
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
11 public RemoveTask(){
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
12 info1.setKey("_WAITINGLIST");
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
13 info2.setKey("_REMOVETASK");
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
14 }
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
15
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
16 @Override
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
17 public void run() {
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
18 ListManager list = info1.asClass(ListManager.class); // explicit cast
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
19 TaskInfo task = info2.asClass(TaskInfo.class);
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
20 TaskExecuter exec = TaskExecuter.getInstance();
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
21 if (exec.compareNowTask(task)){
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
22 // case: remove task is state countdown.
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
23 exec.skip();
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
24 } else {
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
25 // case: remove task is still in the waiting queue.
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
26 boolean removeFlag = list.deleteTask(task);
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
27 if (!removeFlag){
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
28 ods.put("_REMOVETASK", task);
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
29 }
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
30 }
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
31 ods.update("_WAITINGLIST", list);
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
32 }
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
33 }