annotate src/main/java/alice/topology/manager/keeparive/RemoveTask.java @ 498:e5d2141af6c2 dispose

keep alive Scheduler has bug
author sugi
date Mon, 15 Dec 2014 19:16:20 +0900
parents aefbe41fcf12
children c5072a63b257
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 {
419
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
8 private Receiver info1 = ids.create(CommandType.TAKE); // list
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
9 private Receiver info2 = ids.create(CommandType.TAKE); // remove task
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
10
419
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
11 public RemoveTask(){
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
12 info1.setKey("_WAITINGLIST");
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
13 info2.setKey("_REMOVETASK");
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
14 }
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
15
419
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
16 @Override
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
17 public void run() {
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
18 ListManager list = info1.asClass(ListManager.class); // explicit cast
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
19 TaskInfo task = info2.asClass(TaskInfo.class);
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
20 TaskExecuter exec = TaskExecuter.getInstance();
498
e5d2141af6c2 keep alive Scheduler has bug
sugi
parents: 419
diff changeset
21 if (!exec.compareAndSkip(task)){
419
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
22 // case: remove task is still in the waiting queue.
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
23 boolean removeFlag = list.deleteTask(task);
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
24 if (!removeFlag){
498
e5d2141af6c2 keep alive Scheduler has bug
sugi
parents: 419
diff changeset
25 System.out.println("falied RemoveTask "+task.getManagerKey());
419
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
26 ods.put("_REMOVETASK", task);
498
e5d2141af6c2 keep alive Scheduler has bug
sugi
parents: 419
diff changeset
27 } else {
e5d2141af6c2 keep alive Scheduler has bug
sugi
parents: 419
diff changeset
28 System.out.println("success RemoveTask "+task.getManagerKey());
e5d2141af6c2 keep alive Scheduler has bug
sugi
parents: 419
diff changeset
29 //list.show();
419
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
30 }
498
e5d2141af6c2 keep alive Scheduler has bug
sugi
parents: 419
diff changeset
31 } else {
e5d2141af6c2 keep alive Scheduler has bug
sugi
parents: 419
diff changeset
32 System.out.println("success RemoveTask "+task.getManagerKey());
e5d2141af6c2 keep alive Scheduler has bug
sugi
parents: 419
diff changeset
33 //list.show();
419
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
34 }
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
35 ods.update("_WAITINGLIST", list);
aefbe41fcf12 change tab to space
sugi
parents: 345
diff changeset
36 }
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
37 }