Mercurial > hg > Database > Alice
view src/alice/topology/manager/keeparive/SendPing.java @ 312:6e0a3c680b82
Rename
author | sugi |
---|---|
date | Tue, 26 Nov 2013 18:20:18 +0900 |
parents | src/alice/topology/manager/keeparive/PingScheduler.java@f1cd920ea913 |
children | f1f0638861ab |
line wrap: on
line source
package alice.topology.manager.keeparive; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class SendPing extends CodeSegment{ private Receiver info = ids.create(CommandType.TAKE); private TaskInfo nowTask; private boolean interruptFlag = false; private long time = 0; static class SingletonHolder { private static SendPing Instance = new SendPing(); } public static SendPing getInstance(){ return SingletonHolder.Instance; } public void setKey(){ info.setKey("_WAITINGLIST"); } @Override public synchronized void run() { ListManager list = info.asClass(ListManager.class); try { nowTask = list.getTaskList().pollFirst(); ods.update("_WAITINGLIST", list); time = System.currentTimeMillis(); if (nowTask.getSleepTime()!=0) this.wait(nowTask.getSleepTime()); if (interruptFlag){ interruptFlag = false; } else { ods.ping(nowTask.getManagerKey(), nowTask.getReturnKey()); } } catch (InterruptedException e) { } SendPing.getInstance().setKey(); } public synchronized void interrupt(){ interruptFlag = true; notify(); } public TaskInfo getNowTask() { return nowTask; } public long getTime(){ return time; } }