Mercurial > hg > Database > Alice
changeset 319:89dc953fd9e8
Chanage Class namae
author | one |
---|---|
date | Tue, 17 Dec 2013 17:21:12 +0900 |
parents | 32d033a4b3c7 |
children | aafc88985822 |
files | .settings/org.eclipse.core.resources.prefs src/alice/topology/manager/keeparive/CreateSchedule.java src/alice/topology/manager/keeparive/CreateTask.java src/alice/topology/manager/keeparive/SendPing.java src/alice/topology/manager/keeparive/TaskExecuter.java |
diffstat | 5 files changed, 65 insertions(+), 65 deletions(-) [+] |
line wrap: on
line diff
--- a/.settings/org.eclipse.core.resources.prefs Tue Dec 10 18:29:30 2013 +0900 +++ b/.settings/org.eclipse.core.resources.prefs Tue Dec 17 17:21:12 2013 +0900 @@ -4,4 +4,4 @@ encoding//src/alice/test/codesegment/local/wordcount/WordCount.java=UTF-8 encoding//src/alice/topology/manager/IncomingHosts.java=UTF-8 encoding//src/alice/topology/manager/createABSIPList.java=UTF-8 -encoding//src/alice/topology/manager/keeparive/SendPing.java=UTF-8 +encoding//src/alice/topology/manager/keeparive/TaskExecuter.java=UTF-8
--- a/src/alice/topology/manager/keeparive/CreateSchedule.java Tue Dec 10 18:29:30 2013 +0900 +++ b/src/alice/topology/manager/keeparive/CreateSchedule.java Tue Dec 17 17:21:12 2013 +0900 @@ -19,7 +19,7 @@ public void run() { ListManager manager = info1.asClass(ListManager.class); TaskInfo newTask = info2.asClass(TaskInfo.class); - SendPing ps = SendPing.getInstance(); + TaskExecuter ps = TaskExecuter.getInstance(); LinkedList<TaskInfo> list = manager.getTaskList(); if (ps.getNowTask()!=null&&ps.getNowTask().getManagerKey().equals(newTask.getManagerKey())){ long postponeTime = ps.getNowTask().getSleepTime() - (System.currentTimeMillis() - ps.getTime());
--- a/src/alice/topology/manager/keeparive/CreateTask.java Tue Dec 10 18:29:30 2013 +0900 +++ b/src/alice/topology/manager/keeparive/CreateTask.java Tue Dec 17 17:21:12 2013 +0900 @@ -20,7 +20,7 @@ List<String> list = info.asClass(List.class); new CheckExistTask(); - SendPing.getInstance().setKey(); + TaskExecuter.getInstance().setKey(); for (String manager : list){ int i = 5; TaskInfo task = new TaskInfo(manager, "_RESPONCE", i * 1000);
--- a/src/alice/topology/manager/keeparive/SendPing.java Tue Dec 10 18:29:30 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -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; - private static SendPing instance = new SendPing(); - - 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); - setKey(); - return; - } else { - try { - nowTask = list.getTaskList().poll(); - 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()); - new RespondPing(nowTask.getReturnKey()); - } - } catch (InterruptedException e) { - } - } - setKey(); - } - public synchronized void interrupt(){ - interruptFlag = true; - notify(); - } - - public TaskInfo getNowTask() { - return nowTask; - } - - public long getTime(){ - return time; - } -} -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/topology/manager/keeparive/TaskExecuter.java Tue Dec 17 17:21:12 2013 +0900 @@ -0,0 +1,62 @@ +package alice.topology.manager.keeparive; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class TaskExecuter extends CodeSegment{ + private Receiver info = ids.create(CommandType.TAKE); + private TaskInfo nowTask; + private boolean interruptFlag = false; + private long time = 0; + private static TaskExecuter instance = new TaskExecuter(); + + private TaskExecuter(){} + public static TaskExecuter 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); + setKey(); + return; + } else { + try { + nowTask = list.getTaskList().poll(); + 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()); + new RespondPing(nowTask.getReturnKey()); + } + } catch (InterruptedException e) { + } + } + setKey(); + } + public synchronized void interrupt(){ + interruptFlag = true; + notify(); + } + + public TaskInfo getNowTask() { + return nowTask; + } + + public long getTime(){ + return time; + } +} +