Mercurial > hg > Members > tatsuki > Alice
changeset 316:9e84deb9b1e0
Respond Worked
author | sugi |
---|---|
date | Tue, 10 Dec 2013 17:40:13 +0900 |
parents | f9ec5bead150 |
children | 1ddaa687f44a |
files | .classpath scripts/keeparive.sh src/alice/daemon/IncomingTcpConnection.java src/alice/topology/manager/keeparive/CreateSchedule.java src/alice/topology/manager/keeparive/GetTask.java src/alice/topology/manager/keeparive/RespondData.java src/alice/topology/manager/keeparive/RespondPing.java src/alice/topology/manager/keeparive/SendPing.java src/alice/topology/node/IncomingConnectionInfo.java |
diffstat | 9 files changed, 56 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/.classpath Tue Dec 10 12:32:43 2013 +0900 +++ b/.classpath Tue Dec 10 17:40:13 2013 +0900 @@ -5,7 +5,6 @@ <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.16.jar"/> <classpathentry exported="true" kind="lib" path="lib/slf4j-api-1.6.1.jar"/> <classpathentry exported="true" kind="lib" path="lib/slf4j-log4j12-1.6.1.jar"/> - <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry exported="true" kind="lib" path="lib/msgpack-0.6.8-SNAPSHOT-sources.jar"/> <classpathentry exported="true" kind="lib" path="lib/msgpack-0.6.8-SNAPSHOT.jar" sourcepath="lib/msgpack-0.6.8-SNAPSHOT-sources.jar"/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/keeparive.sh Tue Dec 10 17:40:13 2013 +0900 @@ -0,0 +1,26 @@ +#!/bin/bash +if [ $# -ne 2 ]; then + echo "Usage: ./aquarium.sh NODENUM CHILDLENNUM" + exit 1 +fi +max=$1 +child_num=$2 +java=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java +if [ ! -e $java ]; then + echo "$java not found." + exit 1 +fi + +ruby ./topology/treen.rb $1 $2 > ./topology/tree.dot +dot -Tpng ./topology/tree.dot > ./topology/tree.png +#open ./topology/tree.png +$java -version +$java -cp ../Alice.jar alice.topology.manager.TopologyManager -p 10000 -conf ./topology/tree.dot -log ./output/manager.log -level debug > ./output/std_manager.log & + +cnt=0 +while [ $cnt -lt $max ] +do + $java -cp ../Alice.jar alice.topology.manager.keeparive.KeepAlive -host `hostname` -port 10000 -p `expr 20000 + $cnt` -level debug > ./output/std_keepalive${cnt}.log & + cnt=`expr $cnt + 1` +done +wait
--- a/src/alice/daemon/IncomingTcpConnection.java Tue Dec 10 12:32:43 2013 +0900 +++ b/src/alice/daemon/IncomingTcpConnection.java Tue Dec 10 17:40:13 2013 +0900 @@ -14,6 +14,7 @@ import alice.datasegment.DataSegmentManager; import alice.datasegment.LocalDataSegmentManager; import alice.topology.HostMessage; +import alice.topology.manager.keeparive.RespondData; import alice.topology.manager.reconnection.SendError; public class IncomingTcpConnection extends Thread { @@ -66,7 +67,7 @@ DataSegment.get(reverseKey).response(msg.key); break; case RESPONSE: - DataSegment.getLocal().put(msg.key, System.currentTimeMillis()); + DataSegment.getLocal().put(msg.key, new RespondData(reverseKey, System.currentTimeMillis())); break; default: break;
--- a/src/alice/topology/manager/keeparive/CreateSchedule.java Tue Dec 10 12:32:43 2013 +0900 +++ b/src/alice/topology/manager/keeparive/CreateSchedule.java Tue Dec 10 17:40:13 2013 +0900 @@ -23,8 +23,11 @@ LinkedList<TaskInfo> list = manager.getTaskList(); if (ps.getNowTask()!=null&&ps.getNowTask().getManagerKey().equals(newTask.getManagerKey())){ long postponeTime = ps.getNowTask().getSleepTime() - (System.currentTimeMillis() - ps.getTime()); - TaskInfo nextTask = list.getFirst(); - nextTask.setSleepTime(postponeTime + nextTask.getSleepTime()); + TaskInfo nextTask; + if (list.size() != 0){ + nextTask = list.getFirst(); + nextTask.setSleepTime(postponeTime + nextTask.getSleepTime()); + } manager.addTask(newTask); ps.interrupt(); } else {
--- a/src/alice/topology/manager/keeparive/GetTask.java Tue Dec 10 12:32:43 2013 +0900 +++ b/src/alice/topology/manager/keeparive/GetTask.java Tue Dec 10 17:40:13 2013 +0900 @@ -5,20 +5,15 @@ import alice.datasegment.Receiver; public class GetTask extends CodeSegment{ - private Receiver info = ids.create(CommandType.PEEK); + private Receiver info = ids.create(CommandType.TAKE); public GetTask(){ - info.setKey("_WAITINGLIST"); + info.setKey("test"); } @Override public void run() { - ListManager list = info.asClass(ListManager.class); - if (list.getTaskList().size() == 0){ - new GetTask(); - return; - } - SendPing.getInstance().setKey(); + this.recycle(); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/topology/manager/keeparive/RespondData.java Tue Dec 10 17:40:13 2013 +0900 @@ -0,0 +1,11 @@ +package alice.topology.manager.keeparive; + +public class RespondData { + public String from; + public long time; + + public RespondData(String str, long t){ + from = str; + time = t; + } +}
--- a/src/alice/topology/manager/keeparive/RespondPing.java Tue Dec 10 12:32:43 2013 +0900 +++ b/src/alice/topology/manager/keeparive/RespondPing.java Tue Dec 10 17:40:13 2013 +0900 @@ -13,9 +13,12 @@ @Override public void run() { - System.out.println(respond.getVal()); - TaskInfo task = new TaskInfo(respond.from, "_RESPONCE", 10 * 1000); + RespondData d = respond.asClass(RespondData.class); + System.out.print("Data from "+d.from); + System.out.println(" Data time "+d.time); + TaskInfo task = new TaskInfo(d.from, "_RESPONCE", 5 * 1000); ods.put("_TASKINFO", task); + } }
--- a/src/alice/topology/manager/keeparive/SendPing.java Tue Dec 10 12:32:43 2013 +0900 +++ b/src/alice/topology/manager/keeparive/SendPing.java Tue Dec 10 17:40:13 2013 +0900 @@ -26,11 +26,11 @@ ListManager list = info.asClass(ListManager.class); if (list.getTaskList().size() == 0){ ods.update("_WAITINGLIST", list); - new GetTask(); + setKey(); return; } else { try { - nowTask = list.getTaskList().pollFirst(); + nowTask = list.getTaskList().poll(); ods.update("_WAITINGLIST", list); System.out.print("managerkey is "+ nowTask.getManagerKey()); System.out.println(" returnkey is "+ nowTask.getReturnKey()); @@ -46,7 +46,7 @@ } catch (InterruptedException e) { } } - new GetTask(); + setKey(); } public synchronized void interrupt(){ interruptFlag = true;
--- a/src/alice/topology/node/IncomingConnectionInfo.java Tue Dec 10 12:32:43 2013 +0900 +++ b/src/alice/topology/node/IncomingConnectionInfo.java Tue Dec 10 17:40:13 2013 +0900 @@ -36,7 +36,7 @@ } HostMessage hostInfo = this.hostInfo.asClass(HostMessage.class); - System.out.println(hostInfo.reconnectFlag); + //System.out.println(hostInfo.reconnectFlag); DataSegment.connect(hostInfo.connectionName, hostInfo.reverseName, hostInfo.name, hostInfo.port, hostInfo.reconnectFlag); ods.put(hostInfo.connectionName, "reverseKey", hostInfo.reverseName); connectionList.add(hostInfo.connectionName);