345
|
1 package alice.topology.manager.keeparive;
|
|
2
|
|
3 import alice.codesegment.CodeSegment;
|
|
4 import alice.datasegment.CommandType;
|
|
5 import alice.datasegment.Receiver;
|
|
6
|
|
7 public class RemoveTask extends CodeSegment {
|
419
|
8 private Receiver info1 = ids.create(CommandType.TAKE); // list
|
|
9 private Receiver info2 = ids.create(CommandType.TAKE); // remove task
|
345
|
10
|
419
|
11 public RemoveTask(){
|
|
12 info1.setKey("_WAITINGLIST");
|
|
13 info2.setKey("_REMOVETASK");
|
|
14 }
|
345
|
15
|
419
|
16 @Override
|
|
17 public void run() {
|
|
18 ListManager list = info1.asClass(ListManager.class); // explicit cast
|
|
19 TaskInfo task = info2.asClass(TaskInfo.class);
|
|
20 TaskExecuter exec = TaskExecuter.getInstance();
|
498
|
21 if (!exec.compareAndSkip(task)){
|
419
|
22 // case: remove task is still in the waiting queue.
|
|
23 boolean removeFlag = list.deleteTask(task);
|
|
24 if (!removeFlag){
|
498
|
25 System.out.println("falied RemoveTask "+task.getManagerKey());
|
419
|
26 ods.put("_REMOVETASK", task);
|
498
|
27 } else {
|
|
28 System.out.println("success RemoveTask "+task.getManagerKey());
|
|
29 //list.show();
|
419
|
30 }
|
498
|
31 } else {
|
|
32 System.out.println("success RemoveTask "+task.getManagerKey());
|
|
33 //list.show();
|
419
|
34 }
|
|
35 ods.update("_WAITINGLIST", list);
|
|
36 }
|
345
|
37 }
|