Mercurial > hg > Database > Alice
diff src/alice/topology/manager/keeparive/SendPing.java @ 314:f1f0638861ab
ping responce receivable
author | sugi |
---|---|
date | Fri, 06 Dec 2013 11:42:51 +0900 |
parents | 6e0a3c680b82 |
children | f9ec5bead150 |
line wrap: on
line diff
--- a/src/alice/topology/manager/keeparive/SendPing.java Tue Dec 03 21:34:42 2013 +0900 +++ b/src/alice/topology/manager/keeparive/SendPing.java Fri Dec 06 11:42:51 2013 +0900 @@ -9,23 +9,31 @@ private TaskInfo nowTask; private boolean interruptFlag = false; private long time = 0; + private static SendPing instance = new SendPing(); - static class SingletonHolder { - private static SendPing Instance = new SendPing(); - } - public static SendPing getInstance(){ - return SingletonHolder.Instance; - } + private SendPing(){} + public static SendPing getInstance() { + return instance; + } + public void setKey(){ + ids.init(); info.setKey("_WAITINGLIST"); } @Override public synchronized void run() { ListManager list = info.asClass(ListManager.class); + if (list.getTaskList().size() == 0){ + ods.update("_WAITINGLIST", list); + new GetTask(); + return; + } try { nowTask = list.getTaskList().pollFirst(); ods.update("_WAITINGLIST", list); + System.out.print("managerkey is "+ nowTask.getManagerKey()); + System.out.println(" returnkey is "+ nowTask.getReturnKey()); time = System.currentTimeMillis(); if (nowTask.getSleepTime()!=0) this.wait(nowTask.getSleepTime()); @@ -33,10 +41,11 @@ interruptFlag = false; } else { ods.ping(nowTask.getManagerKey(), nowTask.getReturnKey()); + new RespondPing(nowTask.getReturnKey()); } } catch (InterruptedException e) { } - SendPing.getInstance().setKey(); + new GetTask(); } public synchronized void interrupt(){ interruptFlag = true;