# HG changeset patch # User sugi # Date 1384842345 -32400 # Node ID 72739519cc39a276ec70b5dd234c55d240cb6f7b # Parent 366742c2b07dbb88851a61a866c8c4f7060b1624 Add Scheduler Test diff -r 366742c2b07d -r 72739519cc39 src/alice/test/codesegment/api/PingSchedulerTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/codesegment/api/PingSchedulerTest.java Tue Nov 19 15:25:45 2013 +0900 @@ -0,0 +1,31 @@ +package alice.test.codesegment.api; + +import alice.topology.manager.keeparive.PingScheduler; +import alice.topology.manager.keeparive.TaskInfo; + +public class PingSchedulerTest { + public static void main(String[] args){ + PingScheduler sched = new PingScheduler(); + int[] num = { 1 * 1000, + 2 * 1000, + 6 * 1000, + 4 * 1000, + 3 * 1000 + }; + + for (int i = 0; i < num.length; i++){ + String name = "task"+i; + sched.plist.addTask( + new TaskInfo(name, num[i]) + ); + } + + for (TaskInfo info : sched.plist.getTaskList()){ + System.out.println(info.getSleepTime()); + } + + sched.execute(); + //System.exit(0); + } + +} diff -r 366742c2b07d -r 72739519cc39 src/alice/topology/manager/keeparive/PingScheduler.java --- a/src/alice/topology/manager/keeparive/PingScheduler.java Tue Nov 19 14:35:33 2013 +0900 +++ b/src/alice/topology/manager/keeparive/PingScheduler.java Tue Nov 19 15:25:45 2013 +0900 @@ -4,13 +4,13 @@ import alice.codesegment.CodeSegment; public class PingScheduler extends CodeSegment{ - private PingSchedList plist = new PingSchedList(); - private long INTERVAL = 60 * 1000; + public PingSchedList plist = new PingSchedList(); + private TaskInfo nowTask; private boolean interruptFlag = false; + private long INTERVAL = 60 * 1000; private long time = 0; - public TaskInfo nowTask; private long postponeTime = 0; public synchronized void postpone(String name){ @@ -51,14 +51,15 @@ try { while(true){ nowTask = list.poll(); + System.out.print("TaskName "+nowTask.getManagerKey()); + System.out.println(" sleepTime "+nowTask.getSleepTime()); time = System.currentTimeMillis(); if (nowTask.getSleepTime()!=0) this.wait(nowTask.getSleepTime()); if (interruptFlag){ interruptFlag = false; } else { - ods.put("_SENDPING", nowTask); - nowTask.getSleepTime(); + //ods.put("_SENDPING", nowTask); } } } catch (InterruptedException e) {