Mercurial > hg > Database > Alice
changeset 468:27079619f5fd dispose
change create task algotherm
author | sugi |
---|---|
date | Sat, 22 Nov 2014 18:07:24 +0900 |
parents | 6e304a7a60e7 |
children | b31b1d197c42 |
files | src/main/java/alice/topology/manager/StartTopologyManager.java src/main/java/alice/topology/manager/keeparive/CreateTask.java src/main/java/alice/topology/manager/keeparive/ListManager.java src/main/java/alice/topology/manager/keeparive/RespondPing.java src/main/java/alice/topology/manager/keeparive/StartKeepAlive.java src/main/java/alice/topology/manager/keeparive/TaskExecuter.java src/main/java/alice/topology/manager/keeparive/TaskType.java |
diffstat | 7 files changed, 32 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/topology/manager/StartTopologyManager.java Sat Nov 22 12:08:24 2014 +0900 +++ b/src/main/java/alice/topology/manager/StartTopologyManager.java Sat Nov 22 18:07:24 2014 +0900 @@ -103,6 +103,9 @@ ods.put("topology", new HashMap<String, LinkedList<HostMessage>>()); ods.put("createdList", new LinkedList<String>()); new CreateHash(); + + TopologyFinish cs2 = new TopologyFinish(); + cs2.finish.setKey("local", "finish"); } }
--- a/src/main/java/alice/topology/manager/keeparive/CreateTask.java Sat Nov 22 12:08:24 2014 +0900 +++ b/src/main/java/alice/topology/manager/keeparive/CreateTask.java Sat Nov 22 18:07:24 2014 +0900 @@ -1,7 +1,6 @@ package alice.topology.manager.keeparive; import java.util.List; - import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; @@ -15,20 +14,25 @@ @Override public void run(){ - ods.put("_WAITINGLIST", new ListManager()); @SuppressWarnings("unchecked") List<String> list = info.asClass(List.class); - new CheckExistTask(); - TaskExecuter.getInstance().setKey(); - for (String manager : list){ - int i = 5; - TaskInfo task = new TaskInfo(TaskType.PING); - task.setInfo(manager, "_FORM_"+manager, i * 1000); + if (list.size()==0) { + TaskInfo task = new TaskInfo(TaskType.CREATE); + task.setSleepTime(3000); ods.put("_TASKINFO", task); - i +=5; - } + } else { + for (String manager : list){ + int i = 5; + TaskInfo task = new TaskInfo(TaskType.PING); + task.setInfo(manager, "_FORM_"+manager, i * 1000); + ods.put("_TASKINFO", task); + i +=5; + } + TaskInfo task = new TaskInfo(TaskType.CREATE); + task.setSleepTime(10 * 1000); + ods.put("_TASKINFO", task); + } } - }
--- a/src/main/java/alice/topology/manager/keeparive/ListManager.java Sat Nov 22 12:08:24 2014 +0900 +++ b/src/main/java/alice/topology/manager/keeparive/ListManager.java Sat Nov 22 18:07:24 2014 +0900 @@ -71,9 +71,10 @@ } public void show(){ - if (TaskExecuter.getInstance().getNowTask()!=null){ + TaskInfo nowTask = TaskExecuter.getInstance().getNowTask(); + if (nowTask!=null){ System.out.print("NOW | "); - System.out.print(TaskExecuter.getInstance().getNowTask().getSleepTime()); + System.out.print(nowTask.getSleepTime()); System.out.print(" | "); } for (TaskInfo info : list){
--- a/src/main/java/alice/topology/manager/keeparive/RespondPing.java Sat Nov 22 12:08:24 2014 +0900 +++ b/src/main/java/alice/topology/manager/keeparive/RespondPing.java Sat Nov 22 18:07:24 2014 +0900 @@ -35,9 +35,6 @@ ods.put("_REMOVETASK",task); new RemoveTask(); } - TaskInfo task2 = new TaskInfo(TaskType.PING); - task2.setInfo(d.from, "_FORM_"+d.from, 5 * 1000); - ods.put("_TASKINFO", task2); } } }
--- a/src/main/java/alice/topology/manager/keeparive/StartKeepAlive.java Sat Nov 22 12:08:24 2014 +0900 +++ b/src/main/java/alice/topology/manager/keeparive/StartKeepAlive.java Sat Nov 22 18:07:24 2014 +0900 @@ -6,7 +6,13 @@ @Override public void run() { - new CreateTask(); + ods.put("_WAITINGLIST", new ListManager()); + TaskExecuter.getInstance().setKey(); + TaskInfo task = new TaskInfo(TaskType.CREATE); + task.setSleepTime(0); + ods.put("_TASKINFO", task); + new CheckExistTask(); + } }
--- a/src/main/java/alice/topology/manager/keeparive/TaskExecuter.java Sat Nov 22 12:08:24 2014 +0900 +++ b/src/main/java/alice/topology/manager/keeparive/TaskExecuter.java Sat Nov 22 18:07:24 2014 +0900 @@ -41,7 +41,6 @@ } startTime = System.currentTimeMillis(); - System.out.println(nowTask.getSleepTime()+" "+nowTask.getType()); if (nowTask.getSleepTime() != 0){ sleepFlag = true; try { @@ -62,8 +61,10 @@ new RespondPing(nowTask.getReturnKey()); } else if (nowTask.getType() == TaskType.CLOSE) { // no response from the Remote DataSegment. So close this connection. - System.out.println("SHOTDOWN"); DataSegment.get(nowTask.getManagerKey()).shutdown(); + System.out.println(nowTask.getManagerKey() +" IS SHOTDOWN"); + } else if (nowTask.getType() == TaskType.CREATE) { + new CreateTask(); } } nowTask = null;