changeset 305:72739519cc39

Add Scheduler Test
author sugi
date Tue, 19 Nov 2013 15:25:45 +0900
parents 366742c2b07d
children 098e97954c08
files src/alice/test/codesegment/api/PingSchedulerTest.java src/alice/topology/manager/keeparive/PingScheduler.java
diffstat 2 files changed, 37 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- /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);
+	}
+
+}
--- 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) {