Mercurial > hg > Database > Alice
view src/alice/topology/manager/keeparive/CreateSchedule.java @ 319:89dc953fd9e8
Chanage Class namae
author | one |
---|---|
date | Tue, 17 Dec 2013 17:21:12 +0900 |
parents | 9e84deb9b1e0 |
children | d746c4486287 |
line wrap: on
line source
package alice.topology.manager.keeparive; import java.util.LinkedList; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class CreateSchedule extends CodeSegment{ private Receiver info1 = ids.create(CommandType.TAKE); // WaitingList private Receiver info2 = ids.create(CommandType.TAKE); // TaskInfo public CreateSchedule(){ info1.setKey("_WAITINGLIST"); info2.setKey("_TASKINFO"); } @Override public void run() { ListManager manager = info1.asClass(ListManager.class); TaskInfo newTask = info2.asClass(TaskInfo.class); TaskExecuter ps = TaskExecuter.getInstance(); LinkedList<TaskInfo> list = manager.getTaskList(); if (ps.getNowTask()!=null&&ps.getNowTask().getManagerKey().equals(newTask.getManagerKey())){ long postponeTime = ps.getNowTask().getSleepTime() - (System.currentTimeMillis() - ps.getTime()); TaskInfo nextTask; if (list.size() != 0){ nextTask = list.getFirst(); nextTask.setSleepTime(postponeTime + nextTask.getSleepTime()); } manager.addTask(newTask); ps.interrupt(); } else { for (TaskInfo info : list){ if (newTask.getManagerKey().equals(info.getManagerKey())){ list.remove(info); } } manager.addTask(newTask); } ods.update("_WAITINGLIST", manager); new CheckExistTask(); } }