# HG changeset patch
# User sugi
# Date 1386664813 -32400
# Node ID 9e84deb9b1e037b5755e37d23adc2470a39fe213
# Parent f9ec5bead15056fa40fe19f89492769bc51f5fe1
Respond Worked
diff -r f9ec5bead150 -r 9e84deb9b1e0 .classpath
--- a/.classpath Tue Dec 10 12:32:43 2013 +0900
+++ b/.classpath Tue Dec 10 17:40:13 2013 +0900
@@ -5,7 +5,6 @@
-
diff -r f9ec5bead150 -r 9e84deb9b1e0 scripts/keeparive.sh
--- /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
diff -r f9ec5bead150 -r 9e84deb9b1e0 src/alice/daemon/IncomingTcpConnection.java
--- 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;
diff -r f9ec5bead150 -r 9e84deb9b1e0 src/alice/topology/manager/keeparive/CreateSchedule.java
--- 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 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 {
diff -r f9ec5bead150 -r 9e84deb9b1e0 src/alice/topology/manager/keeparive/GetTask.java
--- 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();
}
}
diff -r f9ec5bead150 -r 9e84deb9b1e0 src/alice/topology/manager/keeparive/RespondData.java
--- /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;
+ }
+}
diff -r f9ec5bead150 -r 9e84deb9b1e0 src/alice/topology/manager/keeparive/RespondPing.java
--- 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);
+
}
}
diff -r f9ec5bead150 -r 9e84deb9b1e0 src/alice/topology/manager/keeparive/SendPing.java
--- 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;
diff -r f9ec5bead150 -r 9e84deb9b1e0 src/alice/topology/node/IncomingConnectionInfo.java
--- 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);