Mercurial > hg > Members > tatsuki > Alice
changeset 328:370a2f63944f
add ListManager Test
author | sugi |
---|---|
date | Tue, 11 Feb 2014 16:10:23 +0900 |
parents | 235f6d0994df |
children | 35b4e24e3e02 |
files | src/alice/topology/manager/keeparive/ListManager.java src/alice/topology/manager/keeparive/ListManagerTest.java |
diffstat | 2 files changed, 43 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/topology/manager/keeparive/ListManager.java Tue Feb 11 15:47:14 2014 +0900 +++ b/src/alice/topology/manager/keeparive/ListManager.java Tue Feb 11 16:10:23 2014 +0900 @@ -12,13 +12,13 @@ public void addTask(TaskInfo newInfo) { TaskExecuter exec = TaskExecuter.getInstance(); TaskInfo nowTask = exec.getNowTask(); - long remainingTime = exec.initRemainingTime(); - System.out.println(remainingTime); if (nowTask == null) { // active task is nothing + long remainingTime = exec.initRemainingTime(); TaskInfo task = list.getFirst(); task.setSleepTime(task.getSleepTime() + remainingTime); add(newInfo); } else { + long remainingTime = exec.getRemainingTime(); if (remainingTime > newInfo.getSleepTime()) { // active task is longer than newTask. TaskInfo task = nowTask.clone(); @@ -32,7 +32,6 @@ add(newInfo); } } - showList(); } private void add(TaskInfo newInfo){ @@ -54,7 +53,7 @@ list.add(cnt, newInfo); } - private void showList(){ + public void showList(){ if (TaskExecuter.getInstance().getNowTask()!=null){ System.out.print("NOW | "); System.out.print(TaskExecuter.getInstance().getNowTask().getSleepTime()); @@ -66,35 +65,4 @@ } System.out.println(); } - - public static void main(String args[]){ - TaskExecuter.getInstance().getNowTask(); - ListManager manager = new ListManager(); - LinkedList<String> nameList = new LinkedList<String>(); - nameList.add("nodeA"); - nameList.add("nodeB"); - nameList.add("nodeC"); - nameList.add("nodeD"); - - TaskInfo taskA = new TaskInfo(TaskType.PING); - taskA.setInfo("node0", "_TEST", 3 * 1000); - TaskExecuter.getInstance().setNowTask(taskA); - - int i = 5; - for (String name : nameList){ - TaskInfo task = new TaskInfo(TaskType.PING); - task.setInfo(name, "_TEST", i * 1000); - manager.addTask(task); - i +=1; - } - TaskExecuter.getInstance().skip(); - i = 11; - for (String name : nameList){ - TaskInfo task = new TaskInfo(TaskType.PING); - task.setInfo(name, "_TEST", i * 1000); - manager.addTask(task); - i +=1; - } - - } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/topology/manager/keeparive/ListManagerTest.java Tue Feb 11 16:10:23 2014 +0900 @@ -0,0 +1,40 @@ +package alice.topology.manager.keeparive; + +import java.util.LinkedList; + +public class ListManagerTest { + public static void main(String args[]){ + TaskExecuter.getInstance().getNowTask(); + ListManager manager = new ListManager(); + LinkedList<String> nameList = new LinkedList<String>(); + nameList.add("nodeA"); + nameList.add("nodeB"); + nameList.add("nodeC"); + nameList.add("nodeD"); + + TaskInfo taskA = new TaskInfo(TaskType.PING); + taskA.setInfo("node0", "_TEST", 3 * 1000); + TaskExecuter.getInstance().setNowTask(taskA); + + int i = 5; + for (String name : nameList){ + TaskInfo task = new TaskInfo(TaskType.PING); + task.setInfo(name, "_TEST", i * 1000); + System.out.println(task.getSleepTime()); + manager.addTask(task); + manager.showList(); + i +=1; + } + TaskExecuter.getInstance().skip(); + i = 11; + for (String name : nameList){ + TaskInfo task = new TaskInfo(TaskType.PING); + task.setInfo(name, "_TEST", i * 1000); + System.out.println(task.getSleepTime()); + manager.addTask(task); + manager.showList(); + i +=1; + } + + } +} \ No newline at end of file