Mercurial > hg > Database > Alice
diff src/alice/topology/manager/keeparive/TaskExecuter.java @ 330:d35ff0f588e8
keep alive may work... but bug exist.
author | sugi |
---|---|
date | Mon, 31 Mar 2014 22:28:52 +0900 |
parents | 35b4e24e3e02 |
children | 8266d7cfba7e |
line wrap: on
line diff
--- a/src/alice/topology/manager/keeparive/TaskExecuter.java Mon Mar 24 23:52:20 2014 +0900 +++ b/src/alice/topology/manager/keeparive/TaskExecuter.java Mon Mar 31 22:28:52 2014 +0900 @@ -25,7 +25,7 @@ @Override public synchronized void run() { - ListManager list = info.asClass(ListManager.class); + ListManager list = info.asClass(ListManager.class); if (list.getTaskList().size() == 0){ if (remainingTime !=0){ TaskInfo info = new TaskInfo(TaskType.SKIP); @@ -53,28 +53,37 @@ e.printStackTrace(); } } - setNowTask(null); - startTime = 0; + if (!skipFlag){ - // ping or close - /* - if (nowTask.getType() == TaskType.PING) { - ods.ping(nowTask.getManagerKey(), nowTask.getReturnKey()); - TaskInfo task = new TaskInfo(TaskType.CLOSE); - task.setInfo(nowTask.getManagerKey(), 60 * 1000); - ods.put("_TASKINFO", task); - new RespondPing(nowTask.getReturnKey()); - } else { - // no response from the Remote DataSegment. So close this connection. - DataSegment.get(nowTask.getManagerKey()).close(); - } - */ + execTask(); } + setNowTask(null); + startTime = 0; } setKey(); } + private synchronized void execTask(){ + // ping or close + System.out.println("aaaa"); + if (nowTask.getType() == TaskType.PING) { + System.out.println("bbb"); + ods.ping(nowTask.getManagerKey(), nowTask.getReturnKey()); + TaskInfo task = new TaskInfo(TaskType.CLOSE); + task.setInfo(nowTask.getManagerKey(), 10 * 1000); + ods.put("_TASKINFO", task); + new RespondPing(nowTask.getReturnKey()); + } else if (nowTask.getType() == TaskType.CLOSE) { + // no response from the Remote DataSegment. So close this connection. + //DataSegment.get(nowTask.getManagerKey()).close(); + System.out.println("CLOSE"); + + nowTask.show(); + System.exit(0); + } + } + public synchronized void skip() { skipFlag = true; if (startTime == 0){ @@ -82,8 +91,10 @@ } else { remainingTime = nowTask.getSleepTime() - (System.currentTimeMillis() - startTime); } + System.out.println(remainingTime); nowTask = null; notify(); + System.out.println(nowTask); } public synchronized void ignore() { @@ -93,7 +104,7 @@ notify(); } - public TaskInfo getNowTask() { + public synchronized TaskInfo getNowTask() { return nowTask; } @@ -113,12 +124,6 @@ } } - public long initRemainingTime() { - long time = remainingTime; - remainingTime = 0; - return time; - } - public boolean compareNowTask(TaskInfo task) { if (nowTask != null){ if (nowTask.getType().equals(task.getType())