Mercurial > hg > Database > Alice
view src/alice/topology/manager/keeparive/CreateSchedule.java @ 312:6e0a3c680b82
Rename
author | sugi |
---|---|
date | Tue, 26 Nov 2013 18:20:18 +0900 |
parents | 4b38039e4454 |
children | f1f0638861ab |
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); SendPing ps = SendPing.getInstance(); TaskInfo nowTask = ps.getNowTask(); LinkedList<TaskInfo> list = manager.getTaskList(); if (nowTask.getManagerKey().equals(newTask.getManagerKey())){ long postponeTime = nowTask.getSleepTime() - (System.currentTimeMillis() - ps.getTime()); TaskInfo 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("_SCHEDLIST", manager); new CheckExistTask(); } }