Mercurial > hg > Database > Alice
view src/main/java/alice/topology/manager/keeparive/RespondPing.java @ 491:7d67bc538549 dispose
bug fix
author | sugi |
---|---|
date | Wed, 10 Dec 2014 20:31:09 +0900 |
parents | 7ef0ebb40c9b |
children | e5d2141af6c2 |
line wrap: on
line source
package alice.topology.manager.keeparive; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class RespondPing extends CodeSegment{ private Receiver respond = ids.create(CommandType.TAKE); private long pingedTime = System.currentTimeMillis(); public RespondPing(String key) { respond.setKey(key); } @Override public void run() { RespondData d = respond.asClass(RespondData.class); System.out.print("ping from "+d.from); System.out.println(" Recieved time "+(d.time - pingedTime)); // if (d.time - pingedTime > 60 * 1000){ // // need check, this connection is alive. may be close // if (DataSegment.contains(d.from)) // DataSegment.get(d.from).shutdown(); // } else { // if nowTask close d.from's socket cancel. // if not remove close task in the Queue. TaskExecuter exec = TaskExecuter.getInstance(); TaskInfo task = new TaskInfo(TaskType.CLOSE); task.setInfo(d.from, null, 0); if (exec.compareNowTask(task)){ // case: remove task is state countdown. exec.skip(); // countdown } else { // case: remove task is still in the waiting queue. ods.put("_REMOVETASK",task); new RemoveTask(); } // } } }