changeset 345:8f71c3e6f11d

Change directory structure Maven standard
author sugi
date Wed, 16 Apr 2014 18:26:07 +0900
parents 9f97ec18f8c5
children d46c42352e4f
files .classpath .project .settings/org.eclipse.core.resources.prefs .settings/org.eclipse.jdt.core.prefs src/alice/codesegment/CodeSegment.java src/alice/codesegment/CodeSegmentManager.java src/alice/codesegment/InputDataSegment.java src/alice/codesegment/OutputDataSegment.java src/alice/codesegment/SingletonMessage.java src/alice/daemon/AcceptThread.java src/alice/daemon/AliceDaemon.java src/alice/daemon/CommandMessage.java src/alice/daemon/Config.java src/alice/daemon/Connection.java src/alice/daemon/IncomingTcpConnection.java src/alice/daemon/OutboundTcpConnection.java src/alice/datasegment/Command.java src/alice/datasegment/CommandType.java src/alice/datasegment/DataSegment.java src/alice/datasegment/DataSegmentKey.java src/alice/datasegment/DataSegmentManager.java src/alice/datasegment/DataSegmentValue.java src/alice/datasegment/LocalDataSegmentManager.java src/alice/datasegment/ReceiveLocalData.java src/alice/datasegment/ReceiveRemoteData.java src/alice/datasegment/Receiver.java src/alice/datasegment/ReceiverData.java src/alice/datasegment/RemoteDataSegmentManager.java src/alice/test/codesegment/api/FlipCodeSegment.java src/alice/test/codesegment/api/FlipTest.java src/alice/test/codesegment/api/PeekCodeSegment.java src/alice/test/codesegment/api/PutCodeSegment.java src/alice/test/codesegment/api/StartCodeSegment.java src/alice/test/codesegment/api/TakeCodeSegment.java src/alice/test/codesegment/api/TestApiAlice.java src/alice/test/codesegment/api/UpdateCodeSegment.java src/alice/test/codesegment/local/SingletonTestCodeSegment.java src/alice/test/codesegment/local/StartCodeSegment.java src/alice/test/codesegment/local/TestCodeSegment.java src/alice/test/codesegment/local/TestLocalAlice.java src/alice/test/codesegment/local/bitonicsort/DataInfo.java src/alice/test/codesegment/local/bitonicsort/DataList.java src/alice/test/codesegment/local/bitonicsort/LocalBitonicSort.java src/alice/test/codesegment/local/bitonicsort/MakeData.java src/alice/test/codesegment/local/bitonicsort/RangeInfo.java src/alice/test/codesegment/local/bitonicsort/SetInfo.java src/alice/test/codesegment/local/bitonicsort/SetTask.java src/alice/test/codesegment/local/bitonicsort/ShowData.java src/alice/test/codesegment/local/bitonicsort/Sort.java src/alice/test/codesegment/local/bitonicsort/SortConfig.java src/alice/test/codesegment/local/bitonicsort/SortPhase.java src/alice/test/codesegment/local/bitonicsort/SortTest.java src/alice/test/codesegment/local/wordcount/CorrectResult.java src/alice/test/codesegment/local/wordcount/Range.java src/alice/test/codesegment/local/wordcount/ReadFileTest.java src/alice/test/codesegment/local/wordcount/Result.java src/alice/test/codesegment/local/wordcount/SeparateArray.java src/alice/test/codesegment/local/wordcount/StartWordCount.java src/alice/test/codesegment/local/wordcount/WordConfig.java src/alice/test/codesegment/local/wordcount/WordCount.java src/alice/test/codesegment/remote/RemoteIncrement.java src/alice/test/codesegment/remote/RemoteStartCodeSegment.java src/alice/test/codesegment/remote/TestRemoteAlice.java src/alice/test/codesegment/remote/TestRemoteConfig.java src/alice/test/concurrent/AliceConcurrentTest.java src/alice/test/concurrent/AliceFinish.java src/alice/test/concurrent/SleepCodeSegment.java src/alice/test/concurrent/StartConcurrent.java src/alice/test/reflection/CSTemplate.java src/alice/test/reflection/ReflectionTest.java src/alice/test/topology/aquarium/AutoIncrement.java src/alice/test/topology/aquarium/CheckLocalIndex.java src/alice/test/topology/aquarium/CheckMyName.java src/alice/test/topology/aquarium/FishMovementConfig.java src/alice/test/topology/aquarium/FishMovementTopology.java src/alice/test/topology/aquarium/FishPoint.java src/alice/test/topology/aquarium/KeyInputCodeSegment.java src/alice/test/topology/aquarium/MakeFrame.java src/alice/test/topology/aquarium/MakeObject.java src/alice/test/topology/aquarium/MouseViewEvent.java src/alice/test/topology/aquarium/ObjectList.java src/alice/test/topology/aquarium/RefreshWindow.java src/alice/test/topology/aquarium/ResetFish.java src/alice/test/topology/aquarium/SendLocation.java src/alice/test/topology/aquarium/SendMaxsize.java src/alice/test/topology/aquarium/SetLocation.java src/alice/test/topology/aquarium/StartFishMovement.java src/alice/test/topology/aquarium/TakeMynum.java src/alice/test/topology/aquarium/TakePnum.java src/alice/test/topology/aquarium/ViewChange.java src/alice/test/topology/fish/AssignStartX.java src/alice/test/topology/fish/CheckMyName.java src/alice/test/topology/fish/DistributedFish.java src/alice/test/topology/fish/FishConfig.java src/alice/test/topology/fish/GetStartX.java src/alice/test/topology/fish/PeekStartX.java src/alice/test/topology/fish/Routing.java src/alice/test/topology/fish/RoutingTable.java src/alice/test/topology/fish/SendWidth.java src/alice/test/topology/fish/StartFish.java src/alice/test/topology/fish/StartStartX.java src/alice/test/topology/fish/WidthReceiver.java src/alice/test/topology/ring/CheckMyName.java src/alice/test/topology/ring/FirstRingMessagePassing.java src/alice/test/topology/ring/RingFinish.java src/alice/test/topology/ring/RingMessagePassing.java src/alice/test/topology/ring/RingTopology.java src/alice/test/topology/ring/RingTopologyConfig.java src/alice/test/topology/ring/StartRing.java src/alice/test/topology/share/AutoIncrement.java src/alice/test/topology/share/CheckLocalIndex.java src/alice/test/topology/share/CheckMyName.java src/alice/test/topology/share/DataInfo.java src/alice/test/topology/share/LookUpData.java src/alice/test/topology/share/SendData.java src/alice/test/topology/share/ShareConfig.java src/alice/test/topology/share/ShareTopology.java src/alice/test/topology/share/StartFishMovement.java src/alice/topology/HostMessage.java src/alice/topology/manager/ConfigWaiter.java src/alice/topology/manager/IncomingHosts.java src/alice/topology/manager/NodeInfo.java src/alice/topology/manager/StartTopologyManager.java src/alice/topology/manager/TopologyFinish.java src/alice/topology/manager/TopologyManager.java src/alice/topology/manager/TopologyManagerConfig.java src/alice/topology/manager/createABSIPList.java src/alice/topology/manager/keeparive/CheckExistTask.java src/alice/topology/manager/keeparive/CreateSchedule.java src/alice/topology/manager/keeparive/CreateTask.java src/alice/topology/manager/keeparive/KeepAlive.java src/alice/topology/manager/keeparive/ListManager.java src/alice/topology/manager/keeparive/ListManagerTest.java src/alice/topology/manager/keeparive/RemoveTask.java src/alice/topology/manager/keeparive/RespondData.java src/alice/topology/manager/keeparive/RespondPing.java src/alice/topology/manager/keeparive/StartKeepAlive.java src/alice/topology/manager/keeparive/TaskExecuter.java src/alice/topology/manager/keeparive/TaskInfo.java src/alice/topology/manager/keeparive/TaskType.java src/alice/topology/manager/reconnection/CheckABSName.java src/alice/topology/manager/reconnection/CheckConnectionList.java src/alice/topology/manager/reconnection/ReceiveError.java src/alice/topology/manager/reconnection/ReceiveReconnectData.java src/alice/topology/manager/reconnection/SendError.java src/alice/topology/node/ConfigurationFinish.java src/alice/topology/node/IncomingAbstractHostName.java src/alice/topology/node/IncomingConnectionInfo.java src/alice/topology/node/IncomingReverseKey.java src/alice/topology/node/Start.java src/alice/topology/node/StartTopologyNode.java src/alice/topology/node/TopologyNode.java src/alice/topology/node/TopologyNodeConfig.java src/log4j.xml src/main/java/alice/codesegment/CodeSegment.java src/main/java/alice/codesegment/CodeSegmentManager.java src/main/java/alice/codesegment/InputDataSegment.java src/main/java/alice/codesegment/OutputDataSegment.java src/main/java/alice/codesegment/SingletonMessage.java src/main/java/alice/daemon/AcceptThread.java src/main/java/alice/daemon/AliceDaemon.java src/main/java/alice/daemon/CommandMessage.java src/main/java/alice/daemon/Config.java src/main/java/alice/daemon/Connection.java src/main/java/alice/daemon/IncomingTcpConnection.java src/main/java/alice/daemon/OutboundTcpConnection.java src/main/java/alice/datasegment/Command.java src/main/java/alice/datasegment/CommandType.java src/main/java/alice/datasegment/DataSegment.java src/main/java/alice/datasegment/DataSegmentKey.java src/main/java/alice/datasegment/DataSegmentManager.java src/main/java/alice/datasegment/DataSegmentValue.java src/main/java/alice/datasegment/LocalDataSegmentManager.java src/main/java/alice/datasegment/ReceiveLocalData.java src/main/java/alice/datasegment/ReceiveRemoteData.java src/main/java/alice/datasegment/Receiver.java src/main/java/alice/datasegment/ReceiverData.java src/main/java/alice/datasegment/RemoteDataSegmentManager.java src/main/java/alice/test/codesegment/api/FlipCodeSegment.java src/main/java/alice/test/codesegment/api/FlipTest.java src/main/java/alice/test/codesegment/api/PeekCodeSegment.java src/main/java/alice/test/codesegment/api/PutCodeSegment.java src/main/java/alice/test/codesegment/api/StartCodeSegment.java src/main/java/alice/test/codesegment/api/TakeCodeSegment.java src/main/java/alice/test/codesegment/api/TestApiAlice.java src/main/java/alice/test/codesegment/api/UpdateCodeSegment.java src/main/java/alice/test/codesegment/local/SingletonTestCodeSegment.java src/main/java/alice/test/codesegment/local/StartCodeSegment.java src/main/java/alice/test/codesegment/local/TestCodeSegment.java src/main/java/alice/test/codesegment/local/TestLocalAlice.java src/main/java/alice/test/codesegment/local/bitonicsort/DataInfo.java src/main/java/alice/test/codesegment/local/bitonicsort/DataList.java src/main/java/alice/test/codesegment/local/bitonicsort/LocalBitonicSort.java src/main/java/alice/test/codesegment/local/bitonicsort/MakeData.java src/main/java/alice/test/codesegment/local/bitonicsort/RangeInfo.java src/main/java/alice/test/codesegment/local/bitonicsort/SetInfo.java src/main/java/alice/test/codesegment/local/bitonicsort/SetTask.java src/main/java/alice/test/codesegment/local/bitonicsort/ShowData.java src/main/java/alice/test/codesegment/local/bitonicsort/Sort.java src/main/java/alice/test/codesegment/local/bitonicsort/SortConfig.java src/main/java/alice/test/codesegment/local/bitonicsort/SortPhase.java src/main/java/alice/test/codesegment/local/bitonicsort/SortTest.java src/main/java/alice/test/codesegment/local/wordcount/CorrectResult.java src/main/java/alice/test/codesegment/local/wordcount/Range.java src/main/java/alice/test/codesegment/local/wordcount/ReadFileTest.java src/main/java/alice/test/codesegment/local/wordcount/Result.java src/main/java/alice/test/codesegment/local/wordcount/SeparateArray.java src/main/java/alice/test/codesegment/local/wordcount/StartWordCount.java src/main/java/alice/test/codesegment/local/wordcount/WordConfig.java src/main/java/alice/test/codesegment/local/wordcount/WordCount.java src/main/java/alice/test/codesegment/remote/RemoteIncrement.java src/main/java/alice/test/codesegment/remote/RemoteStartCodeSegment.java src/main/java/alice/test/codesegment/remote/TestRemoteAlice.java src/main/java/alice/test/codesegment/remote/TestRemoteConfig.java src/main/java/alice/test/concurrent/AliceConcurrentTest.java src/main/java/alice/test/concurrent/AliceFinish.java src/main/java/alice/test/concurrent/SleepCodeSegment.java src/main/java/alice/test/concurrent/StartConcurrent.java src/main/java/alice/test/reflection/CSTemplate.java src/main/java/alice/test/reflection/ReflectionTest.java src/main/java/alice/test/topology/aquarium/AutoIncrement.java src/main/java/alice/test/topology/aquarium/CheckLocalIndex.java src/main/java/alice/test/topology/aquarium/CheckMyName.java src/main/java/alice/test/topology/aquarium/FishMovementConfig.java src/main/java/alice/test/topology/aquarium/FishMovementTopology.java src/main/java/alice/test/topology/aquarium/FishPoint.java src/main/java/alice/test/topology/aquarium/KeyInputCodeSegment.java src/main/java/alice/test/topology/aquarium/MakeFrame.java src/main/java/alice/test/topology/aquarium/MakeObject.java src/main/java/alice/test/topology/aquarium/MouseViewEvent.java src/main/java/alice/test/topology/aquarium/ObjectList.java src/main/java/alice/test/topology/aquarium/RefreshWindow.java src/main/java/alice/test/topology/aquarium/ResetFish.java src/main/java/alice/test/topology/aquarium/SendLocation.java src/main/java/alice/test/topology/aquarium/SendMaxsize.java src/main/java/alice/test/topology/aquarium/SetLocation.java src/main/java/alice/test/topology/aquarium/StartFishMovement.java src/main/java/alice/test/topology/aquarium/TakeMynum.java src/main/java/alice/test/topology/aquarium/TakePnum.java src/main/java/alice/test/topology/aquarium/ViewChange.java src/main/java/alice/test/topology/fish/AssignStartX.java src/main/java/alice/test/topology/fish/CheckMyName.java src/main/java/alice/test/topology/fish/DistributedFish.java src/main/java/alice/test/topology/fish/FishConfig.java src/main/java/alice/test/topology/fish/GetStartX.java src/main/java/alice/test/topology/fish/PeekStartX.java src/main/java/alice/test/topology/fish/Routing.java src/main/java/alice/test/topology/fish/RoutingTable.java src/main/java/alice/test/topology/fish/SendWidth.java src/main/java/alice/test/topology/fish/StartFish.java src/main/java/alice/test/topology/fish/StartStartX.java src/main/java/alice/test/topology/fish/WidthReceiver.java src/main/java/alice/test/topology/ring/CheckMyName.java src/main/java/alice/test/topology/ring/FirstRingMessagePassing.java src/main/java/alice/test/topology/ring/RingFinish.java src/main/java/alice/test/topology/ring/RingMessagePassing.java src/main/java/alice/test/topology/ring/RingTopology.java src/main/java/alice/test/topology/ring/RingTopologyConfig.java src/main/java/alice/test/topology/ring/StartRing.java src/main/java/alice/test/topology/share/AutoIncrement.java src/main/java/alice/test/topology/share/CheckLocalIndex.java src/main/java/alice/test/topology/share/CheckMyName.java src/main/java/alice/test/topology/share/DataInfo.java src/main/java/alice/test/topology/share/LookUpData.java src/main/java/alice/test/topology/share/SendData.java src/main/java/alice/test/topology/share/ShareConfig.java src/main/java/alice/test/topology/share/ShareTopology.java src/main/java/alice/test/topology/share/StartFishMovement.java src/main/java/alice/topology/HostMessage.java src/main/java/alice/topology/manager/ConfigWaiter.java src/main/java/alice/topology/manager/IncomingHosts.java src/main/java/alice/topology/manager/NodeInfo.java src/main/java/alice/topology/manager/StartTopologyManager.java src/main/java/alice/topology/manager/TopologyFinish.java src/main/java/alice/topology/manager/TopologyManager.java src/main/java/alice/topology/manager/TopologyManagerConfig.java src/main/java/alice/topology/manager/createABSIPList.java src/main/java/alice/topology/manager/keeparive/CheckExistTask.java src/main/java/alice/topology/manager/keeparive/CreateSchedule.java src/main/java/alice/topology/manager/keeparive/CreateTask.java src/main/java/alice/topology/manager/keeparive/KeepAlive.java src/main/java/alice/topology/manager/keeparive/ListManager.java src/main/java/alice/topology/manager/keeparive/ListManagerTest.java src/main/java/alice/topology/manager/keeparive/RemoveTask.java src/main/java/alice/topology/manager/keeparive/RespondData.java src/main/java/alice/topology/manager/keeparive/RespondPing.java src/main/java/alice/topology/manager/keeparive/StartKeepAlive.java src/main/java/alice/topology/manager/keeparive/TaskExecuter.java src/main/java/alice/topology/manager/keeparive/TaskInfo.java src/main/java/alice/topology/manager/keeparive/TaskType.java src/main/java/alice/topology/manager/reconnection/CheckABSName.java src/main/java/alice/topology/manager/reconnection/CheckConnectionList.java src/main/java/alice/topology/manager/reconnection/ReceiveError.java src/main/java/alice/topology/manager/reconnection/ReceiveReconnectData.java src/main/java/alice/topology/manager/reconnection/SendError.java src/main/java/alice/topology/node/ConfigurationFinish.java src/main/java/alice/topology/node/IncomingAbstractHostName.java src/main/java/alice/topology/node/IncomingConnectionInfo.java src/main/java/alice/topology/node/IncomingReverseKey.java src/main/java/alice/topology/node/Start.java src/main/java/alice/topology/node/StartTopologyNode.java src/main/java/alice/topology/node/TopologyNode.java src/main/java/alice/topology/node/TopologyNodeConfig.java src/main/java/log4j.xml
diffstat 304 files changed, 5874 insertions(+), 5981 deletions(-) [+]
line wrap: on
line diff
--- a/.classpath	Wed Apr 16 17:37:48 2014 +0900
+++ b/.classpath	Wed Apr 16 18:26:07 2014 +0900
@@ -1,13 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry exported="true" kind="lib" path="lib/javassist.jar"/>
-	<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/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"/>
-	<classpathentry exported="true" kind="lib" path="lib/com.alexmerz.graphviz.jar"/>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/main/resources"/>
+	<classpathentry kind="src" path="src/test/java"/>
+	<classpathentry kind="src" path="src/test/resources"/>
+	<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry exported="true" kind="con" path="org.springsource.ide.eclipse.gradle.classpathcontainer"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
--- a/.project	Wed Apr 16 17:37:48 2014 +0900
+++ b/.project	Wed Apr 16 18:26:07 2014 +0900
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>Alice</name>
+	<name>Alice-Gradle</name>
 	<comment></comment>
 	<projects>
 	</projects>
@@ -12,6 +12,7 @@
 		</buildCommand>
 	</buildSpec>
 	<natures>
+		<nature>org.springsource.ide.eclipse.gradle.core.nature</nature>
 		<nature>org.eclipse.jdt.core.javanature</nature>
 	</natures>
 </projectDescription>
--- a/.settings/org.eclipse.core.resources.prefs	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-eclipse.preferences.version=1
-encoding//src/alice/test/codesegment/local/bitonicsort/SortTest.java=UTF-8
-encoding//src/alice/test/codesegment/local/wordcount/SeparateArray.java=UTF-8
-encoding//src/alice/test/codesegment/local/wordcount/WordCount.java=UTF-8
-encoding//src/alice/topology/manager/IncomingHosts.java=UTF-8
-encoding//src/alice/topology/manager/createABSIPList.java=UTF-8
-encoding//src/alice/topology/manager/keeparive/RemoveTask.java=UTF-8
-encoding//src/alice/topology/manager/keeparive/TaskExecuter.java=UTF-8
--- a/.settings/org.eclipse.jdt.core.prefs	Wed Apr 16 17:37:48 2014 +0900
+++ b/.settings/org.eclipse.jdt.core.prefs	Wed Apr 16 18:26:07 2014 +0900
@@ -1,9 +1,4 @@
 eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
@@ -11,99 +6,6 @@
 org.eclipse.jdt.core.compiler.debug.lineNumber=generate
 org.eclipse.jdt.core.compiler.debug.localVariable=generate
 org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.doc.comment.support=enabled
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
 org.eclipse.jdt.core.compiler.source=1.6
--- a/src/alice/codesegment/CodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-package alice.codesegment;
-
-import java.util.ArrayList;
-
-import alice.codesegment.InputDataSegment;
-import alice.datasegment.Receiver;
-
-public abstract class CodeSegment implements Runnable {
-	
-	public InputDataSegment ids = new InputDataSegment(this);
-	public OutputDataSegment ods = new OutputDataSegment();
-	public ArrayList<Receiver> list = new ArrayList<Receiver>();
-	
-	public void execute() {
-		ids.receive();
-	}
-	
-	public void recycle(){
-		ids.init();
-		ids.setCounter(list.size());
-		for (Receiver receiver : list) {
-			ids.recommand(receiver);
-		}
-	}
-
-}
--- a/src/alice/codesegment/CodeSegmentManager.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-package alice.codesegment;
-
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.log4j.Logger;
-
-public class CodeSegmentManager {
-
-	private static CodeSegmentManager instance = new CodeSegmentManager();
-	private ThreadPoolExecutor codeSegmentExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), // initial number of threads
-				                                Runtime.getRuntime().availableProcessors(),
-												Integer.MAX_VALUE, // keepAliveTime
-												TimeUnit.SECONDS,
-												new LinkedBlockingQueue<Runnable>());
-	private Logger logger = Logger.getLogger(CodeSegmentManager.class);
-
-	public static CodeSegmentManager get() {
-		return instance;
-	}
-
-	public static void submit(CodeSegment cs) {
-		CodeSegmentManager csManager = CodeSegmentManager.get();
-		csManager.codeSegmentExecutor.execute(cs);
-		if (csManager.logger.isDebugEnabled()) {
-			csManager.logger.debug(cs.getClass().getName());
-		}
-	}
-	
-}
--- a/src/alice/codesegment/InputDataSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-package alice.codesegment;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import alice.datasegment.Command;
-import alice.datasegment.CommandType;
-import alice.datasegment.DataSegment;
-import alice.datasegment.ReceiveLocalData;
-import alice.datasegment.ReceiveRemoteData;
-import alice.datasegment.Receiver;
-
-/**
- * InputDataSegment Manager
- * 			keep tracking unbound/bound count
- * @author kazz
- *
- */
-public class InputDataSegment {
-	
-	public CodeSegment cs;
-	private AtomicInteger count = new AtomicInteger(1); // 1 for no input data segments
-	private AtomicInteger keyCount = new AtomicInteger(0); // number of DataSegments
-	public InputDataSegment(CodeSegment cs) {
-		this.cs = cs;
-	}
-	
-	public void init(){
-		count = new AtomicInteger(1);
-		keyCount = new AtomicInteger(0);
-	}
-	
-	public void quickPeek(Receiver receiver) {
-		cs.list.add(receiver);
-		if (receiver.managerKey==null){
-			DataSegment.getLocal().peek(receiver, cs);
-		} else {
-			DataSegment.get(receiver.managerKey).quickPeek(receiver ,cs);
-		}
-	}
-	
-	public void quickTake(Receiver receiver) {
-		cs.list.add(receiver);
-		if (receiver.managerKey==null){
-			DataSegment.getLocal().quickTake(receiver, cs);
-		} else {
-			DataSegment.get(receiver.managerKey).quickTake(receiver ,cs);
-		}
-	}
-	
-	public void peek(Receiver receiver) {
-		cs.list.add(receiver);
-		if (receiver.managerKey==null){
-			DataSegment.getLocal().peek(receiver, cs);
-		} else {
-			DataSegment.get(receiver.managerKey).peek(receiver, cs);
-		}
-	}
-
-	
-	public void take(Receiver receiver) {
-		cs.list.add(receiver);
-		if (receiver.managerKey==null){
-			DataSegment.getLocal().take(receiver, cs);
-		} else {
-			DataSegment.get(receiver.managerKey).take(receiver, cs);
-		}
-	}
-
-	public void reply(Receiver receiver, Command reply) {
-		receiver.index = reply.index;
-		receiver.from = reply.reverseKey;
-		if (reply.reverseKey==null){
-			receiver.setData(new ReceiveRemoteData(reply.val));
-		} else if (!reply.reverseKey.equals("local")) {
-			receiver.setData(new ReceiveRemoteData(reply.val));
-		} else {
-			receiver.setData(new ReceiveLocalData(reply.obj));			
-		}
-		receive();
-	}
-
-	public void register() {
-		count.getAndIncrement();
-		keyCount.getAndIncrement();
-	}
-	
-	public void setKey() {
-		if (keyCount.decrementAndGet() == 0) {
-			receive();
-		}
-	}
-	
-	public void receive() {
-		if (count.decrementAndGet() == 0) {
-			CodeSegmentManager.submit(cs);
-		}
-	}
-	
-	/**
-	 * InputDataSegment factory
-	 * @param type PEEK or TAKE
-	 * @return Receiver of DataSegment reply 
-	 */
-	public Receiver create(CommandType type) {
-		return new Receiver(this, type);
-	}
-
-	public void recommand(Receiver receiver) {
-		// TODO why only local?
-		DataSegment.getLocal().recommand(receiver, cs);
-	}
-	
-	public void setCounter(int cnt){
-		count.set(cnt);
-	}
-}
--- a/src/alice/codesegment/OutputDataSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-package alice.codesegment;
-
-import alice.datasegment.DataSegment;
-import alice.datasegment.Receiver;
-
-public class OutputDataSegment {
-
-	/**
-	 * for local
-	 */
-
-	public void flip(Receiver receiver) {
-		receiver.managerKey=null;
-		DataSegment.getLocal().put(receiver.key, receiver.getObj());
-	}
-
-	public void put(String key, Object val) {
-		DataSegment.getLocal().put(key, val);
-	}
-
-	public void quickPut(String key, Object val) {
-		put(key, val);
-	}
-
-	public void update(String key, Object val) {
-		DataSegment.getLocal().update(key, val);
-	}
-
-	public void quickuUpdate(String key, Object val) {
-		update(key, val);
-	}
-
-	/**
-	 * for remote
-	 */
-	public void put(String managerKey, String key, Object val) {
-		if (!managerKey.equals("local")){
-			DataSegment.get(managerKey).put(key,val);
-		} else {
-			put(key, val);
-		}
-	}
-
-	public void quickPut(String managerKey, String key, Object val) {
-		if (!managerKey.equals("local")){
-			DataSegment.get(managerKey).quickPut(key, val);
-		} else {
-			put(key, val);
-		}
-	}
-
-	public void update(String managerKey, String key, Object val) {
-		if (!managerKey.equals("local")){
-			DataSegment.get(managerKey).update(key, val);
-		} else {
-			update(key, val);
-		}
-	}
-
-	public void quickUpdate(String managerKey, String key, Object val) {
-		if (!managerKey.equals("local")){
-			DataSegment.get(managerKey).update(key, val);
-		} else {
-			update(key, val);
-		}
-	}
-
-	/**
-	 * kill the Alice process after send other messages.
-	 * 
-	 * @param managerKey
-	 */
-
-	public void finish(String managerKey) {
-		DataSegment.get(managerKey).finish();
-	}
-
-	/**
-	 * close socket for RemoteDataSegment after send other messages.
-	 * 
-	 * @param managerKey
-	 */
-
-	public void close(String managerKey) {
-		DataSegment.get(managerKey).close();
-	}
-
-	/**
-	 * "key" is not remote DataSegment's key.
-	 * "Ping Response" return in this "key" 
-	 * 
-	 * @param managerKey
-	 * @param key
-	 */
-	public void ping(String managerKey, String returnKey) {
-		DataSegment.get(managerKey).ping(returnKey);
-	}
-
-}
--- a/src/alice/codesegment/SingletonMessage.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-package alice.codesegment;
-
-import org.msgpack.MessagePack;
-
-public class SingletonMessage {
-	
-	private static final MessagePack instance = new MessagePack(); 
-	
-	public static MessagePack getInstance(){
-		return instance;
-	}
-
-}
--- a/src/alice/daemon/AcceptThread.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-package alice.daemon;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.Socket;
-
-import org.apache.log4j.Logger;
-
-import alice.datasegment.DataSegment;
-
-public class AcceptThread extends Thread {
-
-	private ServerSocket ss;
-	private Logger log = Logger.getLogger(AcceptThread.class);
-	public int counter = 0;
-
-	public AcceptThread(ServerSocket ss, String name) {
-		super(name);
-		this.ss = ss;
-	}
-	
-	@Override
-	public void run() {
-		while (true) {
-			try {
-				Socket socket = ss.accept();
-				socket.setTcpNoDelay(true);
-				log.info("Accept " + socket.getInetAddress().getHostName() + ":" + socket.getPort());
-				Connection connection = new Connection(socket);
-				String key = "accept" + counter;
-				IncomingTcpConnection incoming =
-						new IncomingTcpConnection(connection, DataSegment.get("local"), key);
-				incoming.start();
-				DataSegment.setAccept(key, incoming);
-				new OutboundTcpConnection(connection).start();
-				counter++;
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-
-}
--- a/src/alice/daemon/AliceDaemon.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-package alice.daemon;
-
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-import java.nio.channels.ServerSocketChannel;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.WriterAppender;
-
-public class AliceDaemon {
-	
-	private Config conf;
-	private AcceptThread acceptThread;
-	private Logger log = Logger.getLogger(AliceDaemon.class);
-	
-	public AliceDaemon(Config conf) {
-		this.conf = conf;
-		setLogger();
-	}
-	
-	private void setLogger() {
-		Logger root = Logger.getRootLogger();
-		if (conf.level != null)
-			root.setLevel(conf.level);
-		if (conf.logFile == null)
-			return;
-		PatternLayout layout = new PatternLayout();
-		layout.setConversionPattern("%d %-5p %c - %m [%t] (%F:%L)%n");
-		try {
-			FileWriter writer = new FileWriter(conf.logFile);
-			WriterAppender writerAppender = new WriterAppender(layout, writer);
-			root.removeAllAppenders();
-			root.addAppender(writerAppender);
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		log.info("configured");
-	}
-	
-	public void listen() {
-		try {
-			ServerSocketChannel ssChannel = ServerSocketChannel.open();
-			ServerSocket ss = ssChannel.socket();
-			ss.setReuseAddress(true);
-			
-            //InetSocketAddress a = new InetSocketAddress("::", conf.localPort);
-            InetSocketAddress a = new InetSocketAddress(InetAddress.getLocalHost(), conf.localPort);
-            //System.out.println(a);
-            ss.bind(a);
-			acceptThread = new AcceptThread(ss, "ACCEPT" + conf.localPort);
-			acceptThread.start();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		
-	}
-}
--- a/src/alice/daemon/CommandMessage.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-package alice.daemon;
-
-import org.msgpack.annotation.Message;
-import org.msgpack.type.Value;
-
-@Message
-public class CommandMessage {
-	public int type;
-	public int index;
-	public int seq;
-	public String key;
-	public Value val;
-	public boolean flag;
-	
-	public CommandMessage() {}
-	
-	public CommandMessage(int type, int index, int seq, String key, Value val, boolean flag) {
-		this.type = type;
-		this.index = index;
-		this.seq = seq;
-		this.key = key;
-		this.val = val;
-		this.flag = flag;
-	}
-}
--- a/src/alice/daemon/Config.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-package alice.daemon;
-
-import org.apache.log4j.Level;
-
-public class Config {
-
-	public int localPort = 10000;
-	public String logFile = null;
-	public Level level = null;
-	
-	public Config(String[] args) {
-		for (int i = 0; i< args.length; i++) {
-			if ("-p".equals(args[i])) {
-				localPort = Integer.parseInt(args[++i]);
-			} else if ("-log".equals(args[i])) {
-				logFile = args[++i];
-			} else if ("-level".equals(args[i])) {
-				String levelStr = args[++i];
-				if (levelStr.equals("fatal")) {
-					level = Level.FATAL;
-				} else if (levelStr.equals("error")) {
-					level = Level.ERROR;
-				} else if (levelStr.equals("warn")) {
-					level = Level.WARN;
-				} else if (levelStr.equals("info")) {
-					level = Level.INFO;
-				} else if (levelStr.equals("debug")) {
-					level = Level.DEBUG;
-				}
-			}
-		}
-
-	}
-
-}
--- a/src/alice/daemon/Connection.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-package alice.daemon;
-
-import java.io.IOException;
-import java.net.Socket;
-import java.nio.ByteBuffer;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import alice.codesegment.SingletonMessage;
-import alice.datasegment.Command;
-
-public class Connection {
-
-	public Socket socket;
-	public LinkedBlockingQueue<Command> sendQueue = new LinkedBlockingQueue<Command>();
-
-	public Connection(Socket socket) {
-		this.socket = socket;
-	}
-	
-	public Connection() {}
-
-	public void sendCommand(Command cmd) {
-		try {
-			sendQueue.put(cmd);
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	public String getInfoString() {
-		return socket.getInetAddress().getHostName()
-			   + ":" + socket.getPort();
-	}
-
-	public synchronized void write(Command cmd) {	
-		CommandMessage cmdMsg = cmd.convert();
-		ByteBuffer buffer;
-		try {
-			buffer = ByteBuffer.wrap(SingletonMessage.getInstance().write(cmdMsg));
-			while (buffer.hasRemaining()) {
-				socket.getChannel().write(buffer);
-			}
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	public void close(){
-		try {
-			socket.shutdownOutput();
-			socket.shutdownInput();
-			socket.close();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		
-	}
-}
--- a/src/alice/daemon/IncomingTcpConnection.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-package alice.daemon;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.nio.channels.ClosedChannelException;
-
-import org.msgpack.unpacker.Unpacker;
-
-import alice.codesegment.SingletonMessage;
-import alice.datasegment.Command;
-import alice.datasegment.CommandType;
-import alice.datasegment.DataSegment;
-import alice.datasegment.DataSegmentKey;
-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 {
-	
-	public Connection connection;
-	public DataSegmentManager manager;
-	public String reverseKey;
-	private LocalDataSegmentManager lmanager = DataSegment.getLocal();
-
-	public IncomingTcpConnection(Connection connection, DataSegmentManager manager, String reverseKey) {
-		this.manager = manager;
-		this.connection = connection;
-		this.reverseKey = reverseKey;
-	}
-	
-	/**
-	 * pipeline thread for receiving
-	 */
-	public void run() {
-		Unpacker unpacker = this.getUnpacker();
-		if (unpacker == null) {
-			return;
-		}
-		while (true) {
-			try {
-				CommandMessage msg = unpacker.read(CommandMessage.class);
-				CommandType type = CommandType.getCommandTypeFromId(msg.type);
-				switch (type) {
-				case UPDATE:
-					getDataSegmentKey(msg).runCommand(new Command(type, null, null, msg.val, 0, 0, null, null, reverseKey));
-					break;
-				case PUT:
-					getDataSegmentKey(msg).runCommand(new Command(type, null, null, msg.val, 0, 0, null, null, reverseKey));
-					break;
-				case PEEK:
-					getDataSegmentKey(msg).runCommand(new Command(type, null, null, null, msg.index, msg.seq, connection, null, null, msg.flag));
-					break;
-				case TAKE:
-					getDataSegmentKey(msg).runCommand(new Command(type, null, null, null, msg.index, msg.seq, connection, null, null, msg.flag));
-					break;	
-				case REMOVE:
-					getDataSegmentKey(msg).runCommand(new Command(type, null, null, null, 0, 0, null, null, null));
-					break;
-				case REPLY:
-					Command cmd = manager.getAndRemoveCmd(msg.seq);
-					cmd.cs.ids.reply(cmd.receiver, new Command(type, null, null, msg.val, msg.index, msg.seq, null, null, null));
-					cmd=null;
-					break;
-				case PING:
-					DataSegment.get(reverseKey).response(msg.key);
-					break;
-				case RESPONSE:
-					DataSegment.getLocal().put(msg.key, new RespondData(reverseKey, System.currentTimeMillis()));
-					break;
-				default:
-					break;
-				}
-			} catch (ClosedChannelException e) {
-				connection.sendCommand(new Command(CommandType.CLOSE, null, null, null, 0, 0, null, null, null));
-				return;
-			} catch (EOFException e) {
-				new SendError(new HostMessage(connection.socket.getInetAddress().getHostName(), connection.socket.getPort())).execute();
-				connection.sendCommand(new Command(CommandType.CLOSE, null, null, null, 0, 0, null, null, null));
-				return;
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-
-	private Unpacker getUnpacker() {
-		Unpacker unpacker = null;
-		try {
-			unpacker = SingletonMessage.getInstance().createUnpacker(connection.socket.getInputStream());
-		} catch (IOException e2) {
-			e2.printStackTrace();
-		}
-		return unpacker;
-	}
-
-	private DataSegmentKey getDataSegmentKey(CommandMessage msg) {
-		return lmanager.getDataSegmentKey(msg.key);
-	}
-}
--- a/src/alice/daemon/OutboundTcpConnection.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-package alice.daemon;
-
-import java.io.IOException;
-import alice.datasegment.Command;
-
-public class OutboundTcpConnection extends Thread {
-	
-	public Connection connection;
-	
-	public OutboundTcpConnection(Connection connection) {
-		this.connection = connection;
-	}
-	
-	
-	
-	/**
-	 * pipeline thread for transmission
-	 */
-	public void run() {
-		while (true) {
-			try {
-				Command cmd = connection.sendQueue.take();
-				switch (cmd.type) {
-				case CLOSE:
-					connection.socket.close();
-					return;
-				case FINISH:
-					System.exit(0);
-					return;
-				default:
-					break;
-				}
-				connection.write(cmd);
-			} catch (InterruptedException e) {
-				e.printStackTrace();
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-	
-}
--- a/src/alice/datasegment/Command.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-package alice.datasegment;
-
-import java.io.IOException;
-import java.util.concurrent.BlockingQueue;
-import org.msgpack.type.Value;
-
-import alice.codesegment.CodeSegment;
-import alice.codesegment.SingletonMessage;
-import alice.daemon.CommandMessage;
-import alice.daemon.Connection;
-
-public class Command {
-	public CommandType type;
-	public String key;
-	public Receiver receiver;
-	public Value val;
-	public int index;
-	public int seq;
-	public Connection connection; // for remote
-	public BlockingQueue<Command> replyQueue;
-	public CodeSegment cs;
-	public String reverseKey;
-	public Object obj;
-	public boolean flag;
-
-	public Command(CommandType cmdType, Receiver receiver, String key, Value val, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs, String reverseKey) {
-		this.type = cmdType;
-		this.receiver = receiver;
-		this.key = key;
-		this.val = val;
-		this.index = index;
-		this.seq = seq;
-		this.replyQueue = replyQueue;
-		this.cs = cs;
-		this.reverseKey = reverseKey;
-		this.flag = false;
-	}
-	
-	public Command(CommandType cmdType, Receiver receiver, String key, Value val, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs, String reverseKey, boolean flag) {
-		this.type = cmdType;
-		this.receiver = receiver;
-		this.key = key;
-		this.val = val;
-		this.index = index;
-		this.seq = seq;
-		this.replyQueue = replyQueue;
-		this.cs = cs;
-		this.reverseKey = reverseKey;
-		this.flag = flag;
-	}
-	
-	public Command(CommandType cmdType, Receiver receiver, String key, Value val, int index, int seq, Connection connection, CodeSegment cs, String reverseKey, boolean flag) {
-		this.type = cmdType;
-		this.receiver = receiver;
-		this.key = key;
-		this.val = val;
-		this.index = index;
-		this.seq = seq;
-		this.connection = connection;
-		this.cs = cs;
-		this.reverseKey = reverseKey;
-		this.flag = flag;
-	}
-	
-	public Command(CommandType cmdType, Receiver receiver, String key, Object obj, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs, String reverseKey) {
-		this.type = cmdType;
-		this.receiver = receiver;
-		this.key = key;
-		this.obj = obj;
-		this.index = index;
-		this.seq = seq;
-		this.replyQueue = replyQueue;
-		this.cs = cs;
-		this.reverseKey = reverseKey;
-		this.flag = false;
-	}
-	
-	public Command(CommandType cmdType, Receiver receiver, String key, Value val, Object obj, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs, String reverseKey) {
-		this.type = cmdType;
-		this.receiver = receiver;
-		this.key = key;
-		this.val = val;
-		this.obj = obj;
-		this.index = index;
-		this.seq = seq;
-		this.replyQueue = replyQueue;
-		this.cs = cs;
-		this.reverseKey = reverseKey;
-		this.flag = false;
-	}
-	
-	public String getCommandString() {
-		String csName = "null";
-		if (cs != null) {
-			csName = cs.toString();
-		}
-		return this.type + "\t" + key + "\t" + val + "\tindex=" + index + "\tcs=" + csName;
-	}
-	public CommandMessage convert() {
-		if (val==null&&obj!=null){
-			try {
-				this.val = SingletonMessage.getInstance().unconvert(obj);
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-		return new CommandMessage(type.id, index, seq, key, val, flag);
-	}
-	
-}
--- a/src/alice/datasegment/CommandType.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-package alice.datasegment;
-
-import java.util.HashMap;
-
-public enum CommandType {
-	PUT,
-	UPDATE, // remove a DataSegment value and put
-	PEEK,
-	TAKE,
-	REMOVE,
-	REPLY,
-	CLOSE,
-	FINISH, 
-	PING,
-	RESPONSE;
-	
-	public int id;
-	public static HashMap<Integer, CommandType> hash = new HashMap<Integer, CommandType>();
-	private static int lastId = 0;
-	
-	private CommandType(int id) {
-		this.id = id;
-		setLastId(id);
-	}
-	
-	private CommandType() {
-		this.id = incrementLastId();
-	}
-	
-	private void setLastId(int id) {
-		lastId =id;
-	}
-	
-	private int incrementLastId() {
-		return ++lastId;
-	}
-	
-	public static CommandType getCommandTypeFromId(int id) {
-		return hash.get(id);
-	}
-	
-	static {
-		for (CommandType type : CommandType.values()) {
-			hash.put(type.id, type);
-		}
-	}
-	
-}
--- a/src/alice/datasegment/DataSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-package alice.datasegment;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-import alice.daemon.IncomingTcpConnection;
-
-public class DataSegment {
-	
-	private static DataSegment dataSegment = new DataSegment();
-	private LocalDataSegmentManager local = new LocalDataSegmentManager();
-	private ConcurrentHashMap<String, DataSegmentManager> dataSegmentManagers = new ConcurrentHashMap<String, DataSegmentManager>(); //TODO Over Head
-	private ConcurrentHashMap<String, IncomingTcpConnection> acceptHash = new ConcurrentHashMap<String, IncomingTcpConnection>();
-	
-	private DataSegment() {
-		dataSegmentManagers.put("local", local);
-	}
-	
-	public static DataSegmentManager get(String key) {
-		return dataSegment.dataSegmentManagers.get(key);
-	}
-
-	public static LocalDataSegmentManager getLocal() {
-		return dataSegment.local;
-	}
-	
-	public static void register(String key, DataSegmentManager manager) {
-		dataSegment.dataSegmentManagers.put(key, manager);
-	}
-	
-	public static RemoteDataSegmentManager connect(String connectionKey, String reverseKey, String hostName, int port, boolean rFlag) {
-		RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connectionKey, reverseKey, hostName, port, rFlag);
-		register(connectionKey, manager);
-		return manager;
-	}
-	
-	public static void setAccept(String key, IncomingTcpConnection incoming) {
-		dataSegment.acceptHash.put(key, incoming);
-	}
-	
-	public static IncomingTcpConnection getAccept(String key) {
-		return dataSegment.acceptHash.get(key);
-	}
-	
-	public static void remove(String key){
-		dataSegment.dataSegmentManagers.remove(key);
-	}
-	
-}
--- a/src/alice/datasegment/DataSegmentKey.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-package alice.datasegment;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import alice.datasegment.Command; 
-
-/**
- * Synchronized DataSegment for each DataSegment key
- * @author kazz
- *
- */
-public class DataSegmentKey {
-	
-	private ArrayList<DataSegmentValue> dataList = new ArrayList<DataSegmentValue>();
-	private ArrayList<Command> waitList = new ArrayList<Command>();
-	private int tailIndex = 1;
-	
-	public synchronized void runCommand(Command cmd) {
-		switch (cmd.type) {
-		case UPDATE:
-			if (dataList.size() != 0) {
-				dataList.remove(0);
-			}
-		case PUT:
-			int index = tailIndex;
-			tailIndex++;
-			DataSegmentValue dsv = new DataSegmentValue(index, cmd.val, cmd.obj, cmd.reverseKey); 
-			dataList.add(dsv);
-			// Process waiting peek and take commands
-			for (Iterator<Command> iter = waitList.iterator(); iter.hasNext(); ) {
-				Command waitCmd = iter.next();
-				if (waitCmd.index < index) {
-					replyValue(waitCmd ,dsv);
-					iter.remove();
-					if (waitCmd.type == CommandType.TAKE) { // someone is waiting for this put or update command
-						dataList.remove(dsv);
-						break;
-					}
-				}
-			}
-			break;
-		case PEEK:
-			if (cmd.index >= tailIndex) {
-				waitList.add(cmd);
-				break;
-			}
-			boolean waitFlag2 = true;
-			for (DataSegmentValue data : dataList) {
-				if (data.index > cmd.index) {
-					replyValue(cmd ,data);
-					waitFlag2 = false;
-					break;
-				}
-			}
-			if (waitFlag2)
-				waitList.add(cmd);
-			break;
-		case TAKE:
-			if (cmd.index >= tailIndex) {
-				waitList.add(cmd);
-				break;
-			}
-			boolean waitFlag = true;
-			for (Iterator<DataSegmentValue> iter = dataList.iterator(); iter.hasNext(); ) {
-				DataSegmentValue data = iter.next();
-				if (data.index > cmd.index) {
-					replyValue(cmd ,data);
-					iter.remove();
-					waitFlag = false;
-					break;
-				}
-			}
-			if (waitFlag)
-				waitList.add(cmd);
-			break;
-		case REMOVE:
-			// TODO: implements later
-			break;
-		default:
-		}
-
-	}
-	
-	public void replyValue(Command cmd, DataSegmentValue data){
-		if (cmd.cs!=null){ // if cmd has cs-instance, it means Command from local.
-			cmd.cs.ids.reply(cmd.receiver, new Command(CommandType.REPLY, null, null, data.val, data.obj, data.index, cmd.seq, null, null, data.from));
-		} else {
-			try {
-				if (!cmd.flag){ 
-					cmd.connection.sendQueue.put(new Command(CommandType.REPLY, null, null, data.val, data.obj, data.index, cmd.seq, null, null, data.from));
-				}
-				else {
-					cmd.connection.write(new Command(CommandType.REPLY, null, null, data.val, data.obj, data.index, cmd.seq, null, null, data.from));
-				}
-				
-			} catch (InterruptedException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-	
-}
--- a/src/alice/datasegment/DataSegmentManager.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-package alice.datasegment;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.log4j.Logger;
-
-import alice.codesegment.CodeSegment;
-
-public abstract class DataSegmentManager {
-	
-	protected ConcurrentHashMap<Integer, Command> seqHash = new ConcurrentHashMap<Integer, Command>();
-	protected LinkedBlockingQueue<Command> replyQueue = new LinkedBlockingQueue<Command>();
-	protected AtomicInteger seq = new AtomicInteger(1); // waiting for PUT or UPDATE at unique sequence number
-														// but it doesn't need for Local
-	
-	protected Runnable replyThread = new Runnable() {
-		Logger logger = Logger.getLogger("reply");
-		@Override
-		public void run() {
-			while (true) {
-				try {
-					Command reply = replyQueue.take();
-					Command cmd = getAndRemoveCmd(reply.seq);
-					if (cmd == null) {
-						logger.warn("conflict sequence number");
-						continue;
-					}
-					cmd.cs.ids.reply(cmd.receiver, reply);
-					if (logger.isDebugEnabled())
-						logger.debug(reply.getCommandString() + " " + cmd.getCommandString());
-				} catch (InterruptedException e) {
-					e.printStackTrace();
-				}
-			}
-		}
-		
-	};
-	
-	public Command getAndRemoveCmd(int index){
-		return seqHash.remove(index);
-	}
-	
-	public void addReplyCommand(Command cmd) {
-		try {
-			replyQueue.put(cmd);
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-		}
-	}
-		
-	public abstract void put(String key, Object val);
-	public abstract void update(String key, Object val);
-	public abstract void take(Receiver receiver, CodeSegment cs);
-	public abstract void peek(Receiver receiver, CodeSegment cs);
-	
-	public abstract void quickPut(String key, Object val);
-	public abstract void quickUpdate(String key, Object val);
-	public abstract void quickPeek(Receiver receiver, CodeSegment cs);
-	public abstract void quickTake(Receiver receiver, CodeSegment cs);
-
-	public abstract void remove(String key);
-	public abstract void shutdown(String key);
-	public abstract void close();
-	public abstract void finish();
-	
-	public abstract void ping(String returnKey);
-	public abstract void response(String returnKey);
-		
-}
--- a/src/alice/datasegment/DataSegmentValue.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-package alice.datasegment;
-
-import org.msgpack.type.Value;
-
-public class DataSegmentValue {
-
-	public int index;
-	public Value val;
-	public String from;
-	public Object obj;
-	
-	public DataSegmentValue(int index, Value val, Object obj,String reverseKey) {
-		this.index = index;
-		this.val = val;
-		this.from = reverseKey;
-		this.obj = obj;
-	}
-	
-	public DataSegmentValue(int index, Value val,String reverseKey) {
-		this.index = index;
-		this.val = val;
-		this.from = reverseKey;
-	}
-	
-}
--- a/src/alice/datasegment/LocalDataSegmentManager.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +0,0 @@
-package alice.datasegment;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.log4j.Logger;
-
-import alice.codesegment.CodeSegment;
-
-public class LocalDataSegmentManager extends DataSegmentManager {
-	
-	private String reverseKey = "local";
-	private ConcurrentHashMap<String, DataSegmentKey> dataSegments = new ConcurrentHashMap<String, DataSegmentKey>();
-	private Logger logger = Logger.getLogger("local");
-
-	private ThreadPoolExecutor dataSegmentExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), // initial number of threads
-			Runtime.getRuntime().availableProcessors(),
-			Integer.MAX_VALUE, // keepAliveTime
-			TimeUnit.SECONDS,
-			new LinkedBlockingQueue<Runnable>());
-	
-	public LocalDataSegmentManager() {
-		new Thread(replyThread, "LocalDataSegmentManager-replyCommand").start();
-	}
-
-	private class RunCommand implements Runnable {
-		
-		DataSegmentKey key;
-		Command cmd;
-		
-		public RunCommand(DataSegmentKey key, Command cmd) {
-			this.key = key;
-			this.cmd = cmd;
-		}
-		
-		@Override
-		public void run() {
-			key.runCommand(cmd);
-		}
-		
-	}
-	
-	public void submitCommand(DataSegmentKey key, Command cmd) {
-		dataSegmentExecutor.execute(new RunCommand(key, cmd));
-	}
-	
-	public DataSegmentKey getDataSegmentKey(String key) {
-		DataSegmentKey dsKey = dataSegments.get(key);
-		if (dsKey != null)
-			return dsKey;
-		if (key == null)
-			return null;
-		DataSegmentKey newDataSegmentKey = new DataSegmentKey();
-		DataSegmentKey dataSegmentKey = dataSegments.putIfAbsent(key, newDataSegmentKey);
-		if (dataSegmentKey == null) {
-			dataSegmentKey = newDataSegmentKey;
-		}
-		return dataSegmentKey;
-	}
-	
-	@Override
-	public void put(String key, Object val) {
-		DataSegmentKey dataSegmentKey = getDataSegmentKey(key);
-		Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, null, null, reverseKey);
-		dataSegmentKey.runCommand(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-	
-	@Override
-	public void quickPut(String key, Object val) {
-		put(key, val);
-	}
-	
-	/**
-	 * Enqueue update command to the queue of each DataSegment key
-	 */
-	
-	@Override
-	public void update(String key, Object val) {
-		DataSegmentKey dataSegmentKey = getDataSegmentKey(key);
-		Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null, reverseKey);
-		dataSegmentKey.runCommand(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-	
-	
-	@Override
-	public void quickUpdate(String key, Object val) {
-		update(key, val);
-	}
-
-	
-	
-	@Override
-	public void take(Receiver receiver, CodeSegment cs) {
-		DataSegmentKey dataSegmentKey = getDataSegmentKey(receiver.key);
-		int seq = this.seq.getAndIncrement();
-		Command cmd = new Command(CommandType.TAKE, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null);
-		dataSegmentKey.runCommand(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-
-	@Override
-	public void quickTake(Receiver receiver, CodeSegment cs) {
-		take(receiver, cs);		
-	}
-	
-	@Override
-	public void peek(Receiver receiver, CodeSegment cs) {
-		DataSegmentKey dataSegmentKey = getDataSegmentKey(receiver.key);
-		int seq = this.seq.getAndIncrement();
-		Command cmd = new Command(CommandType.PEEK, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null);
-		dataSegmentKey.runCommand(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-	
-	@Override
-	public void quickPeek(Receiver receiver, CodeSegment cs) {
-		peek(receiver, cs);
-	}
-
-
-	@Override
-	public void remove(String key) {
-		DataSegmentKey dataSegmentKey = getDataSegmentKey(key);
-		Command cmd = new Command(CommandType.REMOVE, null, key, null, 0, 0, replyQueue, null, null);
-		dataSegmentKey.runCommand(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-	
-	@Override public void finish() {
-		System.exit(0);
-	}
-
-	@Override
-	public void close() {
-		
-	}
-
-	public void recommand(Receiver receiver, CodeSegment cs) {
-		DataSegmentKey dataSegmentKey = getDataSegmentKey(receiver.key);
-		int seq = this.seq.getAndIncrement();
-		Command cmd = new Command(receiver.type, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null);
-		dataSegmentKey.runCommand(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-		
-	}
-
-	@Override
-	public void ping(String returnKey) {
-		
-	}
-
-	@Override
-	public void response(String returnKey) {
-				
-	}
-
-	@Override
-	public void shutdown(String key) {
-		
-	}
-
-}
--- a/src/alice/datasegment/ReceiveLocalData.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-package alice.datasegment;
-
-import java.io.IOException;
-
-import org.msgpack.type.ArrayValue;
-import org.msgpack.type.Value;
-
-import alice.codesegment.SingletonMessage;
-import alice.datasegment.ReceiverData;
-
-public class ReceiveLocalData implements ReceiverData {
-	private Object obj;
-
-	public ReceiveLocalData(Object obj2) {
-		this.obj = obj2;
-	}
-
-	public String asString() {
-		return (String) obj;
-	}
-
-	public int asInteger() {
-		return (Integer) obj;
-	}
-
-	public Float asFloat() {
-		return (Float) obj;
-	}
-
-	public ArrayValue asArray(){
-		return (ArrayValue) obj;
-	}
-	
-	@SuppressWarnings("unchecked")
-	public <T> T asClass(Class<T> clazz) {
-		return (T) obj;
-
-	}
-
-	@Override
-	public Value getVal() {
-		try {
-			return SingletonMessage.getInstance().unconvert(obj);
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	@Override
-	public Object getObj() {
-		return obj;
-	}
-
-}
--- a/src/alice/datasegment/ReceiveRemoteData.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-package alice.datasegment;
-
-import java.io.IOException;
-
-import org.msgpack.type.ArrayValue;
-import org.msgpack.type.Value;
-import org.msgpack.type.ValueType;
-
-import alice.codesegment.SingletonMessage;
-
-public class ReceiveRemoteData implements ReceiverData {
-	public Value val;
-
-	public ReceiveRemoteData() {
-	}
-
-	public ReceiveRemoteData(Value val2) {
-		this.val = val2;
-	}
-
-	public String asString() {
-		if (val.getType() == ValueType.RAW) {
-			return val.asRawValue().getString();
-		}
-		return null;
-	}
-
-	public int asInteger() {
-		if (val.getType() == ValueType.INTEGER) {
-			return val.asIntegerValue().getInt();
-		}
-		return 0;
-	}
-
-	public Float asFloat() {
-		if (val.getType() == ValueType.FLOAT) {
-			return val.asFloatValue().getFloat();
-		}
-		return 0.0f;
-	}
-
-	public ArrayValue asArray(){
-		if (val.getType() == ValueType.ARRAY){
-			return val.asArrayValue();
-		}
-		return null;
-	}
-	
-	public <T> T asClass(Class<T> clazz) {
-		try {
-			return SingletonMessage.getInstance().convert(val, clazz);
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		return null;
-
-	}
-
-	@Override
-	public Value getVal() {
-		return val;
-	}
-
-	@Override
-	public Object getObj() {
-		return val;
-	}
-	
-}
\ No newline at end of file
--- a/src/alice/datasegment/Receiver.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-package alice.datasegment;
-
-
-import alice.codesegment.InputDataSegment;
-
-/**
- * MessagePack implementation and DataSegment Receiver
- * @author kazz
- *
- */
-public class Receiver {
-	private ReceiverData data = new ReceiveRemoteData();
-	public InputDataSegment ids;
-	public int index;
-	public String from;
-	public CommandType type;
-	public String managerKey;
-	public String key;
-
-	public Receiver(InputDataSegment ids, CommandType type) {
-		this.ids = ids;
-		this.type = type;
-		ids.register();
-		
-	}
-	
-	public void setQuickKey(String managerKey, String key){
-		setQuickKey(managerKey, key, 0);
-	}
-	
-	public void setQuickKey(String managerKey, String key, int index) {
-		this.managerKey = managerKey;
-		this.key = key;
-		switch (type) {
-		case PEEK:
-			ids.quickPeek(this);
-			break;
-		case TAKE:
-			ids.quickTake(this);
-			break;
-		default:
-			break;
-		}
-		ids.setKey();
-	}
-	
-	public void setKey(String managerKey, String key) {
-		setKey(managerKey, key, 0);
-	}
-
-	public void setKey(String managerKey, String key, int index) {
-		this.managerKey = managerKey;
-		this.key = key;
-		this.index = index;
-		switch (type) {
-		case PEEK:
-			ids.peek(this);
-			break;
-		case TAKE:
-			ids.take(this);
-			break;
-		default:
-			break;
-		}
-		ids.setKey();
-	}
-	
-	public void setKey(String key) {
-		setKey(key, 0);
-	}
-
-	public void setKey(String key, int index) {
-		this.key = key;
-		this.index = index;
-		switch (type) {
-		case PEEK:
-			ids.peek(this);
-			break;
-		case TAKE:
-			ids.take(this);
-			break;
-		default:
-			break;
-		}
-		ids.setKey();
-	}
-
-	public void setData(ReceiverData r) {
-		data = r;
-	}
-
-	public int asInteger() {
-		return data.asInteger();
-	}
-
-	public String asString() {
-		return data.asString();
-	}
-	
-	public <T> T asClass(Class<T> clazz) {
-		return data.asClass(clazz);
-	}
-	
-	public Object getObj() {
-		return data.getObj();
-	}
-
-	public Object getVal() {
-		return data.getVal();
-	}
-	
-}
--- a/src/alice/datasegment/ReceiverData.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-package alice.datasegment;
-
-import org.msgpack.type.ArrayValue;
-import org.msgpack.type.Value;
-
-public interface ReceiverData {
-
-	public String asString();
-	public int asInteger();
-	public Float asFloat() ;
-	public ArrayValue asArray();
-	public <T> T asClass(Class<T> clazz);
-	public Value getVal();
-	public Object getObj();
-	
-}
\ No newline at end of file
--- a/src/alice/datasegment/RemoteDataSegmentManager.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-package alice.datasegment;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.channels.SocketChannel;
-
-import org.apache.log4j.Logger;
-
-import alice.codesegment.CodeSegment;
-import alice.daemon.Connection;
-import alice.daemon.IncomingTcpConnection;
-import alice.daemon.OutboundTcpConnection;
-import alice.topology.HostMessage;
-import alice.topology.manager.reconnection.SendError;
-
-public class RemoteDataSegmentManager extends DataSegmentManager {
-	
-	Connection connection;
-	Logger logger;
-	
-	public RemoteDataSegmentManager(String connectionKey, final String reverseKey, final String hostName, final int port, final boolean rFlag) {
-		logger = Logger.getLogger(connectionKey);
-		connection = new Connection();
-		final RemoteDataSegmentManager manager = this;
-		new Thread(replyThread, "RemoteDataSegmentManager-" + connectionKey).start();
-		new Thread("Connect-" + connectionKey) {
-			public void run() {
-				boolean connect = true;
-				do {
-					try {
-						SocketChannel sc = SocketChannel.open(new InetSocketAddress(hostName, port));
-						connection.socket = sc.socket();
-						connection.socket.setTcpNoDelay(true);
-						connect = false;
-						logger.info("Connect to " + connection.getInfoString());
-					} catch (IOException e) {
-						try {
-							Thread.sleep(50);
-						} catch (InterruptedException e1) {
-							e1.printStackTrace();
-						}
-					}
-				} while (connect&&!rFlag);
-				new IncomingTcpConnection(connection, manager, reverseKey).start();
-				new OutboundTcpConnection(connection).start();
-				// if connection failed need to stop these thread 
-				if (connect){
-					new SendError(new HostMessage(hostName, port)).execute();
-				}
-			}
-		}.start();
-	}
-	
-	/**
-	 * send put command to target DataSegment
-	 */
-	@Override
-	public void put(String key, Object val) {
-		Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, null, null, null);
-		connection.sendCommand(cmd); // put command on the transmission thread
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-	
-	@Override
-	public void quickPut(String key, Object val) {
-		Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, null, null, null);
-		connection.write(cmd); // put command is executed right now
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-	
-	@Override
-	public void update(String key, Object val) {
-		Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null, null);
-		connection.sendCommand(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-	
-	@Override
-	public void quickUpdate(String key, Object val) {
-		Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null, null);
-		connection.write(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-
-	@Override
-	public void take(Receiver receiver, CodeSegment cs) {
-		int seq = this.seq.getAndIncrement();
-		Command cmd = new Command(CommandType.TAKE, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null);
-		seqHash.put(seq, cmd);
-		connection.sendCommand(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-	
-	public void quickTake(Receiver receiver, CodeSegment cs) {
-		int seq = this.seq.getAndIncrement();
-		Command cmd = new Command(CommandType.TAKE, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null, true);
-		seqHash.put(seq, cmd);
-		connection.write(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-
-	@Override
-	public void peek(Receiver receiver, CodeSegment cs) {
-		int seq = this.seq.getAndIncrement();
-		Command cmd = new Command(CommandType.PEEK, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null);
-		seqHash.put(seq, cmd);
-		connection.sendCommand(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-	
-	public void quickPeek(Receiver receiver, CodeSegment cs) {
-		int seq = this.seq.getAndIncrement();
-		Command cmd = new Command(CommandType.PEEK, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null, true);
-		seqHash.put(seq, cmd);
-		connection.write(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-		
-	}
-
-	@Override
-	public void remove(String key) {
-		Command cmd = new Command(CommandType.REMOVE, null, key, null, 0, 0, null, null, null);
-		connection.sendCommand(cmd);
-		if (logger.isDebugEnabled())
-			logger.debug(cmd.getCommandString());
-	}
-
-	@Override
-	public void finish() {
-		Command cmd = new Command(CommandType.FINISH, null, null, null, 0, 0, null, null, null);
-		connection.sendCommand(cmd);
-	}
-
-	@Override
-	public void close() {
-		Command cmd = new Command(CommandType.CLOSE, null, null, null, 0, 0, null, null, null);
-		connection.sendCommand(cmd);
-	}
-
-	@Override
-	public void ping(String returnKey) {
-		Command cmd = new Command(CommandType.PING, null, returnKey, null, 0, 0, null, null, null);
-		connection.write(cmd);
-	}
-	
-	@Override
-	public void response(String returnKey) {
-		Command cmd = new Command(CommandType.RESPONSE, null, returnKey, null, 0, 0, null, null, null);
-		connection.write(cmd);
-	}
-
-	@Override
-	public void shutdown(String key) {
-		connection.close();
-	}
-
-
-}
--- a/src/alice/test/codesegment/api/FlipCodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-package alice.test.codesegment.api;
-
-import alice.codesegment.CodeSegment;
-
-public class FlipCodeSegment extends CodeSegment{
-	
-	private String key;
-	public FlipCodeSegment(String _key){
-		this.key = _key;
-	}
-	
-	@Override
-	public void run() {
-		Integer num = 0;
-		ods.put(key, num);
-		
-		//System.out.println("Key is " +key);
-		new FlipTest(key);
-	}
-	
-}
--- a/src/alice/test/codesegment/api/FlipTest.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-package alice.test.codesegment.api;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class FlipTest extends CodeSegment{
-	
-	private Receiver arg1 = ids.create(CommandType.PEEK);
-	public static long t = 0;
-	public static boolean flag = false;
-	public static int count = 10000;
-	public FlipTest(String key){
-		arg1.setKey(key);
-	}
-	
-	public FlipTest(String key, int index){
-		arg1.setKey(key, index);
-	}
-
-	@Override
-	public void run() {
-		if(flag){
-			System.out.println(System.currentTimeMillis() - t +" ms");
-			System.exit(0);
-		}
-		t = System.currentTimeMillis();
-		for (int i=0;i<count;i++)
-			ods.flip(arg1);
-			//ods.put(arg1.key ,arg1.getObj());
-		flag=true;
-
-		new FlipTest(arg1.key,count);
-				
-	}
-
-
-}
--- a/src/alice/test/codesegment/api/PeekCodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-package alice.test.codesegment.api;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class PeekCodeSegment extends CodeSegment{
-	private Receiver info0 = ids.create(CommandType.PEEK);
-	public PeekCodeSegment(String key) {
-		info0.setKey(key);
-	}
-
-	@Override
-	public void run() {
-		if (StartCodeSegment.count>10000){
-			System.out.println(System.currentTimeMillis()-StartCodeSegment.t +" ms");
-			StartCodeSegment.count = 0;
-			
-			if (++StartCodeSegment.cnt>100){
-				System.exit(0);
-			}
-		} else {
-			if(StartCodeSegment.count==1)StartCodeSegment.t = System.currentTimeMillis();
-			StartCodeSegment.count++;
-		}
-		new PeekCodeSegment(info0.key);
-	}
-
-}
--- a/src/alice/test/codesegment/api/PutCodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-package alice.test.codesegment.api;
-
-import alice.codesegment.CodeSegment;
-
-public class PutCodeSegment extends CodeSegment{
-	
-	private static int count = 0;
-	
-	@Override
-	public synchronized void run() {
-		
-		int[] array = new int[1000];
-		for (int i = 0;i< 999; i++)
-			array[i] = i;
-		
-		if (count % 10 == 0)
-			System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "MB");
-		if (count >= 10000000) {
-			System.exit(0);
-		}
-		ods.put("local", "num", array);
-		count++;
-		try {
-			wait(100);
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-		}
-		new PutCodeSegment().execute();
-	}
-	
-
-}
--- a/src/alice/test/codesegment/api/StartCodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-package alice.test.codesegment.api;
-
-import java.util.Random;
-
-import alice.codesegment.CodeSegment;
-import alice.test.codesegment.local.bitonicsort.DataList;
-
-public class StartCodeSegment extends CodeSegment {
-	String[] args;
-	public static int count = 1;
-	public static int cnt = 1;
-	public static long t = 0;
-	
-	
-	public StartCodeSegment(String[] args){
-		this.args = args;
-	}
-
-	@Override
-	public void run() {
-		for (String arg : args) {
-			if ("-update".equals(arg)) {
-				UpdateCodeSegment cs1 = new UpdateCodeSegment();
-				cs1.ds1.setKey("key");
-				int[] array = new int[65536];
-				array[0] = 0;
-				ods.update("local", "key", array);
-
-			} else if ("-put".equals(arg)) {
-				new PutCodeSegment().execute();
-
-			} else if ("-take".equals(arg)) {
-				new PutCodeSegment().execute();
-				new TakeCodeSegment("num");
-
-			} else if ("-flip".equals(arg)) {
-				new FlipCodeSegment("key").execute();
-			} else if ("-peek".equals(arg)) {
-				System.out.println("start peek Test");
-				String key = "peek";
-				int size = 100000;
-				DataList list = new DataList(size);
-				Random rnd = new Random();
-				for (int cnt = 0; cnt < size; cnt++) {
-					list.table[cnt] = rnd.nextInt(100000) + 10;
-				}
-				ods.put(key, list);
-				new PeekCodeSegment(key);
-			}
-		}
-		 
-	}
-
-}
--- a/src/alice/test/codesegment/api/TakeCodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-package alice.test.codesegment.api;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class TakeCodeSegment extends CodeSegment {
-	
-	Receiver ds1 = ids.create(CommandType.TAKE);
-	
-	public TakeCodeSegment(String key){
-		this.ds1.setKey(key);
-	}	
-	@Override
-	public void run() {
-		new TakeCodeSegment(ds1.key);
-		
-	}
-}
--- a/src/alice/test/codesegment/api/TestApiAlice.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-package alice.test.codesegment.api;
-
-import alice.daemon.AliceDaemon;
-import alice.daemon.Config;
-
-public class TestApiAlice {
-
-	/**
-	 * @param args
-	 */
-	public static void main(String[] args) {
-		new AliceDaemon(new Config(args)).listen();
-		new StartCodeSegment(args).execute();
-	}
-
-}
--- a/src/alice/test/codesegment/api/UpdateCodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-package alice.test.codesegment.api;
-
-import org.msgpack.type.Value;
-import org.msgpack.type.ValueFactory;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class UpdateCodeSegment extends CodeSegment {
-	Receiver ds1 = ids.create(CommandType.PEEK);
-
-	@Override
-	public void run() {
-		UpdateCodeSegment cs1 = new UpdateCodeSegment();
-		cs1.ds1.setKey("key", ds1.index);
-		Value[] array = ((Value)ds1.getVal()).asArrayValue().getElementArray();
-		int val = array[0].asIntegerValue().getInt();
-		if (val % 10 == 0)
-			System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "MB");
-		if (val >= 10000000) {
-			System.exit(0);
-		}
-		array[0] = ValueFactory.createIntegerValue(val + 1);
-		ods.update("local", "key", array);
-	}
-
-}
--- a/src/alice/test/codesegment/local/SingletonTestCodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-package alice.test.codesegment.local;
-
-import org.msgpack.type.Value;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class SingletonTestCodeSegment extends CodeSegment {
-	Receiver arg1 = ids.create(CommandType.PEEK);
-	private static SingletonTestCodeSegment instance = new SingletonTestCodeSegment();
-	private SingletonTestCodeSegment(){}
-	
-	public static SingletonTestCodeSegment getInstance(){
-		return instance;
-	}
-	
-	@Override
-	public void run() {
-		System.out.println("type = " + arg1.type);
-		System.out.println("index = " + arg1.index);
-		System.out.println("data = " + arg1.getVal());
-		System.out.println(((Value)arg1.getVal()).getType());
-		
-		if (arg1.index == 10) {
-			System.exit(0);
-			return;
-		}
-		
-		this.recycle();
-		ods.update("local", "key2", "String data");
-	}
-
-}
--- a/src/alice/test/codesegment/local/StartCodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-package alice.test.codesegment.local;
-
-import alice.codesegment.CodeSegment;
-
-public class StartCodeSegment extends CodeSegment {
-
-	@Override
-	public void run() {
-		System.out.println("run StartCodeSegment");
-		
-		TestCodeSegment cs = new TestCodeSegment();
-		cs.arg1.setKey("key1"); // unbound datasegment key1 is created and connect to cs.
-								// cs is waiting for local.key1
-		System.out.println("create TestCodeSegment");
-		
-		ods.update("local", "key1", "String data"); // bind string data to datasegment local.key1
-													// this startup TestCodeSegment.
- 	}
-
-}
--- a/src/alice/test/codesegment/local/TestCodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-package alice.test.codesegment.local;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-import org.msgpack.type.Value;
-
-public class TestCodeSegment extends CodeSegment {
-	
-	// create input datasegment arg1
-	Receiver arg1 = ids.create(CommandType.PEEK);
-	
-	@Override
-	public void run() {
-		System.out.println("type = " + arg1.type);
-		System.out.println("index = " + arg1.index);
-		System.out.println("data = " + arg1.getVal());
-		System.out.println(((Value)arg1.getVal()).getType());
-		
-		if (arg1.index == 10) {
-			System.exit(0);
-			return;
-		}
-		
-		TestCodeSegment cs = new TestCodeSegment();
-		cs.arg1.setKey("key1", arg1.index);
-		
-		// DataSegment.get("local").update
-		ods.update("local", "key1", "String data");
-	}
-
-}
--- a/src/alice/test/codesegment/local/TestLocalAlice.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-package alice.test.codesegment.local;
-
-import alice.daemon.AliceDaemon;
-import alice.daemon.Config;
-
-public class TestLocalAlice {
-	public static void main(String args[]) {
-		new AliceDaemon(new Config(args)).listen(); // logger off
-		new StartCodeSegment().execute();
-	}
-	
-}
--- a/src/alice/test/codesegment/local/bitonicsort/DataInfo.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-package alice.test.codesegment.local.bitonicsort;
-
-import org.msgpack.annotation.Message;
-
-@Message
-public class DataInfo {
-	public int index;
-	public int ptr;
-	
-	public DataInfo(){}
-	
-	public DataInfo(int _index, int _ptr){
-		index = _index;
-		ptr = _ptr;
-	}
-}
--- a/src/alice/test/codesegment/local/bitonicsort/DataList.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-package alice.test.codesegment.local.bitonicsort;
-
-import org.msgpack.annotation.Message;
-
-@Message
-public class DataList {
-
-	public int[] table;
-	
-	public DataList(int size){
-		table = new int[size];
-	}
-	
-	public DataList(int[] numbers){
-		table = numbers;
-	}
-	
-	public DataList createDataList(int start, int size){
-		int[] table2 = new int[size];
-		int end = start+size;
-		for (int i=start,j=0;i<end;i++,j++){
-			table2[j] = table[i];
-		}
-		return new DataList(table2);
-	}
-	
-	public void swap(int i, int j){
-		int tmp = table[i]; 
-		table[i] = table[j];
-		table[j] = tmp;
-	}
-	
-	public void showData(){
-		for (int aTable : table) {
-			System.out.print(aTable + " ");
-		}
-		System.out.println();
-	}
-	
-	public void showData(int range){
-		for(int i = 0;i<range;i++){
-			System.out.print(table[i]+ " ");
-			
-		}
-		System.out.println();
-	}
-	
-	public void showSize(){
-		System.out.print("size is "+this.table.length+". ");
-	}
-	
-	public int getSize(){
-		return this.table.length;
-	}
-
-	public static void merge(DataList list1, DataList list2) {
-		int[] t1 = list1.table; 
-		int[] t2 = list2.table; 
-		int[] t0 = list1.table.clone(); // copy to avoid destroy t1
-		int i = 0, j= 0,n=0;
-        while (i< t0.length) {
-            if (n>=t1.length) { // switch to the second list
-                t1 = t2; n = 0;
-            }
-            if (j>=t2.length || t0[i] < t2[j]) { 
-                t1[n] = t0[i];  // including when  j reaches end of t2
-                i++; n++;
-            } else {
-                t1[n] = t2[j];
-                j++; n++;
-            }
-        }               
-	}
-	
-}
--- a/src/alice/test/codesegment/local/bitonicsort/LocalBitonicSort.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-package alice.test.codesegment.local.bitonicsort;
-
-import alice.daemon.AliceDaemon;
-import alice.daemon.Config;
-
-public class LocalBitonicSort {
-	public static void main(String[] args){
-		new AliceDaemon(new Config(args)).listen(); // logger off
-		
-		SortConfig conf = new SortConfig(args);
-		new SetInfo(conf).execute();
-	}
-}
--- a/src/alice/test/codesegment/local/bitonicsort/MakeData.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-package alice.test.codesegment.local.bitonicsort;
-
-import java.util.Random;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class MakeData extends CodeSegment {
-	
-	private Receiver info1 = ids.create(CommandType.PEEK);
-	private Receiver info2 = ids.create(CommandType.TAKE);
-
-	public MakeData(){
-		info1.setKey("sortconf");
-		info2.setKey("data");
-	}
-	
-	@Override
-	public void run() {
-		// This conversion over head should be remove.
-		SortConfig conf = info1.asClass(SortConfig.class);
-		DataList list = info2.asClass(DataList.class);
-		int size = conf.getLength();
-		Random rnd = new Random();
-		for (int i = 0; i < size; i++){
-			list.table[i] = rnd.nextInt(100000)+10;
-		}
-		ods.update("list", list);
-	}
-}
--- a/src/alice/test/codesegment/local/bitonicsort/RangeInfo.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-package alice.test.codesegment.local.bitonicsort;
-
-import org.msgpack.annotation.Message;
-
-@Message
-public class RangeInfo {
-	public int range;
-	public boolean lastFlag;
-	
-	public RangeInfo(){}
-	public RangeInfo(int i,boolean flag){
-		range = i;
-		lastFlag = flag;
-	}
-
-}
--- a/src/alice/test/codesegment/local/bitonicsort/SetInfo.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-package alice.test.codesegment.local.bitonicsort;
-
-import alice.codesegment.CodeSegment;
-
-public class SetInfo extends CodeSegment {
-
-	private SortConfig conf;
-	public static String[] range;
-	public static String[] array;
-	public static String[] count;
-	
-	public SetInfo(SortConfig conf) {
-		this.conf = conf;
-	}
-
-	@Override
-	public void run() {
-		ods.put("sortconf", conf);
-		ods.put("data", new DataList(conf.length));
-		// sortconf and datasegments should be passed directory.
-		
-		create_keys();
-		new MakeData();
-		new SetTask();
-	}
-
-	private void create_keys() {
-		range = new String[conf.length];
-		array = new String[conf.length];
-		count = new String[conf.length];
-		
-		for(int i = 0 ; i < conf.length ; i++) {
-			range[i] = "range" + i;
-			array[i] = "array" + i;
-			count[i] = "count" + i;
-		}
-		
-	}
-	
-}
--- a/src/alice/test/codesegment/local/bitonicsort/SetTask.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-package alice.test.codesegment.local.bitonicsort;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class SetTask extends CodeSegment {
-	public static long t;
-	private Receiver info1 = ids.create(CommandType.PEEK);
-	private Receiver info2 = ids.create(CommandType.TAKE);
-	
-	SetTask(){
-		info1.setKey("sortconf");
-		info2.setKey("list");
-	}
-	
-	@Override
-	public void run() {
-		SortConfig conf = info1.asClass(SortConfig.class);
-		DataList list = info2.asClass(DataList.class);
-		
-		int sort_count = conf.getSplitNum()*2;
-		ods.put("sort_count", sort_count*2);
-	
-		int block_num = (conf.getLength() + sort_count- 1) / sort_count;
-		ods.put("block_num", block_num);
-		
-		System.out.println("sort start");
-		t = System.currentTimeMillis();
-		{
-			int i;
-			for (i = 0; i < sort_count / 2; i++) {
-				// anonymous datasegmaents should be used.
-				ods.put(SetInfo.range[i], new RangeInfo(i,i==(sort_count/2)-1));
-				ods.update(SetInfo.array[i*2], list.createDataList(i*2*block_num, block_num));
-				ods.update(SetInfo.array[i*2+1], list.createDataList((i*2+1)*block_num, block_num));
-				ods.update(SetInfo.count[i], 0);
-				new SortPhase(SetInfo.range[i],SetInfo.array[i*2],SetInfo.array[i*2+1],0,SetInfo.count[i]);
-				
-			}
-			new ShowData(i*2, sort_count);
-			
-		}
-		
-		
-	}
-
-}
--- a/src/alice/test/codesegment/local/bitonicsort/ShowData.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-package alice.test.codesegment.local.bitonicsort;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class ShowData extends CodeSegment{
-	
-	private Receiver[] info;
-	
-	public ShowData(int cnt, int index) {
-		info = new Receiver[cnt];
-		for (int i= 0;i < cnt; i++)
-			info[i] = ids.create(CommandType.PEEK);
-		for (int i= 0;i < cnt; i++)
-			info[i].setKey(SetInfo.array[i],index);
-		
-	}
-	
-	@Override
-	public void run() {
-		System.out.println(System.currentTimeMillis() -SetTask.t +" ms");
-		int size = 0;
-		for (Receiver anInfo : info) {
-			DataList dlist = anInfo.asClass(DataList.class);
-			size += dlist.table.length;
-		}
-		
-		DataList list = new DataList(size);
-		
-		int start = 0;
-		for (Receiver anInfo : info) {
-			DataList dlist = anInfo.asClass(DataList.class);
-			System.arraycopy(dlist.table, 0, list.table, start, dlist.table.length);
-			start += dlist.table.length;
-		}
-		System.out.println("size check :"+ list.table.length);
-		Sort.check(list);
-		System.exit(0);
-	}
-	
-	
-}
--- a/src/alice/test/codesegment/local/bitonicsort/Sort.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-package alice.test.codesegment.local.bitonicsort;
-
-public class Sort {
-	
-	// this method has "stack overflow" problem
-	public static void quickSort(DataList data){
-		int[] stack = new int[8192];
-		int sp = 0;
-		int begin = 0;
-		int end = data.table.length-1; // index is up to length-1
-		while(true){
-			while(begin < end){
-				if (end-begin< 40){
-					bubbleSort(data,begin,end);
-					break;
-				} else {
-					int where = (begin+end)/2;
-					int pivot = data.table[where];
-					data.table[where] = data.table[begin];
-					int p = begin;
-					for (int i=begin+1;i<=end;i++){
-						if (data.table[i]<pivot){
-							p++;
-							if (i!=p)data.swap(p,i);
-						}
-					}
-					data.table[begin] = data.table[p];
-					data.table[p] = pivot;
-					stack[sp++] = p+1;
-					stack[sp++] = end;
-					end=p-1;
-				}
-			}
-			if (sp==0) return;
-			end = stack[--sp];
-			begin = stack[--sp];
-			
-		}
-	}
-	
-	public static void bubbleSort(DataList data ,int begin,int end){
-		for (int i=begin;i<end;i++){
-			for (int j=end;j>i;j--){
-				if (data.table[i] > data.table[j]){
-					data.swap(i,j);
-				}
-			}
-		}
-		
-		
-	}
-	
-	public static void check(DataList data){
-		System.out.println("checking ....");
-		for (int i = 0; i< data.table.length-1; i++){
-			if (data.table[i] > data.table[i+1]){
-				System.out.println("MISS "+data.table[i]+" > "+data.table[i+1]+" Position is "+i);
-				return;
-			}
-		}
-		System.out.println("sort is succeed");
-	}
-}
--- a/src/alice/test/codesegment/local/bitonicsort/SortConfig.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-package alice.test.codesegment.local.bitonicsort;
-
-import org.msgpack.annotation.Message;
-
-@Message
-public class SortConfig {
-	public int length = 1200;
-	public int MAX_BLOCK_SIZE = 1024;
-	public int cpu = 1;
-	
-	public SortConfig(){}
-	
-	public SortConfig(String[] args){
-		for (int i=0;i<args.length; i++){
-			if ("-l".equals(args[i])){
-				length = Integer.parseInt(args[++i]);	
-			} else if ("-b".equals(args[i])){
-				MAX_BLOCK_SIZE = Integer.parseInt(args[++i]);	
-			}
-		}
-		if (length<MAX_BLOCK_SIZE) MAX_BLOCK_SIZE = length;
-	}
-
-	public int getLength() {
-		return length;
-	}
-
-	public int getblockSize() {
-		return MAX_BLOCK_SIZE;
-	}
-	
-	public int getSplitNum(){
-		if (length / cpu < MAX_BLOCK_SIZE){
-			return cpu;
-		} else {
-			return (length + MAX_BLOCK_SIZE -1) / MAX_BLOCK_SIZE;
-		}
-	}
-}
--- a/src/alice/test/codesegment/local/bitonicsort/SortPhase.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-package alice.test.codesegment.local.bitonicsort;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class SortPhase extends CodeSegment{
-	private Receiver info0 = ids.create(CommandType.PEEK); // range
-	private Receiver info1 = ids.create(CommandType.TAKE); // Array1
-	private Receiver info2 = ids.create(CommandType.TAKE); // Array2
-	private Receiver info3 = ids.create(CommandType.PEEK); // sort_count
-	private Receiver info4 = ids.create(CommandType.TAKE); // count
-	
-	
-	public SortPhase(String key0, String key1, String key2, int index, String key4){
-		info0.setKey(key0);
-		info1.setKey(key1,index);
-		info2.setKey(key2,index);
-		info3.setKey("sort_count");
-		info4.setKey(key4);
-	}
-	
-	@Override
-	public void run() {
-		RangeInfo info = info0.asClass(RangeInfo.class);
-		DataList list1 = info1.asClass(DataList.class);
-		DataList list2 = info2.asClass(DataList.class);
-		int sort_count = info3.asInteger();
-		int count = info4.asInteger();
-		
-		int i = info.range;
-		//System.out.println("CS"+i+" "+info1.key+" "+info2.key+" dataIndex "+info1.index +" count "+count);
-		Sort.quickSort(list1);
-		Sort.quickSort(list2);
-		DataList.merge(list1,list2);
-		
-		if (count%2==0&&i==0){
-			ods.flip(info1); // first block index is less than others. So put data twice.
-		} else if (count%2==0&&info.lastFlag){
-			ods.flip(info2); // Same reason 
-		}
-		
-		ods.flip(info1);
-		ods.flip(info2);
-		
-		if (count%2==0&&info.lastFlag&&count+2<sort_count/2){
-			new SortPhase(info0.key, info1.key, info2.key,count+2,info4.key);
-			ods.update(info4.key, count+2);
-		} else {
-			String f = (count%2==1) ? SetInfo.array[2*i] : SetInfo.array[2*i+1];
-			String b = (count%2==1) ? SetInfo.array[2*i+1] : SetInfo.array[2*i+2];
-			
-			new SortPhase(info0.key, f, b, count+1, info4.key);
-			ods.update(info4.key, count+1);
-		}
-		
-		
-	}
-	
-}
--- a/src/alice/test/codesegment/local/bitonicsort/SortTest.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-package alice.test.codesegment.local.bitonicsort;
-
-import java.util.Random;
-
-public class SortTest {
-	
-	public static void main(String args[]){
-		int size1 = 1000000;
-		int size2 = 1000;
-		int MAX = 1000000;
-		long t;
-		DataList list1 = new DataList(size1);
-		DataList list2 = new DataList(size1);
-		DataList list3 = new DataList(size2);
-		
-		Random rnd = new Random();
-		for (int i = 0; i < size1; i++){
-			int num = rnd.nextInt(MAX)+10;
-			list1.table[i] = num;
-			list2.table[i] = num;
-		}
-		for (int i = 0; i < size2; i++){
-			int num = rnd.nextInt(MAX)+10;
-			list3.table[i] = num;
-		}
-		
-		// bubbleSort
-		t = System.currentTimeMillis();
-		Sort.bubbleSort(list3,0,list3.table.length-1);
-		System.out.println("bubble sort : "+ (System.currentTimeMillis()-t)+" ms");
-		Sort.check(list3);
-		
-		// quickSort
-		t = System.currentTimeMillis();
-		Sort.quickSort(list1);
-		System.out.println("quick sort1 : "+ (System.currentTimeMillis()-t)+" ms");
-		Sort.check(list1);
-		
-		t = System.currentTimeMillis();
-		Sort.quickSort(list2);
-		System.out.println("quick sort2 : "+ (System.currentTimeMillis()-t)+" ms");
-		Sort.check(list2);
-		
-		// merge Test
-	    DataList.merge(list1, list2);
-	    Sort.check(list1);
-	    Sort.check(list2);
-	    
-	    // separate Test
-	    list1.showData(50);
-	    list1.createDataList(0, 25).showSize();
-	    list1.createDataList(0, 25).showData();
-	    list1.createDataList(25, 25).showData();
-	}
-}
--- a/src/alice/test/codesegment/local/wordcount/CorrectResult.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-package alice.test.codesegment.local.wordcount;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class CorrectResult extends CodeSegment{
-
-	private Receiver[] array;
-	
-	public CorrectResult(int size) {
-		array = new Receiver[size];
-		for (int i=0;i<size;i++){
-			array[i] = ids.create(CommandType.TAKE);
-		}
-		for (int i=0;i<size;i++)
-			array[i].setKey("result");
-	}
-
-	@Override
-	public void run() {
-		int line_num = 0;
-		int word_num = 0;
-		Result result;
-		for (Receiver anArray : array) {
-			result = anArray.asClass(Result.class);
-			line_num += result.line_num;
-			word_num += result.word_num;
-		}
-		System.out.println(System.currentTimeMillis() - StartWordCount.t);
-		System.out.println(line_num+" "+word_num);
-		System.exit(0);
-		
-	}
-
-}
--- a/src/alice/test/codesegment/local/wordcount/Range.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-package alice.test.codesegment.local.wordcount;
-
-public class Range {
-
-	public char[] array;
-	public char nextchar;
-	
-	public Range(int size){
-		this.array = new char[size];
-	}
-
-	public Range(char[] _array) {
-		this.array = _array;
-	}
-
-}
--- a/src/alice/test/codesegment/local/wordcount/ReadFileTest.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-package alice.test.codesegment.local.wordcount;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-public class ReadFileTest {
-	
-	public static void main(String[] args){
-		WordConfig conf = new WordConfig(args);
-		BufferedReader br = null;
-		int i = 0;
-		try {
-			br= new BufferedReader(
-					new InputStreamReader(
-							new FileInputStream(
-									new File(conf.filename)
-									)));
-			int size = 4; // Kbyte
-			
-			Range range = new Range(size);
-			int check = br.read(range.array);
-			for (;check!=-1;i++){
-			
-				char[] array;
-				array = new char[size];
-				check = br.read(array);
-				range.nextchar = array[0];
-				System.out.print(range.array); // ods
-				System.out.println(range.nextchar);
-				range = new Range(array);
-			} 
-			System.out.println(i);
-		} catch (FileNotFoundException e) {
-			System.out.println("file was not found");
-			System.exit(1);
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-		
-	}
-}
--- a/src/alice/test/codesegment/local/wordcount/Result.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-package alice.test.codesegment.local.wordcount;
-
-import org.msgpack.annotation.Message;
-
-@Message
-public class Result {
-	public int line_num;
-	public int word_num;
-	
-	public Result(int line,int word){
-		line_num = line;
-		word_num = word;
-	}
-}
--- a/src/alice/test/codesegment/local/wordcount/SeparateArray.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-package alice.test.codesegment.local.wordcount;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import alice.codesegment.CodeSegment;
-
-public class SeparateArray extends CodeSegment{
-	private WordConfig conf;
-	
-	SeparateArray(WordConfig conf){
-		this.conf = conf;
-	}
-	
-	@Override
-	public void run() {	
-		// cpu分だけTaskをあらかじめ作成
-	 	int cpu_num = Runtime.getRuntime().availableProcessors();
-	 	for (int cnt =0;cnt < cpu_num;cnt++){
-	 		new WordCount();
-	 	}
-		BufferedReader br = null;
-		int i = 0;
-		try {
-			br= new BufferedReader(
-					new InputStreamReader(
-							new FileInputStream(
-									new File(conf.filename)
-									)));
-			int size = conf.division * 1024; // Kbyte
-			Range range = new Range(size);
-			int check = br.read(range.array);
-			for (;check!=-1;i++){			
-				char[] array;
-				array = new char[size];
-				check = br.read(array);
-				range.nextchar = array[0];
-				ods.put("array", range);
-				range = new Range(array);
-			} 
-			new CorrectResult(i);
-		} catch (FileNotFoundException e) {
-			System.exit(1);
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
-
-}
--- a/src/alice/test/codesegment/local/wordcount/StartWordCount.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-package alice.test.codesegment.local.wordcount;
-
-import alice.daemon.AliceDaemon;
-import alice.daemon.Config;
-
-
-public class StartWordCount {
-	public static long t = System.currentTimeMillis();
-	public static void main(String[] args){
-		
-		new AliceDaemon(new Config(args)).listen(); // logger off
-		
-		WordConfig conf = new WordConfig(args);
-		new SeparateArray(conf).execute();
-	}
-}
--- a/src/alice/test/codesegment/local/wordcount/WordConfig.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-package alice.test.codesegment.local.wordcount;
-
-public class WordConfig {
-	public String filename;
-	public static String[] array;
-	public int division = 16;
-	
-	public WordConfig(String[] args) {
-		for (int i=0;i<args.length; i++){
-			if ("-f".equals(args[i])){
-				filename = args[++i];	
-			} else if ("-d".equals(args[i])){
-				division = Integer.parseInt(args[++i]);	
-			}
-		}
-		
-		if (filename==null){
-			System.out.println("Usage: WordCount -f FILENAME");
-			System.exit(0);
-		}
-	}
-
-}
--- a/src/alice/test/codesegment/local/wordcount/WordCount.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-package alice.test.codesegment.local.wordcount;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class WordCount extends CodeSegment{
-	
-	private Receiver info1 = ids.create(CommandType.TAKE);
-	
-	public WordCount(){
-		info1.setKey("array");
-	}
-
-	@Override
-	public void run() {
-		Range r = info1.asClass(Range.class);
-		int word_flag = 0;
-	    int word_num = 0;
-	    int line_num = 0;
-	    int i = 0;
-		for (; i < r.array.length; i++) {
-			if (r.array[i] == 0x20) { // 空白                                                                                                                                
-				word_flag = 1;
-			} else if (r.array[i] == 0x0A) { // 改行
-				line_num += 1;
-				word_flag = 1;
-			} else {
-				word_num += word_flag;
-				word_flag = 0;
-			}
-		}
-		word_num += word_flag;
-		if (r.nextchar!='\0'){ // null means last block
-			if ((r.array[i-1] == 0x0A||r.array[i-1] == 0x20) &&
-					(r.nextchar == 0x0A||r.nextchar == 0x20)){
-				word_num--;
-			}
-		}
-		
-		Result result = new Result(line_num,word_num);
-		ods.put("result", result);
-		recycle();//new WordCount();
-		
-	}
-
-}
--- a/src/alice/test/codesegment/remote/RemoteIncrement.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-package alice.test.codesegment.remote;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class RemoteIncrement extends CodeSegment {
-
-	public Receiver num = ids.create(CommandType.TAKE);
-	
-	/**
-	 * Increment DataSegment value up to 10
-	 */
-	@Override
-	public void run() {
-		int num = this.num.asInteger();
-		System.out.println("[CodeSegment] " + num++);
-		if (num == 10) System.exit(0);
-
-		RemoteIncrement cs = new RemoteIncrement();
-		cs.num.setKey("remote", "num");
-		
-		ods.put("local", "num", num);
-	}
-
-}
--- a/src/alice/test/codesegment/remote/RemoteStartCodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-package alice.test.codesegment.remote;
-
-import alice.codesegment.CodeSegment;
-
-public class RemoteStartCodeSegment extends CodeSegment {
-	
-	@Override
-	public void run() {
-		RemoteIncrement cs = new RemoteIncrement();
-		cs.num.setKey("remote", "num");
-		
-		ods.put("local", "num", 0);
-	}
-
-}
--- a/src/alice/test/codesegment/remote/TestRemoteAlice.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-package alice.test.codesegment.remote;
-
-import alice.daemon.AliceDaemon;
-import alice.datasegment.DataSegment;
-
-public class TestRemoteAlice {
-
-	public static void main(String[] args) {
-		TestRemoteConfig conf = new TestRemoteConfig(args);
-
-		new AliceDaemon(conf).listen();
-		DataSegment.connect(conf.key, "", conf.hostname, conf.connectPort, false);
-		new RemoteStartCodeSegment().execute();
-	}
-
-}
--- a/src/alice/test/codesegment/remote/TestRemoteConfig.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-package alice.test.codesegment.remote;
-
-import alice.daemon.Config;
-
-public class TestRemoteConfig extends Config {
-
-	public String hostname;
-	public int connectPort = 10000;
-	public String key;
-
-	public TestRemoteConfig(String[] args) {
-		super(args);
-		for (int i = 0; i< args.length; i++) {
-			if ("-h".equals(args[i])) {
-				hostname = args[++i];
-			} else if ("-cp".equals(args[i])) {
-				connectPort = Integer.parseInt(args[++i]);
-			} else if ("-key".equals(args[i])) {
-				key = args[++i];
-			}
-		}
-	}
-
-}
--- a/src/alice/test/concurrent/AliceConcurrentTest.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-package alice.test.concurrent;
-
-public class AliceConcurrentTest {
-
-	public static void main(String args[]) {
-		
-		int count = 1;
-		
-		for (int i = 0; i< args.length; i++) {
-			if ("-c".equals(args[i])) {
-				count = Integer.parseInt(args[++i]);
-			}
-		}
-		
-		new StartConcurrent(count).execute();
-	}
-	
-}
--- a/src/alice/test/concurrent/AliceFinish.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-package alice.test.concurrent;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class AliceFinish extends CodeSegment {
-
-	private int num;
-	
-	public Receiver ds1 = ids.create(CommandType.TAKE);
-	
-	public AliceFinish(int threadNum) {
-		this.num = threadNum; 
-	}
-
-	@Override
-	public void run() {
-		if (--num == 0) System.exit(0);
-		
-		AliceFinish cs1 = new AliceFinish(num);
-		cs1.ds1.setKey("finish");
-	}
-	
-}
--- a/src/alice/test/concurrent/SleepCodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-package alice.test.concurrent;
-
-import org.msgpack.type.ValueFactory;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class SleepCodeSegment extends CodeSegment {
-
-	public Receiver ds1 = ids.create(CommandType.TAKE);
-	
-	private int num;
-	
-	public SleepCodeSegment(int i) {
-		this.num = i;
-	}
-
-	@Override
-	public void run() {
-		try {
-			Thread.sleep(1000);
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-		}
-		System.out.println("[CodeSegment-" + num + "] Hello, World!");
-		
-		ods.put("local", "finish", ValueFactory.createNilValue());
-	}
-
-}
--- a/src/alice/test/concurrent/StartConcurrent.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-package alice.test.concurrent;
-
-import org.msgpack.type.ValueFactory;
-
-import alice.codesegment.CodeSegment;
-
-public class StartConcurrent extends CodeSegment {
-
-	private int count;
-	
-	public StartConcurrent(int count) {
-		this.count = count;
-	}
-
-	@Override
-	public void run() {
-		int threadNum = Runtime.getRuntime().availableProcessors() * count;
-		
-		AliceFinish cs1 = new AliceFinish(threadNum);
-		cs1.ds1.setKey("finish");
-		
-		for (int i = 0; i < threadNum; i++) {
-			SleepCodeSegment cs2 = new SleepCodeSegment(i);
-			cs2.ds1.setKey("wait");
-		}
-		
-		for (int i = 0; i < threadNum; i++) {
-			ods.put("local", "wait", ValueFactory.createNilValue());
-		}
-	}
-	
-}
--- a/src/alice/test/reflection/CSTemplate.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-package alice.test.reflection;
-
-import alice.codesegment.CodeSegment;
-
-public class CSTemplate extends CodeSegment{
-
-	public CSTemplate(){
-		
-	}
-	
-	@Override
-	public void run() {
-		
-	}
-
-}
--- a/src/alice/test/reflection/ReflectionTest.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-package alice.test.reflection;
-
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.CtConstructor;
-import javassist.CtField;
-import javassist.CtMethod;
-
-public class ReflectionTest {
-
-	public static void main(String[] args){
-		try {
-			new ReflectionTest().createCS();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		System.out.println("TEST END");
-	}
-
-	public void createCS() throws Exception{
-		
-		ClassPool cp = ClassPool.getDefault();
-		CtClass tep = cp.get("alice.test.reflection.CSTemplate");
-		CtClass rec = cp.get("alice.datasegment.Receiver");
-
-		// ---- define Field -----
-		//CtField f1 = CtField.make("alice.datasegment.Receiver arg1 = ids.create(alice.datasegment.CommandType.PEEK);", tep);
-		//tep.addField(f1);
-		CtField f1 = new CtField(rec,"arg1",tep);
-		tep.addField(f1,"ids.create(alice.datasegment.CommandType.PEEK)");
-
-		// ---- define Constructor -----
-		CtConstructor c = tep.getConstructor("()V");
-		c.insertAfter("arg1.setKey(\"key1\");");
-
-		// ---- define run -----
-		CtMethod m = tep.getMethod("run", "()V");
-		m.insertAfter("System.out.println(\"type = \" + arg1.type);");
-		m.insertAfter("System.out.println(\"index = \" + arg1.index);");
-		m.insertAfter("System.out.println(\"data = \" + arg1.getVal());");
-		m.insertAfter("System.out.println(((org.msgpack.type.Value)arg1.getVal()).getType());");
-		m.insertAfter("if (arg1.index==10){ System.exit(0);}");
-		m.insertAfter("new alice.test.reflection.CSTemplate();");
-		m.insertAfter("ods.update(\"key1\", \"String Data\");");
-
-		Class<?> clazz = tep.toClass(); // load Class 
-		@SuppressWarnings("unused")
-		CSTemplate cs = (CSTemplate)clazz.newInstance(); // create instance
-		
-	}
-}
--- a/src/alice/test/topology/aquarium/AutoIncrement.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-package alice.test.topology.aquarium;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class AutoIncrement extends CodeSegment {
-	
-	private Receiver position = ids.create(CommandType.PEEK);
-	private Receiver number = ids.create(CommandType.PEEK);
-	private static final float MIN = -1.3f;
-	
-	public AutoIncrement(String key, int index) {
-		this.number.setKey("maxsize");
-		this.position.setKey(key, index);
-	}
-
-	@Override
-	public void run() {
-		float max = this.number.asInteger() * 2 - 1 + 0.3f;
-		FishPoint fp = this.position.asClass(FishPoint.class);
-		if (fp.getX() + 0.01 > max) {
-			fp.setXYZ(MIN, fp.getY(), fp.getZ());
-		} else if (fp.getX() + 0.01 < MIN) {
-			fp.setXYZ(max, fp.getY(), fp.getZ());
-		}
-		else {
-			fp.setXYZ(fp.getX() + 0.01f, fp.getY(), fp.getZ());
-		}
-		
-		ods.update(position.key, fp);
-		synchronized (this) {
-			try {
-				// TODO
-				// Waiting should be done in Alice kernel
-				// ids.create(CommandType.WAIT);
-			 
-				wait(20);
-			} catch (InterruptedException e) {
-				e.printStackTrace();
-			}
-		}
-		
-		new AutoIncrement(this.position.key, this.position.index);
-	}
-	
-}
--- a/src/alice/test/topology/aquarium/CheckLocalIndex.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-package alice.test.topology.aquarium;
-
-import java.util.List;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class CheckLocalIndex extends CodeSegment {
-
-	private Receiver data = ids.create(CommandType.PEEK);
-	private Receiver list = ids.create(CommandType.PEEK);
-	
-	public CheckLocalIndex(String key, int index){
-		this.list.setKey("_CLIST");
-		this.data.setKey(key, index);
-	}
-	
-	@Override
-	public void run() {
-		@SuppressWarnings("unchecked")
-		List<String> r = list.asClass(List.class);
-		for (String node : r) {
-			if (!node.equals(data.from)) {
-				System.out.println(data.from);
-				ods.update(node, data.key, data.getVal());
-			}
-		}
-		new CheckLocalIndex(data.key, data.index);
-		
-	}
-
-}
--- a/src/alice/test/topology/aquarium/CheckMyName.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-package alice.test.topology.aquarium;
-
-import java.util.Random;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-
-public class CheckMyName extends CodeSegment {
- 	private Receiver host = ids.create(CommandType.PEEK);
-	private Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
-	private String key = "fish";
-	
-	public CheckMyName(){
-		host.setKey("host");
-	}
-	
-	@Override
-	public void run(){
-		String name = host.asString();
-		Matcher matcher = pattern.matcher(name);
-		
-		matcher.find();
-		String type = matcher.group(1);
-		int num = new Integer(matcher.group(2));
-		ods.put("host_num", num*2);
-		MakeFrame frame =  new MakeFrame(name,num*2);
-		ods.put("num", 1);
-		
-		if (type.equals("cli")){
-			System.out.println("cli"+num);
-			new TakeMynum();	
-		}else if (type.equals("node")){
-			System.out.println("node"+num);
-			if (num != 0){
-				new TakeMynum();
-			} else {
-				new SendMaxsize(0);
-			}
-		}
-		new CheckLocalIndex("maxsize",0);
-		
-		ods.update(key, new FishPoint(-0.1f,-0.1f));
-		new SetLocation(new MakeObject(frame), key, 0);
-		new CheckLocalIndex(key,1);
-		for (int i = 0; i < 3 ; i++){
-			key = "fish"+i;
-			if (num == 0) new AutoIncrement(key,0);
-			ods.update(key, new FishPoint((float)Math.random(),
-					(float)Math.random(), (float)Math.random()));
-			new SetLocation(new MakeObject(frame), key, 0);
-			new CheckLocalIndex(key,1);
-		}
-		
-		for (int i = 3; i < 6 ; i++){
-			key = "fish"+i;
-			if (num == 1) new AutoIncrement(key,0);
-			Random rnd = new Random();
-			int tmp = rnd.nextInt(3);
-			int rand = tmp + 1;
-			ods.update(key, new FishPoint( (float)rand, 
-					-(float)Math.random(), -(float)Math.random()));
-			new SetLocation(new MakeObject(frame), key, 0);
-			new CheckLocalIndex(key,1);
-		}
-		
-		for (int i = 6; i < 9 ; i++){
-			key = "fish"+i;
-			if (num == 2) new AutoIncrement(key,0);
-			Random rnd = new Random();
-			int tmp = rnd.nextInt(3); 
-			int rand = tmp + 3;
-			ods.update(key, new FishPoint( (float)rand, 
-					(float)Math.random(), -(float)Math.random()));
-			new SetLocation(new MakeObject(frame), key, 0);
-			new CheckLocalIndex(key,1);
-		}
-		
-		for (int i = 9; i < 12 ; i++){
-			key = "fish"+i;
-			if (num == 3) new AutoIncrement(key,0);
-			
-			Random rnd = new Random();
-			int tmp = rnd.nextInt(3); 
-			int rand = tmp + 5;
-			
-			ods.update(key, new FishPoint( (float)rand, 
-					-(float)Math.random(), (float)Math.random()));
-			new SetLocation(new MakeObject(frame), key, 0);
-			new CheckLocalIndex(key,1);
-		}
-		
-	}
-}
--- a/src/alice/test/topology/aquarium/FishMovementConfig.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-package alice.test.topology.aquarium;
-
-import alice.topology.node.TopologyNodeConfig;
-
-public class FishMovementConfig extends TopologyNodeConfig {
-	
-	public FishMovementConfig(String[] args){
-		super(args);
-	} 
-	
-
-}
--- a/src/alice/test/topology/aquarium/FishMovementTopology.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-package alice.test.topology.aquarium;
-import alice.topology.node.TopologyNode;
-
-public class FishMovementTopology {
-	public static void main(String[] args){
-		FishMovementConfig conf = new FishMovementConfig(args);
-		new TopologyNode(conf, new StartFishMovement());
-		
-	}
-
-}
--- a/src/alice/test/topology/aquarium/FishPoint.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-package alice.test.topology.aquarium;
-
-import org.msgpack.annotation.Message;
-
-@Message
-public class FishPoint {
-	// public fields are serialized.
-	public float x = 0.0f;
-	public float y = 0.0f;
-	public float z = 0.0f;
-	
-	public FishPoint(){}
-	
-	public FishPoint(float x,float y){
-		this.x = x;
-		this.y = y;
-	}
-	
-	public FishPoint(float x,float y,float z){
-		this.x = x;
-		this.y = y;
-		this.z = z;
-	}
-	
-	public void setXY(float x,float y){
-		this.x = x;
-		this.y = y;
-	}
-	
-	public void setXYZ(float x,float y,float z){
-		this.x = x;
-		this.y = y;
-		this.z = z;
-	}
-	
-	public float getX(){
-		return this.x;
-	}
-	
-	public float getY(){
-		return this.y;
-	}
-	
-	public float getZ(){
-		return this.z;
-	}
-	
-}
--- a/src/alice/test/topology/aquarium/KeyInputCodeSegment.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-package alice.test.topology.aquarium;
-
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-
-public class KeyInputCodeSegment implements KeyListener{
-		
-	MakeFrame frame;
-	public KeyInputCodeSegment(MakeFrame frame) {
-		this.frame = frame;
-	}
-
-	@Override
-	public void keyPressed(KeyEvent event) {
-		//System.out.println(event.getKeyCode());
-		switch(event.getKeyCode())
-		{
-		case 37: // left
-			new SendLocation(-0.1f,0.0f,0.0f); 
-			break;
-		case 38: // up
-			new SendLocation(0.0f,0.1f,0.0f);
-			break;
-		case 39: // right
-			new SendLocation(0.1f,0.0f,0.0f);
-			break;
-		case 40: // down
-			new SendLocation(0.0f,-0.1f,0.0f);
-			break;
-		case 76: // l
-			new SendLocation(0.0f,0.0f,0.1f);
-			break;
-		case 78: // "n"
-			new RefreshWindow(frame);
-			break;
-		case 79: // "o"
-			new SendLocation(0.0f,0.0f,-0.1f);
-			break;
-		case 82: // "r"
-			new ResetFish().execute();
-			break;
-		}
-	}
-
-	@Override
-	public void keyReleased(KeyEvent event) {
-		
-	}
-
-	@Override
-	public void keyTyped(KeyEvent event) {
-		
-	}
-
-}
--- a/src/alice/test/topology/aquarium/MakeFrame.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-package alice.test.topology.aquarium;
-
-import java.awt.GraphicsConfiguration;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-import javax.imageio.ImageIO;
-import javax.media.j3d.Background;
-import javax.media.j3d.BoundingSphere;
-import javax.media.j3d.BranchGroup;
-import javax.media.j3d.DirectionalLight;
-import javax.media.j3d.ImageComponent2D;
-
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.vecmath.Color3f;
-import javax.vecmath.Point3d;
-import javax.vecmath.Vector3f;
-
-import com.sun.j3d.utils.universe.SimpleUniverse;
-
-public class MakeFrame {
-	
-	private static final int F_SIZE_X = 800;
-	private static final int F_SIZE_Y = 800;
-	private ViewChange canvas;
-	private JFrame frame;
-	private ObjectList list = new ObjectList();
-	
-	public MakeFrame(String str,float x) {
-	    System.loadLibrary("jawt"); 
-		frame = new JFrame(str);
-		frame.setSize(F_SIZE_X, F_SIZE_Y);
-		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-		
-		JPanel cp = new JPanel();
-		cp.setLayout(null);
-		frame.add(cp);
-		
-		GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
-		canvas = new ViewChange(x,0.01f,config);
-		canvas.setBounds(0,0, F_SIZE_X, F_SIZE_Y);
-		cp.add(canvas);
-		
-		canvas.universe.addBranchGraph(createLight());
-		canvas.universe.addBranchGraph(setBackground());
-		
-		canvas.addKeyListener(new KeyInputCodeSegment(this));
-		frame.setVisible(true);
-		
-	}
-	
-	private BranchGroup setBackground() {
-		BranchGroup scene = new BranchGroup();
-		BufferedImage img = null;
-		try {
-			URL url = getClass().getClassLoader().getResource("image1.jpg");
-			if (url!=null) {
-			    img = ImageIO.read(url);
-			} else {
-			    img = ImageIO.read(new File("image/image1.jpg"));
-			}
-		} catch (IOException e) {
-		  	e.printStackTrace();
-		}
-		ImageComponent2D image = 
-				new ImageComponent2D(ImageComponent2D.FORMAT_RGBA8,img);
-		Background background = new Background(image);
-		background.setImageScaleMode(Background.SCALE_FIT_ALL);
-		BoundingSphere bounds = new BoundingSphere(new Point3d(), 10.0);
-		background.setApplicationBounds(bounds);
-		scene.addChild(background);
-		return scene;
-		
-	}
-	
-	private BranchGroup createLight() {
-		BranchGroup scene = new BranchGroup();
-		Color3f light_color  = new Color3f(1.7f,1.7f,1.7f);
-		Vector3f light_direction = new Vector3f(0.0f,0.0f,-1.0f);
-		DirectionalLight light = new DirectionalLight(light_color,light_direction);
-		BoundingSphere bounds = new BoundingSphere(new Point3d(), 10.0);
-		light.setInfluencingBounds(bounds);
-		scene.addChild(light);
-		return scene;
-	}
-	
-	public void register(MakeObject obj){
-		list.table.add(obj);
-		BranchGroup group = obj.createBranch();
-		this.canvas.universe.addBranchGraph(group);
-	}
-	
-	public ViewChange getCanvas(){
-		return this.canvas;
-	}
-	
-	public JFrame getJFrame(){
-		return this.frame;
-	}
-	
-	public ObjectList getList(){
-		return this.list;
-	}
-	
-	static public void main(String [] args) {
-	    MakeFrame test = new MakeFrame("Test", 0);
-	    test.setBackground();
-	    test.createLight();
-	}
-	
-}
--- a/src/alice/test/topology/aquarium/MakeObject.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-package alice.test.topology.aquarium;
-
-import java.awt.Image;
-import java.awt.MediaTracker;
-import java.awt.Toolkit;
-import java.io.FileNotFoundException;
-import java.net.URL;
-
-import javax.media.j3d.Appearance;
-import javax.media.j3d.BranchGroup;
-import javax.media.j3d.Texture;
-import javax.media.j3d.Transform3D;
-import javax.media.j3d.TransformGroup;
-import javax.vecmath.Matrix4d;
-
-import com.sun.j3d.loaders.IncorrectFormatException;
-import com.sun.j3d.loaders.ParsingErrorException;
-import com.sun.j3d.loaders.Scene;
-import com.sun.j3d.loaders.objectfile.ObjectFile;
-
-import com.sun.j3d.utils.image.TextureLoader;
-
-public class MakeObject {
-	
-	private Transform3D transform;  
-	private TransformGroup transform_group;
-	private ViewChange canvas;
-	private Matrix4d matrix;
-	private double s;
-
-	
-	public MakeObject(MakeFrame frame){
-		this.canvas = frame.getCanvas();
-		this.s = 0.3;
-		frame.register(this);
-	}
-	
-	public BranchGroup createBranch(){
-		BranchGroup scene = new BranchGroup();
-		/*Box box = new Box(0.1f,0.1f,0.0f,
-				Box.GENERATE_NORMALS|Box.GENERATE_TEXTURE_COORDS,createAppearance());*/
-		ObjectFile obj = new ObjectFile(ObjectFile.RESIZE);
-		Scene img = null;
-		try{
-			URL url=getClass().getClassLoader().getResource("TUNA");
-			img = obj.load(url);
-		} catch(FileNotFoundException e){
-			System.err.println(e);
-			System.exit(1);
-		} catch(ParsingErrorException e){
-			System.err.println(e);
-			System.exit(1);
-		} catch(IncorrectFormatException e){
-			System.err.println(e);
-			System.exit(1);
-		}
-		
-		transform_group = new TransformGroup();
-		setLocation(-2.0f,-2.0f); //set out of window
-		transform_group.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
-		transform_group.addChild(img.getSceneGroup());
-		scene.addChild(transform_group);
-		return scene;		
-	}
-	
-	// no use method
-	public Appearance createAppearance(){
-		Appearance app = new Appearance();
-		Image image = null; 	
-		Toolkit toolkit = Toolkit.getDefaultToolkit();
-		URL url = getClass().getClassLoader().getResource("fish.jpg");
-		image = toolkit.getImage(url);
-		MediaTracker mt = new MediaTracker(canvas);
-		mt.addImage(image, 0);
-		mt.checkAll(true);
-		try {
-			mt.waitForID(0);
-			
-		}catch (InterruptedException e){
-			e.printStackTrace();
-			
-		}
-		Texture texture = new TextureLoader(image,canvas).getTexture();
-		app.setTexture(texture);
-		return app;
-		
-	}
-	
-	public void setScale(float size){
-		s = size;
-	}
-	
-	public void setLocation(float x,float y){
-		transform = new Transform3D();
-		matrix = new Matrix4d(s,0,0,x,
-							  0,s,0,y,
-							  0,0,s,0,
-							  0,0,0,1);
-		transform.set(matrix);
-		transform_group.setTransform(transform);
-	}
-	
-	public void setLocation(float x,float y,float z){
-		transform = new Transform3D();
-		matrix = new Matrix4d(s,0,0,x,
-				  			  0,s,0,y,
-				  			  0,0,s,z,
-				  			  0,0,0,1);
-		transform.set(matrix);
-		transform_group.setTransform(transform);
-	}
-	
-	
-}
-
--- a/src/alice/test/topology/aquarium/MouseViewEvent.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-package alice.test.topology.aquarium;
-
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseMotionListener;
-
-public class MouseViewEvent implements MouseMotionListener {
-	
-	int new_x, new_y;
-	int pre_x, pre_y;
-	ViewChange v;
-	
-	public MouseViewEvent(ViewChange v) {
-		this.v = v;
-		
-	}
-
-	@Override
-	public void mouseDragged(MouseEvent event) {
-		new_x = event.getX();
-		new_y = event.getY();
-		
-		v.theta -= v.sensitivity * (new_y - pre_y);
-		v.phi += v.sensitivity * (new_x - pre_x);
-		v.camera_y = v.distance * (float)Math.sin(v.theta);
-		v.camera_xz = v.distance * (float)Math.cos(v.theta);
-	
-		v.camera_x =  v.camera_xz * (float)Math.sin(v.phi);
-		v.camera_z =  v.camera_xz * (float)Math.cos(v.phi);	
-		v.Vector_camera_pos.x = v.camera_x;
-		v.Vector_camera_pos.y = v.camera_y;
-		v.Vector_camera_pos.z = v.camera_z;
-		
-		v.Transform_camera_pos.setIdentity();
-		v.Transform_camera_pos.setTranslation(v.Vector_camera_pos);
-		
-		v.Transform_camera_theta.rotX(-v.theta);
-		v.Transform_camera_phi.rotY(v.phi);
-		v.Transform_camera_phi.mul(v.Transform_camera_theta);
-		v.Transform_camera_pos.mul(v.Transform_camera_phi);
-		v.Camera.setTransform(v.Transform_camera_pos);
-		pre_x = event.getX();
-		pre_y = event.getY();
-		
-	}	
-	
-	@Override
-	public void mouseMoved(MouseEvent event) {
-		pre_x = event.getX();
-		pre_y = event.getY();	
-	}
-
-}
--- a/src/alice/test/topology/aquarium/ObjectList.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-package alice.test.topology.aquarium;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ObjectList {
-	public List<MakeObject> table = new ArrayList<MakeObject>();
-}
--- a/src/alice/test/topology/aquarium/RefreshWindow.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-package alice.test.topology.aquarium;
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class RefreshWindow extends CodeSegment {
-	private Receiver num = ids.create(CommandType.PEEK);
-	private Receiver host = ids.create(CommandType.PEEK);
-	private MakeFrame frame;
-	
-	public RefreshWindow(MakeFrame frame){
-		this.host.setKey("host");
-		this.num.setKey("host_num");
-		this.frame = frame;
-	}
-	
-	@Override
-	public void run() {
-		frame.getJFrame().dispose();
-		ObjectList list = frame.getList();
-		frame = new MakeFrame(host.asString(),num.asInteger());
-		for (MakeObject obj : list.table) {
-			frame.register(obj);
-		}
-	}
-
-}
-
--- a/src/alice/test/topology/aquarium/ResetFish.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-package alice.test.topology.aquarium;
-
-import alice.codesegment.CodeSegment;
-
-public class ResetFish extends CodeSegment {
-	
-	public ResetFish(){}
-
-	@Override
-	public void run() {
-		FishPoint fp = new FishPoint(0.0f,0.0f,0.0f);
-		ods.update("fish", fp);
-		
-	}
-
-}
--- a/src/alice/test/topology/aquarium/SendLocation.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-package alice.test.topology.aquarium;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-
-public class SendLocation extends CodeSegment {
-	
-	private Receiver position = ids.create(CommandType.PEEK);
-	float x;
-	float y;
-	float z;
-	
-	public SendLocation(float x,float y,float z){
-		this.x = x;
-		this.y = y;
-		this.z = z;
-		position.setKey("fish");
-	}
-	
-	@Override
-	public void run() {
-		FishPoint fp = this.position.asClass(FishPoint.class);
-		fp.setXYZ(fp.getX()+x, fp.getY()+y, fp.getZ()+z);
-		ods.update("fish", fp);
-		
-	}
-
-}
--- a/src/alice/test/topology/aquarium/SendMaxsize.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-package alice.test.topology.aquarium;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class SendMaxsize extends CodeSegment{
-
-	private Receiver max = ids.create(CommandType.PEEK);
-	
-	public SendMaxsize(int index){
-		this.max.setKey("num", index);
-	}
-	
-	@Override
-	public void run() {
-		int size = max.asInteger();
-		ods.update("maxsize",size);
-		new SendMaxsize(this.max.index);
-	}
-
-}
--- a/src/alice/test/topology/aquarium/SetLocation.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-package alice.test.topology.aquarium;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-
-public class SetLocation extends CodeSegment{
-	
-	private Receiver position = ids.create(CommandType.PEEK);
-	private MakeObject obj;
-	
-	public SetLocation(MakeObject obj ,String key, int index){
-		this.obj = obj;
-		this.position.setKey(key,index);
-	}
-	
-	@Override
-	public void run(){
-		FishPoint fp = this.position.asClass(FishPoint.class);
-		obj.setLocation(fp.getX(), fp.getY(), fp.getZ());
-		new SetLocation(obj, position.key, position.index);
-					
-	}
-	
-
-}
--- a/src/alice/test/topology/aquarium/StartFishMovement.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-package alice.test.topology.aquarium;
-
-import alice.codesegment.CodeSegment;
-
-public class StartFishMovement extends CodeSegment{
-	@Override
-	public void run(){
-		new CheckMyName();
-	}
-	
-
-}
--- a/src/alice/test/topology/aquarium/TakeMynum.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-package alice.test.topology.aquarium;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class TakeMynum extends CodeSegment {
-	
-	private Receiver mynum = ids.create(CommandType.TAKE);
-	
-	public TakeMynum(){
-		this.mynum.setKey("num");
-	}
-	
-	public TakeMynum(int index){
-		this.mynum.setKey("num", index);
-	}
-
-	@Override
-	public void run() {
-		new TakePnum(this.mynum);
-		ods.put("num", 0);
-		new TakeMynum(this.mynum.index+1);
-	}
-
-}
-
--- a/src/alice/test/topology/aquarium/TakePnum.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-package alice.test.topology.aquarium;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class TakePnum extends CodeSegment {
-	// this CodeSegment has bug
-	
-	private Receiver pnum = ids.create(CommandType.TAKE);
-	private Receiver mynum;
-	
-	public TakePnum(Receiver data){
-		this.pnum.setKey("parent", "num");
-		this.mynum = data;
-	}
-
-	@Override
-	public void run() {
-		ods.update("parent", "num", 
-				this.pnum.asInteger()+this.mynum.asInteger());
-	}
-
-}
--- a/src/alice/test/topology/aquarium/ViewChange.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-package alice.test.topology.aquarium;
-
-import java.awt.*;
-
-import javax.media.j3d.*;
-import javax.vecmath.*;
-import com.sun.j3d.utils.universe.*;
-
-public class ViewChange extends Canvas3D {
-
-	private static final long serialVersionUID = 1L;
-	float sensitivity;
-	float distance = 2.5f;
-	float camera_x, camera_y, camera_z, camera_xz, camera_xy, camera_yz = 0;
-	float phi =  0; // flow
-	float theta = 0;
-	
-	SimpleUniverse universe;
-	TransformGroup Camera;
-	Transform3D Transform_camera_pos;
-	Transform3D Transform_camera_phi;
-	Transform3D Transform_camera_theta;
-	Vector3f Vector_camera_pos;
-	
-	public ViewChange(float x, float Sensitivity, GraphicsConfiguration config){
-		super(config);
-		
-		sensitivity = Sensitivity;
-		universe = new SimpleUniverse(this);
-		ViewingPlatform vp = universe.getViewingPlatform();
-		Camera = vp.getViewPlatformTransform();
-
-		camera_y = distance * (float)Math.sin(theta);
-		camera_xz = distance * (float)Math.cos(theta);
-		System.out.println(x);
-		camera_x = x;
-		camera_z =  camera_xz * (float)Math.cos(phi);
-		
-		Vector_camera_pos = new Vector3f(camera_x, camera_y, camera_z);
-		Transform_camera_pos = new Transform3D();
-		Transform_camera_pos.setTranslation(Vector_camera_pos);
-		Transform_camera_phi = new Transform3D();
-		Transform_camera_theta = new Transform3D();
-		Transform_camera_theta.rotX(-theta);
-		Transform_camera_phi.rotY(phi);
-		Transform_camera_theta.mul(Transform_camera_phi);
-		Transform_camera_pos.mul(Transform_camera_theta);
-
-		Camera.setTransform(Transform_camera_pos);
-
-		addMouseMotionListener(new MouseViewEvent(this));
-		
-	}
-	
-	
-	
-}
-
--- a/src/alice/test/topology/fish/AssignStartX.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-package alice.test.topology.fish;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class AssignStartX extends CodeSegment {
-
-	public Receiver routing = ids.create(CommandType.PEEK);
-	public int startX;
-	public int index;
-
-	public AssignStartX(int startX, int index) {
-		this.startX = startX;
-		this.index = index;
-	}
-	
-	@Override
-	public void run() {
-		System.out.println("AssignStartX: " + startX);
-		
-		RoutingTable routing = this.routing.asClass(RoutingTable.class);
-		int x = startX;
-		System.out.println("RoutingTable: " + this.routing.getVal());
-		if (this.index >= this.routing.index) {
-			AssignStartX cs = new AssignStartX(startX, index);
-			cs.routing.setKey("local", "routing", this.routing.index);
-			return;
-		}
-		for (Routing r : routing.table) {
-			System.out.println(r.name);
-			ods.update(r.name, "startX", x);
-			System.out.println("Assign: " + r.name + ".startX = " + x);
-			x += r.width;
-		}
-		PeekStartX cs = new PeekStartX(this.routing.index);
-		cs.startX.setKey("local", "startX", this.index);
-	}
-
-}
--- a/src/alice/test/topology/fish/CheckMyName.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-package alice.test.topology.fish;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class CheckMyName extends CodeSegment {
-	
-	private Receiver host = ids.create(CommandType.PEEK);
-	
-	public CheckMyName(){
-		host.setKey("host");
-	}
-	
-	@Override
-	public void run() {
-		String name = host.asString();
-		Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
-		Matcher matcher = pattern.matcher(name);
-		
-		matcher.find();
-		String type = matcher.group(1);
-		int num = new Integer(matcher.group(2));
-		
-		if (type.equals("cli")) {
-			System.out.println("********************I am cli" + num);
-			ods.update("local", "width", 400);
-			
-			GetStartX cs = new GetStartX();
-			cs.startX.setKey("local", "startX");
-			
-		} else if (type.equals("node")) {
-			System.out.println("********************I am node" + num);
-			WidthReceiver cs = new WidthReceiver();
-			cs.widths.setKey("local", "widths");
-			cs.routing.setKey("local", "routing");
-			
-			PeekStartX cs2 = new PeekStartX(0);
-			cs2.startX.setKey("local", "startX");
-			
-			ods.put("local", "routing", new RoutingTable());
-			if (num == 0) { // First node ("node0") check
-				StartStartX cs3 = new StartStartX();
-				cs3.width.setKey("local", "width");
-				//ods.update("local", "startX", 0);
-				return;
-			}
-		}
-		
-		SendWidth cs = new SendWidth();
-		cs.width.setKey("local", "width");
-
-	}
-
-}
--- a/src/alice/test/topology/fish/DistributedFish.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-package alice.test.topology.fish;
-
-import alice.topology.node.TopologyNode;
-
-public class DistributedFish {
-
-	public static void main(String[] args) {
-		FishConfig conf = new FishConfig(args);
-		new TopologyNode(conf, new StartFish());
-
-	}
-
-}
--- a/src/alice/test/topology/fish/FishConfig.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-package alice.test.topology.fish;
-
-import alice.topology.node.TopologyNodeConfig;
-
-public class FishConfig extends TopologyNodeConfig {
-
-	public FishConfig(String[] args) {
-		super(args);
-		
-	}
-	
-}
--- a/src/alice/test/topology/fish/GetStartX.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-package alice.test.topology.fish;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class GetStartX extends CodeSegment {
-
-	public Receiver startX = ids.create(CommandType.PEEK);
-	
-	@Override
-	public void run() {
-		int startX = this.startX.asInteger();
-		
-		System.out.println("GetStartX: " + startX);
-		
-		GetStartX cs = new GetStartX();
-		cs.startX.setKey("local", "startX", this.startX.index);
-	}
-
-}
--- a/src/alice/test/topology/fish/PeekStartX.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-package alice.test.topology.fish;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class PeekStartX extends CodeSegment {
-
-	public Receiver startX = ids.create(CommandType.PEEK);
-	public int index;
-	
-	public PeekStartX(int index) {
-		this.index = index;
-	}
-	
-	@Override
-	public void run() {
-		int startX = this.startX.asInteger();
-		AssignStartX cs = new AssignStartX(startX, this.startX.index);
-		cs.routing.setKey("routing", this.startX.index);
-	}
-
-}
--- a/src/alice/test/topology/fish/Routing.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-package alice.test.topology.fish;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.msgpack.annotation.Message;
-import org.msgpack.annotation.Optional;
-
-@Message
-public class Routing {
-
-	public String name;
-	public int id;
-	public int width;
-	@Optional public int startX;
-	
-	public Routing() {}
-	
-	public Routing(String name, int width) {
-		this.name = name;
-		this.width = width;
-		Pattern pattern = Pattern.compile("^child([0-9]+)$");
-		Matcher matcher = pattern.matcher(name);
-		matcher.find();
-		id = new Integer(matcher.group(1));
-	}
-
-	public Routing(String name, int id, int width, int startX) {
-		this.name = name;
-		this.id = id;
-		this.width = width;
-		this.startX = startX;
-	}
-	
-}
--- a/src/alice/test/topology/fish/RoutingTable.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-package alice.test.topology.fish;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.msgpack.annotation.Message;
-
-@Message
-public class RoutingTable {
-
-	int sumWidth = 0;
-	List<Routing> table = new ArrayList<Routing>();
-	
-}
--- a/src/alice/test/topology/fish/SendWidth.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-package alice.test.topology.fish;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class SendWidth extends CodeSegment {
-	
-	Receiver width = ids.create(CommandType.PEEK);
-
-	@Override
-	public void run() {
-		int width = this.width.asInteger();
-		ods.put("parent", "widths", width);
-		
-		System.out.println("send widths: " + width);
-		
-		SendWidth cs = new SendWidth();
-		cs.width.setKey("width", this.width.index);
-	}
-
-}
--- a/src/alice/test/topology/fish/StartFish.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-package alice.test.topology.fish;
-
-import alice.codesegment.CodeSegment;
-
-public class StartFish extends CodeSegment {
-
-	@Override
-	public void run() {
-		new CheckMyName(); // separate processing
-		
-	}
-
-}
--- a/src/alice/test/topology/fish/StartStartX.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-package alice.test.topology.fish;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class StartStartX extends CodeSegment {
-	
-	public Receiver width = ids.create(CommandType.PEEK);
-	
-	@Override
-	public void run() {
-		ods.update("local", "startX", 0);
-		StartStartX cs = new StartStartX();
-		cs.width.setKey("local", "width", this.width.index);
-	}
-
-}
--- a/src/alice/test/topology/fish/WidthReceiver.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-package alice.test.topology.fish;
-
-import java.util.Collections;
-import java.util.Comparator;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class WidthReceiver extends CodeSegment {
-	
-	public Receiver widths = ids.create(CommandType.TAKE);
-	public Receiver routing = ids.create(CommandType.PEEK);	
-	
-	@Override
-	public void run() {
-		int width = this.widths.asInteger();
-		String from = this.widths.from;
-		RoutingTable routing = this.routing.asClass(RoutingTable.class);
-		Routing newRouting = new Routing(from, width);
-		boolean update = false;
-		for (Routing r : routing.table) {
-			if (r.id == newRouting.id) {
-				routing.sumWidth -= r.width;
-				routing.sumWidth += newRouting.width;
-				r.width = width;
-				update = true;
-				break;
-			}
-		}
-		if (!update) {
-			routing.table.add(newRouting);
-			Collections.sort(routing.table, new Comparator<Routing>() {
-				@Override
-				public int compare(Routing o1, Routing o2) {
-					return o1.id - o2.id;
-				}
-			});
-			routing.sumWidth += width;
-		}
-		
-		System.out.println("SUM WIDTH: " + routing.sumWidth);
-		
-		System.out.println("NODE NUM: " + routing.table.size());
-		
-		ods.update("width", routing.sumWidth);
-		ods.update("routing", routing);
-		
-		WidthReceiver cs = new WidthReceiver();
-		cs.widths.setKey("widths", this.widths.index);
-		cs.routing.setKey("routing");
-		//cs.routing.setKey("routing", this.routing.index);
-	}
-
-}
--- a/src/alice/test/topology/ring/CheckMyName.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-package alice.test.topology.ring;
-
-import org.apache.log4j.Logger;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class CheckMyName extends CodeSegment {
-
-	public Receiver ds1 = ids.create(CommandType.PEEK);
-	
-	private Logger logger = Logger.getLogger(CheckMyName.class);
-	private RingTopologyConfig conf;
-	
-	public CheckMyName(RingTopologyConfig conf) {
-		this.conf = conf;
-	}
-	
-	@Override
-	public void run() {
-		String host = this.ds1.asString();
-		logger.debug(host);
-		if (host.equals("node0")) {
-			ods.put("local", "c", new byte[conf.size]);
-			FirstRingMessagePassing cs1 = new FirstRingMessagePassing(conf.count, conf.nodeNum);
-			cs1.ds1.setKey("c");
-			RingFinish cs2 = new RingFinish("manager");
-			cs2.finish.setKey("finish");
-		} else {
-			ods.close("manager");
-			RingMessagePassing cs1 = new RingMessagePassing();
-			cs1.ds1.setKey("c");
-			RingFinish cs2 = new RingFinish("right");
-			cs2.finish.setKey("finish");
-		}
-	}
-
-}
--- a/src/alice/test/topology/ring/FirstRingMessagePassing.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-package alice.test.topology.ring;
-
-import org.msgpack.type.ValueFactory;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class FirstRingMessagePassing extends CodeSegment {
-	
-	public Receiver ds1 = ids.create(CommandType.TAKE);
-	private long startTime;
-	private int count;
-	private int nodeNum;
-	
-	public FirstRingMessagePassing(long startTime, int count, int nodeNum) {
-		this.startTime = startTime;
-		this.count = count;
-		this.nodeNum = nodeNum;
-	}
-	
-	public FirstRingMessagePassing(int count, int nodeNum) { // at first
-		this.startTime = System.nanoTime();
-		this.count = count;
-		this.nodeNum = nodeNum;
-	}
-	
-	@Override
-	public void run() {
-		ods.put("right", "c", ds1.getVal()); // copy whole DataSegment to the right
-		if (ds1.index > count) {        // after count time update of ds1
-			ods.put("right", "finish", ValueFactory.createNilValue());
-			long endTime = System.nanoTime();
-			long time = endTime - startTime;
-			System.out.println(nodeNum + " " + time / count / 1000000.0);
-			return;
-		}
-		
-		FirstRingMessagePassing cs = new FirstRingMessagePassing(startTime, count, nodeNum);
-		cs.ds1.setKey("c");
-	}
-
-}
--- a/src/alice/test/topology/ring/RingFinish.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-package alice.test.topology.ring;
-
-import org.msgpack.type.ValueFactory;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class RingFinish extends CodeSegment {
-	
-	private String sendKey;
-	public Receiver finish = ids.create(CommandType.TAKE);
-	
-	public RingFinish(String sendKey) {
-		this.sendKey = sendKey;
-	}
-
-	@Override
-	public void run() {
-		ods.put(sendKey, "finish", ValueFactory.createNilValue());
-		ods.finish(sendKey);
-	}
-
-}
--- a/src/alice/test/topology/ring/RingMessagePassing.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-package alice.test.topology.ring;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class RingMessagePassing extends CodeSegment {
-
-	public Receiver ds1 = ids.create(CommandType.TAKE);
-
-	@Override
-	public void run() {
-		ods.put("right", "c", this.ds1.getVal());
-		RingMessagePassing cs = new RingMessagePassing();
-		cs.ds1.setKey("c");
-	}
-
-}
--- a/src/alice/test/topology/ring/RingTopology.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-package alice.test.topology.ring;
-
-import alice.topology.node.TopologyNode;
-
-public class RingTopology {
-	
-	public static void main(String[] args) {
-		RingTopologyConfig conf = new RingTopologyConfig(args);
-		new TopologyNode(conf, new StartRing(conf));
-	}
-	
-}
--- a/src/alice/test/topology/ring/RingTopologyConfig.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-package alice.test.topology.ring;
-
-import alice.topology.node.TopologyNodeConfig;
-
-public class RingTopologyConfig extends TopologyNodeConfig {
-	
-	public int count = 10;
-	public int size = 10;
-	public int nodeNum = 10;
-	
-	public RingTopologyConfig(String[] args) {
-		super(args);
-		for (int i = 0; i < args.length; i++) {
-			if ("-count".equals(args[i])) {
-				this.count = Integer.parseInt(args[++i]);
-			} else if ("-size".equals(args[i])) {
-				this.size = Integer.parseInt(args[++i]);
-			} else if ("-nodeNum".equals(args[i])) {
-				this.nodeNum = Integer.parseInt(args[++i]);
-			}
-		}
-	}
-
-}
--- a/src/alice/test/topology/ring/StartRing.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-package alice.test.topology.ring;
-
-import alice.codesegment.CodeSegment;
-
-public class StartRing extends CodeSegment {
-	private RingTopologyConfig conf;
-	public StartRing(RingTopologyConfig conf) {
-		this.conf = conf;
-	}
-	@Override
-	public void run() {
-		CheckMyName cs = new CheckMyName(conf);
-		cs.ds1.setKey("host");
-	}
-
-}
--- a/src/alice/test/topology/share/AutoIncrement.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-package alice.test.topology.share;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class AutoIncrement extends CodeSegment {
-	
-	public Receiver position = ids.create(CommandType.PEEK);	
-		
-	public AutoIncrement(String key,int index){
-		this.position.setKey(key, index);
-	}
-
-	@Override
-	public void run() {
-		synchronized(this){
-			try {
-				wait(50);
-			} catch (InterruptedException e) {
-				e.printStackTrace();
-			}
-		}
-		ods.update(position.key, new DataInfo(System.nanoTime()));
-		new AutoIncrement(position.key ,position.index);
-	}
-	
-}
--- a/src/alice/test/topology/share/CheckLocalIndex.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-package alice.test.topology.share;
-
-import java.util.List;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class CheckLocalIndex extends CodeSegment {
-
-	private Receiver data = ids.create(CommandType.PEEK);
-	private Receiver list = ids.create(CommandType.PEEK);
-	private Receiver host = ids.create(CommandType.PEEK);
-
-	
-	public CheckLocalIndex(String key, int index) {
-		this.host.setKey("host");
-		this.list.setKey("_CLIST");
-		this.data.setKey(key, index);
-	}
-	
-	@Override
-	public void run() {
-		@SuppressWarnings("unchecked")
-		List<String> r = list.asClass(List.class);
-		int count = 0;
-		boolean flag = false;
-		for (String node : r) {
-			if (node.equals("parent")) {
-				flag = true;
-			}
-			if (!node.equals(this.data.from)) {
-				ods.update(node, data.key, data.getVal());
-				count++;
-			}
-		}
-		if (count == 0 && flag) {
-			ods.put("parent", "data", data.getVal());
-		}
-		new CheckLocalIndex(data.key, data.index);
-		
-	}
-
-}
--- a/src/alice/test/topology/share/CheckMyName.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-package alice.test.topology.share;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-
-public class CheckMyName extends CodeSegment {
-	Receiver host = ids.create(CommandType.PEEK);
-	Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
-	String key = "fish";
-	
-	public CheckMyName(){
-		this.host.setKey("host");
-	}
-	
-	@Override
-	public void run(){
-		
-		String name = host.asString();
-		Matcher matcher = pattern.matcher(name);
-		
-		matcher.find();
-		String type = matcher.group(1);
-		int num = new Integer(matcher.group(2));
-			
-		if (type.equals("cli")){
-			System.out.println("cli"+num);
-			new SendData(0);
-			
-		}else if (type.equals("node")){
-			System.out.println("node"+num);
-			if (num != 0){
-				new SendData(0);
-			}else{
-				new LookUpData("data",0);
-			}
-		}
-		for (int i =0 ;i<1000000;i++){}
-		ods.update(key, new DataInfo());
-		
-		if (num == 0) new AutoIncrement(key,0);
-		new CheckLocalIndex(key,1);
-	}
-}
--- a/src/alice/test/topology/share/DataInfo.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-package alice.test.topology.share;
-
-import org.msgpack.annotation.Message;
-
-@Message
-public class DataInfo {
-	public long setTime = 0;
-		
-	public DataInfo(){}
-	
-	public DataInfo(long t){
-		setTime = t;
-	}
-	
-	public void setTime(long t){
-		setTime = t;
-	}
-	
-	public long getTime(){
-		return setTime;
-	}
-}
--- a/src/alice/test/topology/share/LookUpData.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-package alice.test.topology.share;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class LookUpData extends CodeSegment{
-
-	private Receiver data = ids.create(CommandType.PEEK);
-	String key;
-	int depth;
-	
-	public LookUpData(String key,int index){
-		this.key = key;
-		this.data.setKey(key, index);
-	}
-	
-	public LookUpData(String key,int index, int depth){
-		this.key = key;
-		this.depth = depth;
-		this.data.setKey(key, index);
-	}
-
-	@Override
-	public void run(){
-		new LookUpData(this.key,this.data.index);
-		DataInfo di = data.asClass(DataInfo.class);
-		System.out.println(System.nanoTime()-di.getTime());
-
-	}
-	
-}
\ No newline at end of file
--- a/src/alice/test/topology/share/SendData.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-package alice.test.topology.share;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class SendData extends CodeSegment{
-	private Receiver data = ids.create(CommandType.PEEK);
-	
-	public SendData(int index){
-		this.data.setKey("data", index);
-	}
-	
-	@Override
-	public void run(){
-		new SendData(this.data.index);
-		ods.put("parent", "data", this.data.getVal());
-	}
-	
-}
\ No newline at end of file
--- a/src/alice/test/topology/share/ShareConfig.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-package alice.test.topology.share;
-
-import alice.topology.node.TopologyNodeConfig;
-
-public class ShareConfig extends TopologyNodeConfig {
-	
-	public ShareConfig(String[] args){
-		super(args);
-	} 
-	
-
-}
--- a/src/alice/test/topology/share/ShareTopology.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-package alice.test.topology.share;
-import alice.topology.node.TopologyNode;
-
-public class ShareTopology {
-	public static void main(String[] args){
-		ShareConfig conf = new ShareConfig(args);
-		new TopologyNode(conf, new StartFishMovement());
-		
-	}
-
-}
--- a/src/alice/test/topology/share/StartFishMovement.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-package alice.test.topology.share;
-
-import alice.codesegment.CodeSegment;
-
-public class StartFishMovement extends CodeSegment{
-	@Override
-	public void run(){
-		new CheckMyName();
-	}
-	
-
-}
--- a/src/alice/topology/HostMessage.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-package alice.topology;
-
-import org.msgpack.annotation.Message;
-
-@Message
-public class HostMessage {
-	
-	public String name;
-	public int port;
-	public String connectionName;
-	public String reverseName;
-	public String absName;
-	public boolean reconnectFlag = false;
-	
-	public HostMessage() { }
-	public HostMessage(String name, int port) {
-		this.name = name;
-		this.port = port;
-	}
-
-	public HostMessage(String name, int port, String connectionName, String reverseName) {
-		this.name = name;
-		this.port = port;
-		this.connectionName = connectionName;
-		this.reverseName = reverseName;
-	}
-	
-	public void setABSName(String name){
-		absName = name;
-	}
-	
-	public String getABSName(){
-		return absName;
-	}
-	
-	public void setFlag(){
-		this.reconnectFlag = true;
-	}
-	
-}
--- a/src/alice/topology/manager/ConfigWaiter.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-package alice.topology.manager;
-
-import org.msgpack.type.ValueFactory;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-import alice.topology.manager.reconnection.ReceiveError;
-
-public class ConfigWaiter extends CodeSegment {
-	
-	public Receiver done = ids.create(CommandType.TAKE);
-	public int count;
-	
-	public ConfigWaiter(int nodeNum) {
-		this.count = nodeNum;
-	}
-
-	@Override
-	public void run() {
-		count--;
-		if (count == 0) {
-			ods.put("local", "start", ValueFactory.createNilValue());
-			new ReceiveError();
-			return;
-		}
-		ConfigWaiter cs3 = new ConfigWaiter(count);
-		cs3.done.setKey("local", "done");
-	}
-
-}
--- a/src/alice/topology/manager/IncomingHosts.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-package alice.topology.manager;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-
-import org.msgpack.type.ValueFactory;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.DataSegment;
-import alice.datasegment.Receiver;
-import alice.topology.HostMessage;
-
-public class IncomingHosts extends CodeSegment {
-	
-	HashMap<String, LinkedList<NodeInfo>> topology;
-	LinkedList<String> nodeNames;
-	Receiver host = ids.create(CommandType.TAKE);
-	Receiver connection = ids.create(CommandType.TAKE);
-	
-	public IncomingHosts(HashMap<String, LinkedList<NodeInfo>> topology, LinkedList<String> nodeNames) {
-		this.topology = topology;
-		this.nodeNames = nodeNames;
-	}
-
-	@Override
-	public void run() {
-		HostMessage host = this.host.asClass(HostMessage.class);
-		@SuppressWarnings("unchecked")
-		HashMap<String, ArrayList<HostMessage>> connectionList = this.connection.asClass(HashMap.class);
-		
-		String nodeName = nodeNames.poll();
-		// Manager connect to Node
-		
-		DataSegment.connect(nodeName, "", host.name, host.port, host.reconnectFlag);
-		ods.put(nodeName, "host", nodeName);
-		LinkedList<NodeInfo> nodes = topology.get(nodeName);
-		ArrayList<HostMessage> list;
-		for (NodeInfo nodeInfo : nodes) {
-			HostMessage newHost = new HostMessage(host.name, host.port, nodeInfo.connectionName, nodeInfo.reverseName);
-			ods.put("local", nodeInfo.sourceNodeName, newHost);
-			
-			if (connectionList.containsKey(nodeInfo.sourceNodeName)){
-				list = connectionList.get(nodeInfo.sourceNodeName);
-			} else {
-				list = new ArrayList<HostMessage>();
-				connectionList.put(nodeInfo.sourceNodeName, list);
-				
-			}			
-			list.add(newHost);
-		}
-		ods.update("local", "connection", connectionList);
-		
-		if (nodeNames.isEmpty()) {
-			// configuration finish
-			for (String key : topology.keySet()) {
-				ods.put("local", key, ValueFactory.createNilValue());
-			}
-		} else {
-			IncomingHosts cs = new IncomingHosts(topology, nodeNames);
-			cs.host.setKey("local", "host");
-			cs.connection.setKey("local", "connection");
-		}
-	}
-
-}
--- a/src/alice/topology/manager/NodeInfo.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-package alice.topology.manager;
-
-public class NodeInfo {
-	
-	public String sourceNodeName;
-	public String connectionName;
-	public String reverseName;
-	
-	public NodeInfo(String source, String connection) {
-		this.sourceNodeName = source;
-		this.connectionName = connection;
-	}
-	
-}
--- a/src/alice/topology/manager/StartTopologyManager.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-package alice.topology.manager;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-
-import org.apache.log4j.Logger;
-
-import alice.codesegment.CodeSegment;
-import alice.topology.HostMessage;
-
-import com.alexmerz.graphviz.ParseException;
-import com.alexmerz.graphviz.Parser;
-import com.alexmerz.graphviz.objects.Edge;
-import com.alexmerz.graphviz.objects.Graph;
-import com.alexmerz.graphviz.objects.Node;
-
-public class StartTopologyManager extends CodeSegment {
-
-	TopologyManagerConfig conf;
-	Logger logger = Logger.getLogger(StartTopologyManager.class);
-
-	public StartTopologyManager(TopologyManagerConfig conf) {
-		this.conf = conf;
-	}
-
-	@Override
-	public void run() {
-		LinkedList<String> nodeNames = new LinkedList<String>();
-		HashMap<String, LinkedList<NodeInfo>> topology = new HashMap<String, LinkedList<NodeInfo>>();
-		int nodeNum = 0;
-		try {
-			FileReader reader = new FileReader(new File(conf.confFilePath));
-			Parser parser = new Parser();
-			parser.parse(reader);
-			ArrayList<Graph> graphs = parser.getGraphs();
-			for (Graph graph : graphs) {
-				ArrayList<Node> nodes = graph.getNodes(false);
-				nodeNum = nodes.size();
-				for (Node node : nodes) {
-					String nodeName = node.getId().getId();
-					nodeNames.add(nodeName);
-					topology.put(nodeName, new LinkedList<NodeInfo>());
-				}
-				ArrayList<Edge> edges = graph.getEdges();
-				HashMap<String, NodeInfo> hash = new HashMap<String, NodeInfo>();
-				for (Edge edge : edges) {
-					String connection = edge.getAttribute("label");
-					String source = edge.getSource().getNode().getId().getId();
-					String target = edge.getTarget().getNode().getId().getId();
-					LinkedList<NodeInfo> sources = topology.get(target);
-					NodeInfo nodeInfo = new NodeInfo(source, connection);
-					sources.add(nodeInfo);
-					hash.put(source + "," + target, nodeInfo);
-				}
-				for (Edge edge : edges) {
-					String connection = edge.getAttribute("label");
-					String source = edge.getSource().getNode().getId().getId();
-					String target = edge.getTarget().getNode().getId().getId();
-					NodeInfo nodeInfo = hash.get(target + "," + source);
-					if (nodeInfo != null) {
-						nodeInfo.reverseName = connection;
-					}
-				}
-			}
-			
-		} catch (FileNotFoundException e) {
-			logger.error("File not found: " + conf.confFilePath);
-			e.printStackTrace();
-		} catch (ParseException e) {
-			logger.error("File format error: " + conf.confFilePath);
-			e.printStackTrace();
-		}
-		HashMap<String, ArrayList<HostMessage>> connectionList = new HashMap<String, ArrayList<HostMessage>>();
-		ods.put("connection", connectionList);
-		ods.put("_ABSIPTABLE" ,new ArrayList<HostMessage>());
-		
-		new createABSIPList();
-		
-		IncomingHosts cs1 = new IncomingHosts(topology, nodeNames);
-		cs1.host.setKey("host");
-		cs1.connection.setKey("connection");
-		
-		ConfigWaiter cs3 = new ConfigWaiter(nodeNum);
-		cs3.done.setKey("local", "done");
-		
-		
-	}
-
-}
--- a/src/alice/topology/manager/TopologyFinish.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-package alice.topology.manager;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class TopologyFinish extends CodeSegment {
-	public Receiver finish = ids.create(CommandType.TAKE);
-	@Override
-	public void run() {
-		System.exit(0);
-	}
-
-}
--- a/src/alice/topology/manager/TopologyManager.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-package alice.topology.manager;
-
-import alice.daemon.AliceDaemon;
-
-public class TopologyManager {
-
-	public static void main(String[] args) {
-		TopologyManagerConfig conf = new TopologyManagerConfig(args);
-		new AliceDaemon(conf).listen();
-		new StartTopologyManager(conf).execute();
-	}
-
-}
--- a/src/alice/topology/manager/TopologyManagerConfig.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-package alice.topology.manager;
-
-import alice.daemon.Config;
-
-public class TopologyManagerConfig extends Config {
-	
-	public String confFilePath;
-	
-	public TopologyManagerConfig(String[] args) {
-		super(args);
-		for (int i = 0; i < args.length; i++) {
-			if ("-conf".equals(args[i])) {
-				confFilePath = args[++i];
-			}
-		}
-	}
-
-}
--- a/src/alice/topology/manager/createABSIPList.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-package alice.topology.manager;
-
-import java.util.List;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-import alice.topology.HostMessage;
-
-public class createABSIPList extends CodeSegment{
-	private Receiver rData = ids.create(CommandType.TAKE);
-	private Receiver hlist = ids.create(CommandType.PEEK);
-	
-	public createABSIPList(){
-		rData.setKey("_ABS_IP");
-		hlist.setKey("_ABSIPTABLE");
-	}
-	
-	@Override
-	public void run() {
-		HostMessage host = rData.asClass(HostMessage.class);
-		@SuppressWarnings("unchecked")
-		List<HostMessage> ABSIPList = hlist.asClass(List.class);
-		ABSIPList.add(host);
-		ods.update("_ABSIPTABLE", ABSIPList);
-		
-		new createABSIPList();
-		
-	}
-
-}
--- a/src/alice/topology/manager/keeparive/CheckExistTask.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-package alice.topology.manager.keeparive;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class CheckExistTask extends CodeSegment{
-	private Receiver info = ids.create(CommandType.PEEK); // TaskInfo
-	
-	public CheckExistTask(){
-		info.setKey("_TASKINFO");
-	}
-	
-	@Override
-	public void run() {
-		new CreateSchedule();
-		
-	}
-
-}
--- a/src/alice/topology/manager/keeparive/CreateSchedule.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-package alice.topology.manager.keeparive;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class CreateSchedule extends CodeSegment{
-	private Receiver info1 = ids.create(CommandType.TAKE); // WaitingList 
-	private Receiver info2 = ids.create(CommandType.TAKE); // TaskInfo
-	
-	public CreateSchedule(){
-		info1.setKey("_WAITINGLIST");
-		info2.setKey("_TASKINFO");
-	}
-
-	@Override
-	public void run() {
-		ListManager manager = info1.asClass(ListManager.class);
-		TaskInfo newTask = info2.asClass(TaskInfo.class);
-		manager.addTask(newTask);
-		ods.update("_WAITINGLIST", manager);
-		new CheckExistTask();
-	}
-}
--- a/src/alice/topology/manager/keeparive/CreateTask.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-package alice.topology.manager.keeparive;
-
-import java.util.List;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class CreateTask extends CodeSegment{
-	private Receiver info = ids.create(CommandType.PEEK);
-	
-	public CreateTask(){
-		info.setKey("_CLIST");
-	}
-	
-	@Override
-	public void run(){
-		ods.put("_WAITINGLIST", new ListManager());
-		@SuppressWarnings("unchecked")
-		List<String> list = info.asClass(List.class);
-		
-		new CheckExistTask();
-		TaskExecuter.getInstance().setKey();
-		for (String manager : list){
-			int i = 5;
-			TaskInfo task = new TaskInfo(TaskType.PING);
-			task.setInfo(manager, "_FORM_"+manager, i * 1000);
-			ods.put("_TASKINFO", task);
-			i +=5;
-		}
-		
-	}
-
-}
--- a/src/alice/topology/manager/keeparive/KeepAlive.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-package alice.topology.manager.keeparive;
-
-import alice.topology.node.TopologyNode;
-import alice.topology.node.TopologyNodeConfig;
-
-public class KeepAlive {
-	public static void main(String[] args) {
-		TopologyNodeConfig conf = new TopologyNodeConfig(args);
-		new TopologyNode(conf, new StartKeepAlive());
-	}
-
-}
--- a/src/alice/topology/manager/keeparive/ListManager.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-package alice.topology.manager.keeparive;
-
-import java.util.LinkedList;
-
-public class ListManager {
-	private LinkedList<TaskInfo> list = new LinkedList<TaskInfo>();
-
-	public LinkedList<TaskInfo> getTaskList() {
-		return list;
-	}
-
-	public void addTask(TaskInfo newInfo) {
-		TaskExecuter exec = TaskExecuter.getInstance();
-		TaskInfo nowTask = exec.getNowTask();
-		if (nowTask == null) { // active task is nothing
-			add(newInfo);
-		} else {
-			long remainingTime = exec.getRemainingTime();
-			if (remainingTime > newInfo.getSleepTime()) {
-				// active task is longer than newTask.
-				TaskInfo task = nowTask.clone();
-				task.setSleepTime(remainingTime);
-				list.addFirst(task);
-				add(newInfo);
-				exec.ignore();
-			} else {
-				// newTask is longer than active task.
-				newInfo.setSleepTime(newInfo.getSleepTime() - remainingTime);
-				add(newInfo);
-			}
-		}
-		show();
-	}
-
-	private void add(TaskInfo newInfo){
-		int cnt = 0;
-		for (TaskInfo info : list){
-			if (info.getSleepTime() < newInfo.getSleepTime()){
-				newInfo.setSleepTime(newInfo.getSleepTime() - info.getSleepTime());	
-			} else if (info.getSleepTime() == newInfo.getSleepTime()){
-				// newInfo.getSleepTime() - info.getSleepTime() must be Zero
-				newInfo.setSleepTime(0);
-				cnt++;
-				break;
-			} else if (info.getSleepTime() > newInfo.getSleepTime()){
-				info.setSleepTime(info.getSleepTime() - newInfo.getSleepTime());
-				break;
-			}
-			cnt++;
-		}
-		list.add(cnt, newInfo);
-	}
-	
-	public boolean deleteTask(TaskInfo task){
-		boolean matchFlag = false;
-		int cnt = 0;
-		for (TaskInfo t: list){
-			if (t.getType().equals(task.getType())){
-				matchFlag = true;
-				if (cnt+1 < list.size() ){ // next task exists.
-					TaskInfo next = list.get(cnt+1);
-					next.setSleepTime(next.getSleepTime()+task.getSleepTime());
-				}
-				list.remove(cnt);
-				break;
-			} else {
-				cnt++;
-			}
-		}	
-		return matchFlag;
-	}
-	
-	public void show(){
-		if (TaskExecuter.getInstance().getNowTask()!=null){
-			System.out.print("NOW | ");
-			System.out.print(TaskExecuter.getInstance().getNowTask().getSleepTime());
-			System.out.print(" | ");
-		}
-		for (TaskInfo info : list){
-			System.out.print(info.getSleepTime());
-			System.out.print(" | ");
-		}
-		System.out.println();
-	}
-}
--- a/src/alice/topology/manager/keeparive/ListManagerTest.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-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.show();
-			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.show();
-			i +=1;
-		}
-		
-		manager = new ListManager();
-		System.out.println(TaskExecuter.getInstance().getRemainingTime());
-		TaskExecuter.getInstance().setNowTask(taskA);
-		TaskExecuter.getInstance().skip();
-		System.out.println(TaskExecuter.getInstance().getRemainingTime());
-
-	}
-}
\ No newline at end of file
--- a/src/alice/topology/manager/keeparive/RemoveTask.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-package alice.topology.manager.keeparive;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class RemoveTask extends CodeSegment {
-	private Receiver info1 = ids.create(CommandType.TAKE); // list
-	private Receiver info2 = ids.create(CommandType.TAKE); // remove task
-
-	public RemoveTask(){
-		info1.setKey("_WAITINGLIST");
-		info2.setKey("_REMOVETASK");
-	}
-
-	@Override
-	public void run() {
-		ListManager list = info1.asClass(ListManager.class); // explicit cast
-		TaskInfo task = info2.asClass(TaskInfo.class);
-		TaskExecuter exec = TaskExecuter.getInstance();
-		if (exec.compareNowTask(task)){
-			// case: remove task is state countdown.
-			exec.skip();
-		} else {
-			// case: remove task is still in the waiting queue.
-			boolean removeFlag = list.deleteTask(task);
-			if (!removeFlag){
-				ods.put("_REMOVETASK", task);
-			}
-		}
-		ods.update("_WAITINGLIST", list);
-	}
-}
--- a/src/alice/topology/manager/keeparive/RespondData.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-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	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-package alice.topology.manager.keeparive;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.DataSegment;
-import alice.datasegment.Receiver;
-
-public class RespondPing extends CodeSegment{
-	private Receiver respond = ids.create(CommandType.TAKE);
-	private long pingedTime = System.currentTimeMillis();
-	
-	public RespondPing(String key) {
-		respond.setKey(key);
-	}
-
-	@Override
-	public void run() {
-		RespondData d = respond.asClass(RespondData.class);
-		System.out.print("ping from "+d.from);
-		System.out.println(" Recieved time "+(d.time - pingedTime));
-		if (d.time - pingedTime > 60 * 1000){
-			// need check, this connection is alive. may be close 
-			DataSegment.get(d.from).close();
-		} else {
-			// if nowTask close d.from's socket cancel. 
-			// if not remove close task in the Queue.
-			TaskExecuter exec = TaskExecuter.getInstance();
-			TaskInfo task = new TaskInfo(TaskType.CLOSE);
-			task.setInfo(d.from, null, 0);
-			if (exec.compareNowTask(task)){
-				// case: remove task is state countdown.
-				exec.skip(); // countdown
-			} else {
-				// case: remove task is still in the waiting queue.
-				ods.put("_REMOVETASK",task);
-				new RemoveTask();
-			}
-			TaskInfo task2 = new TaskInfo(TaskType.PING);
-			task2.setInfo(d.from, "_FORM_"+d.from, 5 * 1000);
-			ods.put("_TASKINFO", task2);
-		}
-	}
-}
--- a/src/alice/topology/manager/keeparive/StartKeepAlive.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-package alice.topology.manager.keeparive;
-
-import alice.codesegment.CodeSegment;
-
-public class StartKeepAlive extends CodeSegment {
-
-	@Override
-	public void run() {
-		new CreateTask();
-
-	}
-
-}
--- a/src/alice/topology/manager/keeparive/TaskExecuter.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-package alice.topology.manager.keeparive;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.DataSegment;
-import alice.datasegment.Receiver;
-
-public class TaskExecuter extends CodeSegment {
-	private Receiver info = ids.create(CommandType.TAKE);
-	private TaskInfo nowTask;
-	private boolean sleepFlag = false;
-	private boolean skipFlag = false;
-	private long startTime = 0;
-	private long remainingTime = 0; 
-	private static TaskExecuter instance = new TaskExecuter();
-
-	private TaskExecuter() {}
-	public static TaskExecuter getInstance() {
-		return instance;
-	}
-
-	public void setKey() {
-		ids.init();
-		info.setKey("_WAITINGLIST");
-	}
-
-	@Override
-	public synchronized void run()  {
-		ListManager list = info.asClass(ListManager.class);
-		if (list.getTaskList().size() == 0){
-			remainingTime = 0;
-			ods.update("_WAITINGLIST", list);
-		} else {
-			nowTask = list.getTaskList().poll();
-			ods.update("_WAITINGLIST", list);
-			
-			if (skipFlag) {
-				skipFlag = false;
-				nowTask.setSleepTime(remainingTime + nowTask.getSleepTime());
-				remainingTime = 0;
-			}
-			
-			startTime = System.currentTimeMillis();
-			System.out.println(nowTask.getSleepTime()+" "+nowTask.getType());
-			if (nowTask.getSleepTime() != 0){
-				sleepFlag = true;
-				try {
-					wait(nowTask.getSleepTime());
-				} catch (InterruptedException e) {
-					e.printStackTrace();
-				}
-				sleepFlag = false;
-			}
-			
-			if (!skipFlag){
-				// ping or close
-				if (nowTask.getType() == TaskType.PING) {
-					ods.ping(nowTask.getManagerKey(), nowTask.getReturnKey());
-					TaskInfo task = new TaskInfo(TaskType.CLOSE);
-					task.setInfo(nowTask.getManagerKey(), 10 * 1000);
-					ods.put("_TASKINFO", task);
-					new RespondPing(nowTask.getReturnKey());
-				} else if (nowTask.getType() == TaskType.CLOSE) {
-					// no response from the Remote DataSegment. So close this connection.
-					System.out.println("SHOTDOWN");
-					DataSegment.get(nowTask.getManagerKey()).close();
-				}
-			}
-			nowTask = null;
-			startTime = 0;
-		}
-		setKey();
-	}
-	
-	public synchronized void skip() {
-		if (sleepFlag){
-			skipFlag = true;
-			if (startTime == 0){
-				remainingTime = nowTask.getSleepTime();
-			} else {
-				remainingTime = nowTask.getSleepTime() - (System.currentTimeMillis() - startTime);
-			}
-			nowTask = null;			
-			notify();
-		}
-	}
-
-	public synchronized void ignore() {
-		if (sleepFlag){
-			skipFlag = true;
-			remainingTime = 0;
-			nowTask = null;
-			notify();			
-		}
-	}
-
-	public synchronized TaskInfo getNowTask() {
-		return nowTask;
-	}
-
-	// only use in ListManagerTest
-	public synchronized void setNowTask(TaskInfo info) {
-		nowTask = info;
-	}
-
-	public synchronized long getRemainingTime() {
-		if (sleepFlag) {
-			if (startTime !=0) {
-				return nowTask.getSleepTime() - (System.currentTimeMillis() - startTime);
-			} else {
-				return nowTask.getSleepTime();
-			}
-		} else {
-			return remainingTime;
-		}
-	}
-
-	public boolean compareNowTask(TaskInfo task) {
-		if (nowTask != null){
-			if (nowTask.getType().equals(task.getType())
-					&& nowTask.getManagerKey().equals(task.getManagerKey())){
-				return true;
-			} 
-		}
-		return false;
-	}
-
-}
\ No newline at end of file
--- a/src/alice/topology/manager/keeparive/TaskInfo.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-package alice.topology.manager.keeparive;
-
-public class TaskInfo {
-	private TaskType type;
-	private long sleepTime;
-	private String managerKey;
-	private String returnKey;
-	
-	public TaskInfo(TaskType t){
-		type = t;
-	}
-	
-	public void setInfo(String managerKey, long time){
-		this.managerKey = managerKey;
-		sleepTime = time;
-	}
-	
-	public void setInfo(String managerKey, String returnKey, long time){
-		this.managerKey = managerKey;
-		this.returnKey = returnKey;
-		sleepTime = time;
-	}
-	
-	public TaskType getType(){
-		return type;
-	}
-	
-	public long getSleepTime(){
-		return sleepTime;
-	}
-	
-	public void setSleepTime(long time){
-		sleepTime = time;
-	}
-
-	public String getManagerKey(){
-		return managerKey;
-	}
-	
-	public String getReturnKey(){
-		return returnKey;
-	}
-	
-	public TaskInfo clone(){
-		TaskInfo task = new TaskInfo(type);
-		task.setInfo(managerKey, returnKey, sleepTime);
-		return task;
-	}
-	
-	public void show(){
-		System.out.print(type);
-		System.out.print(" "+  this.sleepTime);
-		System.out.print(" "+ this.managerKey);
-		System.out.println(" "+  this.returnKey);
-	}
-}
--- a/src/alice/topology/manager/keeparive/TaskType.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-package alice.topology.manager.keeparive;
-
-public enum TaskType {
-	PING,
-	CLOSE,
-}
--- a/src/alice/topology/manager/reconnection/CheckABSName.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-package alice.topology.manager.reconnection;
-
-import java.util.List;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.DataSegment;
-import alice.datasegment.Receiver;
-import alice.topology.HostMessage;
-
-public class CheckABSName extends CodeSegment{
-	private Receiver abs = ids.create(CommandType.PEEK);
-	private Receiver host = ids.create(CommandType.TAKE);
-	private HostMessage message;
-	
-	public CheckABSName(HostMessage mes) {
-		message = mes;
-		abs.setKey("_ABSIPTABLE");
-		host.setKey("host");
-	}
-
-	@Override
-	public void run() {
-		System.out.println("CheckABSName");
-		@SuppressWarnings("unchecked")
-		List<HostMessage> ABSIPList = abs.asClass(List.class);
-		HostMessage hostInfo = host.asClass(HostMessage.class);
-		for (HostMessage mes : ABSIPList){
-			if (mes.name.equals(message.name)&&mes.port == message.port){
-				DataSegment.remove(mes.getABSName());
-				DataSegment.connect(mes.getABSName(), "", hostInfo.name, hostInfo.port, hostInfo.reconnectFlag);
-				ods.put(mes.getABSName(), "host", mes.getABSName());
-				ods.put("_RECABSNAME", mes.getABSName());
-				ods.put("_HMCLONE", new HostMessage(mes.name, mes.port));		
-				mes.port = hostInfo.port;
-				mes.name = hostInfo.name;
-				ods.update("_ABSIPTABLE", ABSIPList);
-				new CheckConnectionList();
-				return;
-			}
-		}
-		ods.put("host", hostInfo);
-		new ReceiveError();
-		System.out.println("not match");
-	}
-
-}
--- a/src/alice/topology/manager/reconnection/CheckConnectionList.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-package alice.topology.manager.reconnection;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.msgpack.type.ValueFactory;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-import alice.topology.HostMessage;
-
-public class CheckConnectionList extends CodeSegment {
-
-	private Receiver name = ids.create(CommandType.TAKE);
-	private Receiver connection = ids.create(CommandType.TAKE);
-	private Receiver abs = ids.create(CommandType.PEEK);
-	private Receiver clone = ids.create(CommandType.TAKE);
-	
-	public CheckConnectionList(){
-		name.setKey("_RECABSNAME");
-		connection.setKey("connection");
-		abs.setKey("_ABSIPTABLE");
-		clone.setKey("_HMCLONE");
-	}
-	
-	@Override
-	public void run() {
-		@SuppressWarnings("unchecked")
-		HashMap<String, ArrayList<HostMessage>> connectionList = connection.asClass(HashMap.class);
-		@SuppressWarnings("unchecked")
-		List<HostMessage> ABSIPList = abs.asClass(List.class);
-		String absName = name.asClass(String.class);
-		HostMessage oldInfo =  clone.asClass(HostMessage.class);
-		HostMessage newInfo = null; 
-		for (HostMessage mes : ABSIPList){
-			if (mes.absName.equals(absName)){
-				newInfo = mes;
-				break;
-			}
-		}
-		
-		List<HostMessage> clist = connectionList.get(absName);
-		for (HostMessage mes : clist){
-			mes.setFlag();
-			ods.put(absName, mes);
-			for (HostMessage mes2 : ABSIPList){
-				if (mes.name.equals(mes2.name)&&mes.port == mes2.port){
-					String absName2 = mes2.getABSName();
-					List<HostMessage> clist2 = connectionList.get(absName2);
-					for (HostMessage mes3 : clist2){
-						if (mes3.name.equals(oldInfo.name)&&mes3.port == oldInfo.port){
-							mes3.name = newInfo.name;
-							mes3.port = newInfo.port;
-							mes3.setFlag();
-							ods.put(absName2, "_RECODATA", mes3);
-							break;
-						}
-					}
-					break;
-				}			
-			}
-		}
-		System.out.println("SendHost Data");
-		ods.put(absName, ValueFactory.createNilValue());
-		ods.update("connection", connectionList);
-		new ReceiveError();
-	}
-}
\ No newline at end of file
--- a/src/alice/topology/manager/reconnection/ReceiveError.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-package alice.topology.manager.reconnection;
-
-import java.io.IOException;
-import java.net.Socket;
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-import alice.topology.HostMessage;
-
-public class ReceiveError extends CodeSegment {
-	public Receiver reportInfo = ids.create(CommandType.TAKE);
-	
-	public ReceiveError(){
-		reportInfo.setKey("_ERROR");
-	}
-	
-	@Override
-	public void run() {		
-		HostMessage message = reportInfo.asClass(HostMessage.class);
-		try {
-			System.out.println("Receive Error "+ message.port);
-			Socket socket = new Socket(message.name, message.port);
-			socket.close();
-			System.out.println("alive "+message.port);
-		} catch (IOException e) {
-			System.out.println("Receive Error "+ message.port);
-			new CheckABSName(message);
-			return;
-		}
-		new ReceiveError();
-	}
-
-}
--- a/src/alice/topology/manager/reconnection/ReceiveReconnectData.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-package alice.topology.manager.reconnection;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.DataSegment;
-import alice.datasegment.Receiver;
-import alice.topology.HostMessage;
-
-public class ReceiveReconnectData extends CodeSegment{
-	private Receiver hostData = ids.create(CommandType.TAKE);
-
-	public ReceiveReconnectData(){
-		hostData.setKey("_RECODATA");
-	}
-	
-	@Override
-	public void run() {
-		HostMessage host = hostData.asClass(HostMessage.class);
-		DataSegment.remove(host.connectionName);
-		DataSegment.connect(host.connectionName, host.reverseName, host.name, host.port, host.reconnectFlag);
-		ods.put(host.connectionName, "reverseKey", host.reverseName);
-		new ReceiveReconnectData();
-	}
-	
-
-}
--- a/src/alice/topology/manager/reconnection/SendError.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-package alice.topology.manager.reconnection;
-
-import alice.codesegment.CodeSegment;
-import alice.topology.HostMessage;
-
-public class SendError extends CodeSegment{
-	private HostMessage message;
-	
-	public SendError(HostMessage mes){
-		message = mes;
-	}
-	
-	@Override
-	public void run() {
-		ods.put("manager", "_ERROR", message);
-	}
-
-}
--- a/src/alice/topology/node/ConfigurationFinish.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-package alice.topology.node;
-
-import org.msgpack.type.ValueFactory;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-import alice.topology.manager.reconnection.ReceiveReconnectData;
-
-public class ConfigurationFinish extends CodeSegment {
-
-	public Receiver reverseCount = ids.create(CommandType.PEEK);
-	public Receiver configNodeNum = ids.create(CommandType.PEEK);
-	private CodeSegment startCS;
-	
-	public ConfigurationFinish(CodeSegment startCS) {
-		this.startCS = startCS;
-	}
-	
-	@Override
-	public void run() {
-		if (reverseCount.getVal().equals(configNodeNum.getVal())) {
-			new ReceiveReconnectData();
-			
-			ods.put("manager", "done", ValueFactory.createNilValue());
-			Start cs = new Start(startCS);
-			cs.done.setKey("manager", "start");
-			return;
-		}
-		
-		ConfigurationFinish cs3 = new ConfigurationFinish(startCS);
-		cs3.reverseCount.setKey("local", "reverseCount", this.reverseCount.index);
-		cs3.configNodeNum.setKey("local", "configNodeNum");
-	}
-
-}
--- a/src/alice/topology/node/IncomingAbstractHostName.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-package alice.topology.node;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-import alice.topology.HostMessage;
-
-public class IncomingAbstractHostName extends CodeSegment {
-
-	public Receiver absName = ids.create(CommandType.PEEK);
-	private HostMessage host; // need CodeSegment	
-	
-	public IncomingAbstractHostName(HostMessage _host){
-		host = _host;
-	}
-	
-	@Override
-	public void run() {
-		String absName = this.absName.asString();
-		IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, 0);
-		cs.hostInfo.setKey("manager", absName);
-		host.setABSName(absName);
-		ods.put("manager","_ABS_IP", host);
-	}
-
-}
--- a/src/alice/topology/node/IncomingConnectionInfo.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-package alice.topology.node;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.DataSegment;
-import alice.datasegment.Receiver;
-import alice.topology.HostMessage;
-
-public class IncomingConnectionInfo extends CodeSegment {
-
-	public Receiver hostInfo = ids.create(CommandType.TAKE);
-	private List<String> connectionList;
-	private String absName;
-	private int count;
-	
-	public IncomingConnectionInfo(String absName, int count) {
-		this.absName = absName;
-		this.count = count;
-		this.connectionList = new ArrayList<String>();
-	}
-	
-	public IncomingConnectionInfo(String absName, int count, List<String> connectionList) {
-		this.absName = absName;
-		this.count = count;
-		this.connectionList = connectionList;
-	}
-
-	@Override
-	public void run() {
-		if (this.hostInfo.getVal() == null) {
-			ods.put("local", "configNodeNum", count);
-			return;
-		}
-		
-		HostMessage hostInfo = this.hostInfo.asClass(HostMessage.class);
-		//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);
-		ods.update("_CLIST", connectionList);
-		IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, ++count, connectionList);
-		cs.hostInfo.setKey("manager", absName);
-		
-	}
-
-}
--- a/src/alice/topology/node/IncomingReverseKey.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-package alice.topology.node;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.DataSegment;
-import alice.datasegment.Receiver;
-import org.msgpack.type.Value;
-
-public class IncomingReverseKey extends CodeSegment {
-
-	public Receiver reverseKey = ids.create(CommandType.TAKE);
-	public Receiver reverseCount = ids.create(CommandType.PEEK);
-	
-	@Override
-	public void run() {
-		String reverseKey = ((Value)this.reverseKey.getVal()).asRawValue().getString();
-		String from = this.reverseKey.from;
-		DataSegment.getAccept(from).reverseKey = reverseKey;
-		
-		int reverseCount = this.reverseCount.asInteger();
-		reverseCount++;
-		ods.update("local", "reverseCount", reverseCount);
-		
-		
-		IncomingReverseKey cs = new IncomingReverseKey();
-		cs.reverseKey.setKey("local", "reverseKey");
-		cs.reverseCount.setKey("local", "reverseCount");
-	}
-
-}
--- a/src/alice/topology/node/Start.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-package alice.topology.node;
-
-import org.apache.log4j.Logger;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class Start extends CodeSegment {
-	
-	public Receiver done = ids.create(CommandType.PEEK);
-	private Logger logger = Logger.getLogger(Start.class);
-	private CodeSegment startCS;
-	
-	public Start(CodeSegment startCS) {
-		this.startCS = startCS;
-	}
-	
-	@Override
-	public void run() {
-		logger.info("Configuration finished.");
-		if (startCS == null)
-			return;
-		startCS.execute();
-		
-	}
-
-}
--- a/src/alice/topology/node/StartTopologyNode.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-package alice.topology.node;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.DataSegment;
-import alice.topology.HostMessage;
-
-public class StartTopologyNode extends CodeSegment {
-
-	private TopologyNodeConfig conf;
-	private CodeSegment startCS;
-	
-	public StartTopologyNode(TopologyNodeConfig conf, CodeSegment startCS) {
-		this.conf = conf;
-		this.startCS = startCS;
-	}
-	
-	@Override
-	public void run() {
-		DataSegment.connect("manager", "", conf.managerHostName, conf.managerPort, false);
-		String localHostName = null;
-		try {
-			localHostName = InetAddress.getLocalHost().getHostName();
-		} catch (UnknownHostException e) {
-			e.printStackTrace();
-		}
-		
-		HostMessage host = new HostMessage(localHostName, conf.localPort);
-		ods.put("manager", "host", host);
-		
-		IncomingAbstractHostName cs = new IncomingAbstractHostName(host);
-		cs.absName.setKey("local", "host");
-		
-		IncomingReverseKey cs2 = new IncomingReverseKey();
-		cs2.reverseKey.setKey("local", "reverseKey");
-		cs2.reverseCount.setKey("local", "reverseCount");
-		
-		ods.put("local", "reverseCount", 0);
-		
-		ConfigurationFinish cs3 = new ConfigurationFinish(startCS);
-		cs3.reverseCount.setKey("local", "reverseCount");
-		cs3.configNodeNum.setKey("local", "configNodeNum");
-		
-	}
-
-	@SuppressWarnings("unused")
-	private String getIPAddress() throws SocketException {
-		Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
-
-		while(interfaces.hasMoreElements()){
-			NetworkInterface network = interfaces.nextElement();
-			Enumeration<InetAddress> addresses = network.getInetAddresses();
-
-			while(addresses.hasMoreElements()){
-				String address = addresses.nextElement().getHostAddress();
-				if(!"127.0.0.1".equals(address) && !"0.0.0.0".equals(address)){
-					return address;
-				}
-			}
-		}
-		return "127.0.0.1";
-	}
-
-}
--- a/src/alice/topology/node/TopologyNode.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-package alice.topology.node;
-
-import alice.codesegment.CodeSegment;
-import alice.daemon.AliceDaemon;
-
-public class TopologyNode {
-
-	public TopologyNode(TopologyNodeConfig conf, CodeSegment startCS) {
-		new AliceDaemon(conf).listen();
-		new StartTopologyNode(conf, startCS).execute();
-	}
-	
-	public static void main(String[] args) {
-		TopologyNodeConfig conf = new TopologyNodeConfig(args);
-		new TopologyNode(conf, null);
-	}
-
-}
--- a/src/alice/topology/node/TopologyNodeConfig.java	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-package alice.topology.node;
-
-import alice.daemon.Config;
-
-public class TopologyNodeConfig extends Config {
-	
-	String managerHostName;
-	int managerPort;
-	
-	public TopologyNodeConfig(String[] args) {
-		super(args);
-		for (int i = 0; i< args.length; i++) {
-			if ("-host".equals(args[i])) {
-				managerHostName = args[++i];
-			} else if ("-port".equals(args[i])) {
-				managerPort = Integer.parseInt(args[++i]);
-			}
-		}
-	}
-
-}
--- a/src/log4j.xml	Wed Apr 16 17:37:48 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-   <appender name="Appender1" class="org.apache.log4j.FileAppender">
-      <param name="File" value="alice.log" ></param>
-      <layout class="org.apache.log4j.PatternLayout">
-         <param name="ConversionPattern" value="%d %-5p %c - %m [%t] (%F:%L)%n"/>
-      </layout>
-   </appender>
-   <root>
-      <level value="debug" />
-      <appender-ref ref="Appender1" />
-   </root>
-</log4j:configuration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/codesegment/CodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,26 @@
+package alice.codesegment;
+
+import java.util.ArrayList;
+
+import alice.codesegment.InputDataSegment;
+import alice.datasegment.Receiver;
+
+public abstract class CodeSegment implements Runnable {
+	
+	public InputDataSegment ids = new InputDataSegment(this);
+	public OutputDataSegment ods = new OutputDataSegment();
+	public ArrayList<Receiver> list = new ArrayList<Receiver>();
+	
+	public void execute() {
+		ids.receive();
+	}
+	
+	public void recycle(){
+		ids.init();
+		ids.setCounter(list.size());
+		for (Receiver receiver : list) {
+			ids.recommand(receiver);
+		}
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/codesegment/CodeSegmentManager.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,31 @@
+package alice.codesegment;
+
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.log4j.Logger;
+
+public class CodeSegmentManager {
+
+	private static CodeSegmentManager instance = new CodeSegmentManager();
+	private ThreadPoolExecutor codeSegmentExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), // initial number of threads
+				                                Runtime.getRuntime().availableProcessors(),
+												Integer.MAX_VALUE, // keepAliveTime
+												TimeUnit.SECONDS,
+												new LinkedBlockingQueue<Runnable>());
+	private Logger logger = Logger.getLogger(CodeSegmentManager.class);
+
+	public static CodeSegmentManager get() {
+		return instance;
+	}
+
+	public static void submit(CodeSegment cs) {
+		CodeSegmentManager csManager = CodeSegmentManager.get();
+		csManager.codeSegmentExecutor.execute(cs);
+		if (csManager.logger.isDebugEnabled()) {
+			csManager.logger.debug(cs.getClass().getName());
+		}
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/codesegment/InputDataSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,116 @@
+package alice.codesegment;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import alice.datasegment.Command;
+import alice.datasegment.CommandType;
+import alice.datasegment.DataSegment;
+import alice.datasegment.ReceiveLocalData;
+import alice.datasegment.ReceiveRemoteData;
+import alice.datasegment.Receiver;
+
+/**
+ * InputDataSegment Manager
+ * 			keep tracking unbound/bound count
+ * @author kazz
+ *
+ */
+public class InputDataSegment {
+	
+	public CodeSegment cs;
+	private AtomicInteger count = new AtomicInteger(1); // 1 for no input data segments
+	private AtomicInteger keyCount = new AtomicInteger(0); // number of DataSegments
+	public InputDataSegment(CodeSegment cs) {
+		this.cs = cs;
+	}
+	
+	public void init(){
+		count = new AtomicInteger(1);
+		keyCount = new AtomicInteger(0);
+	}
+	
+	public void quickPeek(Receiver receiver) {
+		cs.list.add(receiver);
+		if (receiver.managerKey==null){
+			DataSegment.getLocal().peek(receiver, cs);
+		} else {
+			DataSegment.get(receiver.managerKey).quickPeek(receiver ,cs);
+		}
+	}
+	
+	public void quickTake(Receiver receiver) {
+		cs.list.add(receiver);
+		if (receiver.managerKey==null){
+			DataSegment.getLocal().quickTake(receiver, cs);
+		} else {
+			DataSegment.get(receiver.managerKey).quickTake(receiver ,cs);
+		}
+	}
+	
+	public void peek(Receiver receiver) {
+		cs.list.add(receiver);
+		if (receiver.managerKey==null){
+			DataSegment.getLocal().peek(receiver, cs);
+		} else {
+			DataSegment.get(receiver.managerKey).peek(receiver, cs);
+		}
+	}
+
+	
+	public void take(Receiver receiver) {
+		cs.list.add(receiver);
+		if (receiver.managerKey==null){
+			DataSegment.getLocal().take(receiver, cs);
+		} else {
+			DataSegment.get(receiver.managerKey).take(receiver, cs);
+		}
+	}
+
+	public void reply(Receiver receiver, Command reply) {
+		receiver.index = reply.index;
+		receiver.from = reply.reverseKey;
+		if (reply.reverseKey==null){
+			receiver.setData(new ReceiveRemoteData(reply.val));
+		} else if (!reply.reverseKey.equals("local")) {
+			receiver.setData(new ReceiveRemoteData(reply.val));
+		} else {
+			receiver.setData(new ReceiveLocalData(reply.obj));			
+		}
+		receive();
+	}
+
+	public void register() {
+		count.getAndIncrement();
+		keyCount.getAndIncrement();
+	}
+	
+	public void setKey() {
+		if (keyCount.decrementAndGet() == 0) {
+			receive();
+		}
+	}
+	
+	public void receive() {
+		if (count.decrementAndGet() == 0) {
+			CodeSegmentManager.submit(cs);
+		}
+	}
+	
+	/**
+	 * InputDataSegment factory
+	 * @param type PEEK or TAKE
+	 * @return Receiver of DataSegment reply 
+	 */
+	public Receiver create(CommandType type) {
+		return new Receiver(this, type);
+	}
+
+	public void recommand(Receiver receiver) {
+		// TODO why only local?
+		DataSegment.getLocal().recommand(receiver, cs);
+	}
+	
+	public void setCounter(int cnt){
+		count.set(cnt);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/codesegment/OutputDataSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,99 @@
+package alice.codesegment;
+
+import alice.datasegment.DataSegment;
+import alice.datasegment.Receiver;
+
+public class OutputDataSegment {
+
+	/**
+	 * for local
+	 */
+
+	public void flip(Receiver receiver) {
+		receiver.managerKey=null;
+		DataSegment.getLocal().put(receiver.key, receiver.getObj());
+	}
+
+	public void put(String key, Object val) {
+		DataSegment.getLocal().put(key, val);
+	}
+
+	public void quickPut(String key, Object val) {
+		put(key, val);
+	}
+
+	public void update(String key, Object val) {
+		DataSegment.getLocal().update(key, val);
+	}
+
+	public void quickuUpdate(String key, Object val) {
+		update(key, val);
+	}
+
+	/**
+	 * for remote
+	 */
+	public void put(String managerKey, String key, Object val) {
+		if (!managerKey.equals("local")){
+			DataSegment.get(managerKey).put(key,val);
+		} else {
+			put(key, val);
+		}
+	}
+
+	public void quickPut(String managerKey, String key, Object val) {
+		if (!managerKey.equals("local")){
+			DataSegment.get(managerKey).quickPut(key, val);
+		} else {
+			put(key, val);
+		}
+	}
+
+	public void update(String managerKey, String key, Object val) {
+		if (!managerKey.equals("local")){
+			DataSegment.get(managerKey).update(key, val);
+		} else {
+			update(key, val);
+		}
+	}
+
+	public void quickUpdate(String managerKey, String key, Object val) {
+		if (!managerKey.equals("local")){
+			DataSegment.get(managerKey).update(key, val);
+		} else {
+			update(key, val);
+		}
+	}
+
+	/**
+	 * kill the Alice process after send other messages.
+	 * 
+	 * @param managerKey
+	 */
+
+	public void finish(String managerKey) {
+		DataSegment.get(managerKey).finish();
+	}
+
+	/**
+	 * close socket for RemoteDataSegment after send other messages.
+	 * 
+	 * @param managerKey
+	 */
+
+	public void close(String managerKey) {
+		DataSegment.get(managerKey).close();
+	}
+
+	/**
+	 * "key" is not remote DataSegment's key.
+	 * "Ping Response" return in this "key" 
+	 * 
+	 * @param managerKey
+	 * @param key
+	 */
+	public void ping(String managerKey, String returnKey) {
+		DataSegment.get(managerKey).ping(returnKey);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/codesegment/SingletonMessage.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,13 @@
+package alice.codesegment;
+
+import org.msgpack.MessagePack;
+
+public class SingletonMessage {
+	
+	private static final MessagePack instance = new MessagePack(); 
+	
+	public static MessagePack getInstance(){
+		return instance;
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/daemon/AcceptThread.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,43 @@
+package alice.daemon;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import org.apache.log4j.Logger;
+
+import alice.datasegment.DataSegment;
+
+public class AcceptThread extends Thread {
+
+	private ServerSocket ss;
+	private Logger log = Logger.getLogger(AcceptThread.class);
+	public int counter = 0;
+
+	public AcceptThread(ServerSocket ss, String name) {
+		super(name);
+		this.ss = ss;
+	}
+	
+	@Override
+	public void run() {
+		while (true) {
+			try {
+				Socket socket = ss.accept();
+				socket.setTcpNoDelay(true);
+				log.info("Accept " + socket.getInetAddress().getHostName() + ":" + socket.getPort());
+				Connection connection = new Connection(socket);
+				String key = "accept" + counter;
+				IncomingTcpConnection incoming =
+						new IncomingTcpConnection(connection, DataSegment.get("local"), key);
+				incoming.start();
+				DataSegment.setAccept(key, incoming);
+				new OutboundTcpConnection(connection).start();
+				counter++;
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/daemon/AliceDaemon.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,61 @@
+package alice.daemon;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.nio.channels.ServerSocketChannel;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.apache.log4j.WriterAppender;
+
+public class AliceDaemon {
+	
+	private Config conf;
+	private AcceptThread acceptThread;
+	private Logger log = Logger.getLogger(AliceDaemon.class);
+	
+	public AliceDaemon(Config conf) {
+		this.conf = conf;
+		setLogger();
+	}
+	
+	private void setLogger() {
+		Logger root = Logger.getRootLogger();
+		if (conf.level != null)
+			root.setLevel(conf.level);
+		if (conf.logFile == null)
+			return;
+		PatternLayout layout = new PatternLayout();
+		layout.setConversionPattern("%d %-5p %c - %m [%t] (%F:%L)%n");
+		try {
+			FileWriter writer = new FileWriter(conf.logFile);
+			WriterAppender writerAppender = new WriterAppender(layout, writer);
+			root.removeAllAppenders();
+			root.addAppender(writerAppender);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		log.info("configured");
+	}
+	
+	public void listen() {
+		try {
+			ServerSocketChannel ssChannel = ServerSocketChannel.open();
+			ServerSocket ss = ssChannel.socket();
+			ss.setReuseAddress(true);
+			
+            //InetSocketAddress a = new InetSocketAddress("::", conf.localPort);
+            InetSocketAddress a = new InetSocketAddress(InetAddress.getLocalHost(), conf.localPort);
+            //System.out.println(a);
+            ss.bind(a);
+			acceptThread = new AcceptThread(ss, "ACCEPT" + conf.localPort);
+			acceptThread.start();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/daemon/CommandMessage.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,25 @@
+package alice.daemon;
+
+import org.msgpack.annotation.Message;
+import org.msgpack.type.Value;
+
+@Message
+public class CommandMessage {
+	public int type;
+	public int index;
+	public int seq;
+	public String key;
+	public Value val;
+	public boolean flag;
+	
+	public CommandMessage() {}
+	
+	public CommandMessage(int type, int index, int seq, String key, Value val, boolean flag) {
+		this.type = type;
+		this.index = index;
+		this.seq = seq;
+		this.key = key;
+		this.val = val;
+		this.flag = flag;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/daemon/Config.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,35 @@
+package alice.daemon;
+
+import org.apache.log4j.Level;
+
+public class Config {
+
+	public int localPort = 10000;
+	public String logFile = null;
+	public Level level = null;
+	
+	public Config(String[] args) {
+		for (int i = 0; i< args.length; i++) {
+			if ("-p".equals(args[i])) {
+				localPort = Integer.parseInt(args[++i]);
+			} else if ("-log".equals(args[i])) {
+				logFile = args[++i];
+			} else if ("-level".equals(args[i])) {
+				String levelStr = args[++i];
+				if (levelStr.equals("fatal")) {
+					level = Level.FATAL;
+				} else if (levelStr.equals("error")) {
+					level = Level.ERROR;
+				} else if (levelStr.equals("warn")) {
+					level = Level.WARN;
+				} else if (levelStr.equals("info")) {
+					level = Level.INFO;
+				} else if (levelStr.equals("debug")) {
+					level = Level.DEBUG;
+				}
+			}
+		}
+
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/daemon/Connection.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,58 @@
+package alice.daemon;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.nio.ByteBuffer;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import alice.codesegment.SingletonMessage;
+import alice.datasegment.Command;
+
+public class Connection {
+
+	public Socket socket;
+	public LinkedBlockingQueue<Command> sendQueue = new LinkedBlockingQueue<Command>();
+
+	public Connection(Socket socket) {
+		this.socket = socket;
+	}
+	
+	public Connection() {}
+
+	public void sendCommand(Command cmd) {
+		try {
+			sendQueue.put(cmd);
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	public String getInfoString() {
+		return socket.getInetAddress().getHostName()
+			   + ":" + socket.getPort();
+	}
+
+	public synchronized void write(Command cmd) {	
+		CommandMessage cmdMsg = cmd.convert();
+		ByteBuffer buffer;
+		try {
+			buffer = ByteBuffer.wrap(SingletonMessage.getInstance().write(cmdMsg));
+			while (buffer.hasRemaining()) {
+				socket.getChannel().write(buffer);
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	public void close(){
+		try {
+			socket.shutdownOutput();
+			socket.shutdownInput();
+			socket.close();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/daemon/IncomingTcpConnection.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,101 @@
+package alice.daemon;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.nio.channels.ClosedChannelException;
+
+import org.msgpack.unpacker.Unpacker;
+
+import alice.codesegment.SingletonMessage;
+import alice.datasegment.Command;
+import alice.datasegment.CommandType;
+import alice.datasegment.DataSegment;
+import alice.datasegment.DataSegmentKey;
+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 {
+	
+	public Connection connection;
+	public DataSegmentManager manager;
+	public String reverseKey;
+	private LocalDataSegmentManager lmanager = DataSegment.getLocal();
+
+	public IncomingTcpConnection(Connection connection, DataSegmentManager manager, String reverseKey) {
+		this.manager = manager;
+		this.connection = connection;
+		this.reverseKey = reverseKey;
+	}
+	
+	/**
+	 * pipeline thread for receiving
+	 */
+	public void run() {
+		Unpacker unpacker = this.getUnpacker();
+		if (unpacker == null) {
+			return;
+		}
+		while (true) {
+			try {
+				CommandMessage msg = unpacker.read(CommandMessage.class);
+				CommandType type = CommandType.getCommandTypeFromId(msg.type);
+				switch (type) {
+				case UPDATE:
+					getDataSegmentKey(msg).runCommand(new Command(type, null, null, msg.val, 0, 0, null, null, reverseKey));
+					break;
+				case PUT:
+					getDataSegmentKey(msg).runCommand(new Command(type, null, null, msg.val, 0, 0, null, null, reverseKey));
+					break;
+				case PEEK:
+					getDataSegmentKey(msg).runCommand(new Command(type, null, null, null, msg.index, msg.seq, connection, null, null, msg.flag));
+					break;
+				case TAKE:
+					getDataSegmentKey(msg).runCommand(new Command(type, null, null, null, msg.index, msg.seq, connection, null, null, msg.flag));
+					break;	
+				case REMOVE:
+					getDataSegmentKey(msg).runCommand(new Command(type, null, null, null, 0, 0, null, null, null));
+					break;
+				case REPLY:
+					Command cmd = manager.getAndRemoveCmd(msg.seq);
+					cmd.cs.ids.reply(cmd.receiver, new Command(type, null, null, msg.val, msg.index, msg.seq, null, null, null));
+					cmd=null;
+					break;
+				case PING:
+					DataSegment.get(reverseKey).response(msg.key);
+					break;
+				case RESPONSE:
+					DataSegment.getLocal().put(msg.key, new RespondData(reverseKey, System.currentTimeMillis()));
+					break;
+				default:
+					break;
+				}
+			} catch (ClosedChannelException e) {
+				connection.sendCommand(new Command(CommandType.CLOSE, null, null, null, 0, 0, null, null, null));
+				return;
+			} catch (EOFException e) {
+				new SendError(new HostMessage(connection.socket.getInetAddress().getHostName(), connection.socket.getPort())).execute();
+				connection.sendCommand(new Command(CommandType.CLOSE, null, null, null, 0, 0, null, null, null));
+				return;
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	private Unpacker getUnpacker() {
+		Unpacker unpacker = null;
+		try {
+			unpacker = SingletonMessage.getInstance().createUnpacker(connection.socket.getInputStream());
+		} catch (IOException e2) {
+			e2.printStackTrace();
+		}
+		return unpacker;
+	}
+
+	private DataSegmentKey getDataSegmentKey(CommandMessage msg) {
+		return lmanager.getDataSegmentKey(msg.key);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/daemon/OutboundTcpConnection.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,42 @@
+package alice.daemon;
+
+import java.io.IOException;
+import alice.datasegment.Command;
+
+public class OutboundTcpConnection extends Thread {
+	
+	public Connection connection;
+	
+	public OutboundTcpConnection(Connection connection) {
+		this.connection = connection;
+	}
+	
+	
+	
+	/**
+	 * pipeline thread for transmission
+	 */
+	public void run() {
+		while (true) {
+			try {
+				Command cmd = connection.sendQueue.take();
+				switch (cmd.type) {
+				case CLOSE:
+					connection.socket.close();
+					return;
+				case FINISH:
+					System.exit(0);
+					return;
+				default:
+					break;
+				}
+				connection.write(cmd);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/datasegment/Command.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,110 @@
+package alice.datasegment;
+
+import java.io.IOException;
+import java.util.concurrent.BlockingQueue;
+import org.msgpack.type.Value;
+
+import alice.codesegment.CodeSegment;
+import alice.codesegment.SingletonMessage;
+import alice.daemon.CommandMessage;
+import alice.daemon.Connection;
+
+public class Command {
+	public CommandType type;
+	public String key;
+	public Receiver receiver;
+	public Value val;
+	public int index;
+	public int seq;
+	public Connection connection; // for remote
+	public BlockingQueue<Command> replyQueue;
+	public CodeSegment cs;
+	public String reverseKey;
+	public Object obj;
+	public boolean flag;
+
+	public Command(CommandType cmdType, Receiver receiver, String key, Value val, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs, String reverseKey) {
+		this.type = cmdType;
+		this.receiver = receiver;
+		this.key = key;
+		this.val = val;
+		this.index = index;
+		this.seq = seq;
+		this.replyQueue = replyQueue;
+		this.cs = cs;
+		this.reverseKey = reverseKey;
+		this.flag = false;
+	}
+	
+	public Command(CommandType cmdType, Receiver receiver, String key, Value val, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs, String reverseKey, boolean flag) {
+		this.type = cmdType;
+		this.receiver = receiver;
+		this.key = key;
+		this.val = val;
+		this.index = index;
+		this.seq = seq;
+		this.replyQueue = replyQueue;
+		this.cs = cs;
+		this.reverseKey = reverseKey;
+		this.flag = flag;
+	}
+	
+	public Command(CommandType cmdType, Receiver receiver, String key, Value val, int index, int seq, Connection connection, CodeSegment cs, String reverseKey, boolean flag) {
+		this.type = cmdType;
+		this.receiver = receiver;
+		this.key = key;
+		this.val = val;
+		this.index = index;
+		this.seq = seq;
+		this.connection = connection;
+		this.cs = cs;
+		this.reverseKey = reverseKey;
+		this.flag = flag;
+	}
+	
+	public Command(CommandType cmdType, Receiver receiver, String key, Object obj, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs, String reverseKey) {
+		this.type = cmdType;
+		this.receiver = receiver;
+		this.key = key;
+		this.obj = obj;
+		this.index = index;
+		this.seq = seq;
+		this.replyQueue = replyQueue;
+		this.cs = cs;
+		this.reverseKey = reverseKey;
+		this.flag = false;
+	}
+	
+	public Command(CommandType cmdType, Receiver receiver, String key, Value val, Object obj, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs, String reverseKey) {
+		this.type = cmdType;
+		this.receiver = receiver;
+		this.key = key;
+		this.val = val;
+		this.obj = obj;
+		this.index = index;
+		this.seq = seq;
+		this.replyQueue = replyQueue;
+		this.cs = cs;
+		this.reverseKey = reverseKey;
+		this.flag = false;
+	}
+	
+	public String getCommandString() {
+		String csName = "null";
+		if (cs != null) {
+			csName = cs.toString();
+		}
+		return this.type + "\t" + key + "\t" + val + "\tindex=" + index + "\tcs=" + csName;
+	}
+	public CommandMessage convert() {
+		if (val==null&&obj!=null){
+			try {
+				this.val = SingletonMessage.getInstance().unconvert(obj);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		return new CommandMessage(type.id, index, seq, key, val, flag);
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/datasegment/CommandType.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,48 @@
+package alice.datasegment;
+
+import java.util.HashMap;
+
+public enum CommandType {
+	PUT,
+	UPDATE, // remove a DataSegment value and put
+	PEEK,
+	TAKE,
+	REMOVE,
+	REPLY,
+	CLOSE,
+	FINISH, 
+	PING,
+	RESPONSE;
+	
+	public int id;
+	public static HashMap<Integer, CommandType> hash = new HashMap<Integer, CommandType>();
+	private static int lastId = 0;
+	
+	private CommandType(int id) {
+		this.id = id;
+		setLastId(id);
+	}
+	
+	private CommandType() {
+		this.id = incrementLastId();
+	}
+	
+	private void setLastId(int id) {
+		lastId =id;
+	}
+	
+	private int incrementLastId() {
+		return ++lastId;
+	}
+	
+	public static CommandType getCommandTypeFromId(int id) {
+		return hash.get(id);
+	}
+	
+	static {
+		for (CommandType type : CommandType.values()) {
+			hash.put(type.id, type);
+		}
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/datasegment/DataSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,48 @@
+package alice.datasegment;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+import alice.daemon.IncomingTcpConnection;
+
+public class DataSegment {
+	
+	private static DataSegment dataSegment = new DataSegment();
+	private LocalDataSegmentManager local = new LocalDataSegmentManager();
+	private ConcurrentHashMap<String, DataSegmentManager> dataSegmentManagers = new ConcurrentHashMap<String, DataSegmentManager>(); //TODO Over Head
+	private ConcurrentHashMap<String, IncomingTcpConnection> acceptHash = new ConcurrentHashMap<String, IncomingTcpConnection>();
+	
+	private DataSegment() {
+		dataSegmentManagers.put("local", local);
+	}
+	
+	public static DataSegmentManager get(String key) {
+		return dataSegment.dataSegmentManagers.get(key);
+	}
+
+	public static LocalDataSegmentManager getLocal() {
+		return dataSegment.local;
+	}
+	
+	public static void register(String key, DataSegmentManager manager) {
+		dataSegment.dataSegmentManagers.put(key, manager);
+	}
+	
+	public static RemoteDataSegmentManager connect(String connectionKey, String reverseKey, String hostName, int port, boolean rFlag) {
+		RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connectionKey, reverseKey, hostName, port, rFlag);
+		register(connectionKey, manager);
+		return manager;
+	}
+	
+	public static void setAccept(String key, IncomingTcpConnection incoming) {
+		dataSegment.acceptHash.put(key, incoming);
+	}
+	
+	public static IncomingTcpConnection getAccept(String key) {
+		return dataSegment.acceptHash.get(key);
+	}
+	
+	public static void remove(String key){
+		dataSegment.dataSegmentManagers.remove(key);
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/datasegment/DataSegmentKey.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,103 @@
+package alice.datasegment;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import alice.datasegment.Command; 
+
+/**
+ * Synchronized DataSegment for each DataSegment key
+ * @author kazz
+ *
+ */
+public class DataSegmentKey {
+	
+	private ArrayList<DataSegmentValue> dataList = new ArrayList<DataSegmentValue>();
+	private ArrayList<Command> waitList = new ArrayList<Command>();
+	private int tailIndex = 1;
+	
+	public synchronized void runCommand(Command cmd) {
+		switch (cmd.type) {
+		case UPDATE:
+			if (dataList.size() != 0) {
+				dataList.remove(0);
+			}
+		case PUT:
+			int index = tailIndex;
+			tailIndex++;
+			DataSegmentValue dsv = new DataSegmentValue(index, cmd.val, cmd.obj, cmd.reverseKey); 
+			dataList.add(dsv);
+			// Process waiting peek and take commands
+			for (Iterator<Command> iter = waitList.iterator(); iter.hasNext(); ) {
+				Command waitCmd = iter.next();
+				if (waitCmd.index < index) {
+					replyValue(waitCmd ,dsv);
+					iter.remove();
+					if (waitCmd.type == CommandType.TAKE) { // someone is waiting for this put or update command
+						dataList.remove(dsv);
+						break;
+					}
+				}
+			}
+			break;
+		case PEEK:
+			if (cmd.index >= tailIndex) {
+				waitList.add(cmd);
+				break;
+			}
+			boolean waitFlag2 = true;
+			for (DataSegmentValue data : dataList) {
+				if (data.index > cmd.index) {
+					replyValue(cmd ,data);
+					waitFlag2 = false;
+					break;
+				}
+			}
+			if (waitFlag2)
+				waitList.add(cmd);
+			break;
+		case TAKE:
+			if (cmd.index >= tailIndex) {
+				waitList.add(cmd);
+				break;
+			}
+			boolean waitFlag = true;
+			for (Iterator<DataSegmentValue> iter = dataList.iterator(); iter.hasNext(); ) {
+				DataSegmentValue data = iter.next();
+				if (data.index > cmd.index) {
+					replyValue(cmd ,data);
+					iter.remove();
+					waitFlag = false;
+					break;
+				}
+			}
+			if (waitFlag)
+				waitList.add(cmd);
+			break;
+		case REMOVE:
+			// TODO: implements later
+			break;
+		default:
+		}
+
+	}
+	
+	public void replyValue(Command cmd, DataSegmentValue data){
+		if (cmd.cs!=null){ // if cmd has cs-instance, it means Command from local.
+			cmd.cs.ids.reply(cmd.receiver, new Command(CommandType.REPLY, null, null, data.val, data.obj, data.index, cmd.seq, null, null, data.from));
+		} else {
+			try {
+				if (!cmd.flag){ 
+					cmd.connection.sendQueue.put(new Command(CommandType.REPLY, null, null, data.val, data.obj, data.index, cmd.seq, null, null, data.from));
+				}
+				else {
+					cmd.connection.write(new Command(CommandType.REPLY, null, null, data.val, data.obj, data.index, cmd.seq, null, null, data.from));
+				}
+				
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/datasegment/DataSegmentManager.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,71 @@
+package alice.datasegment;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.log4j.Logger;
+
+import alice.codesegment.CodeSegment;
+
+public abstract class DataSegmentManager {
+	
+	protected ConcurrentHashMap<Integer, Command> seqHash = new ConcurrentHashMap<Integer, Command>();
+	protected LinkedBlockingQueue<Command> replyQueue = new LinkedBlockingQueue<Command>();
+	protected AtomicInteger seq = new AtomicInteger(1); // waiting for PUT or UPDATE at unique sequence number
+														// but it doesn't need for Local
+	
+	protected Runnable replyThread = new Runnable() {
+		Logger logger = Logger.getLogger("reply");
+		@Override
+		public void run() {
+			while (true) {
+				try {
+					Command reply = replyQueue.take();
+					Command cmd = getAndRemoveCmd(reply.seq);
+					if (cmd == null) {
+						logger.warn("conflict sequence number");
+						continue;
+					}
+					cmd.cs.ids.reply(cmd.receiver, reply);
+					if (logger.isDebugEnabled())
+						logger.debug(reply.getCommandString() + " " + cmd.getCommandString());
+				} catch (InterruptedException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		
+	};
+	
+	public Command getAndRemoveCmd(int index){
+		return seqHash.remove(index);
+	}
+	
+	public void addReplyCommand(Command cmd) {
+		try {
+			replyQueue.put(cmd);
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+	}
+		
+	public abstract void put(String key, Object val);
+	public abstract void update(String key, Object val);
+	public abstract void take(Receiver receiver, CodeSegment cs);
+	public abstract void peek(Receiver receiver, CodeSegment cs);
+	
+	public abstract void quickPut(String key, Object val);
+	public abstract void quickUpdate(String key, Object val);
+	public abstract void quickPeek(Receiver receiver, CodeSegment cs);
+	public abstract void quickTake(Receiver receiver, CodeSegment cs);
+
+	public abstract void remove(String key);
+	public abstract void shutdown(String key);
+	public abstract void close();
+	public abstract void finish();
+	
+	public abstract void ping(String returnKey);
+	public abstract void response(String returnKey);
+		
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/datasegment/DataSegmentValue.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,25 @@
+package alice.datasegment;
+
+import org.msgpack.type.Value;
+
+public class DataSegmentValue {
+
+	public int index;
+	public Value val;
+	public String from;
+	public Object obj;
+	
+	public DataSegmentValue(int index, Value val, Object obj,String reverseKey) {
+		this.index = index;
+		this.val = val;
+		this.from = reverseKey;
+		this.obj = obj;
+	}
+	
+	public DataSegmentValue(int index, Value val,String reverseKey) {
+		this.index = index;
+		this.val = val;
+		this.from = reverseKey;
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/datasegment/LocalDataSegmentManager.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,172 @@
+package alice.datasegment;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.log4j.Logger;
+
+import alice.codesegment.CodeSegment;
+
+public class LocalDataSegmentManager extends DataSegmentManager {
+	
+	private String reverseKey = "local";
+	private ConcurrentHashMap<String, DataSegmentKey> dataSegments = new ConcurrentHashMap<String, DataSegmentKey>();
+	private Logger logger = Logger.getLogger("local");
+
+	private ThreadPoolExecutor dataSegmentExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), // initial number of threads
+			Runtime.getRuntime().availableProcessors(),
+			Integer.MAX_VALUE, // keepAliveTime
+			TimeUnit.SECONDS,
+			new LinkedBlockingQueue<Runnable>());
+	
+	public LocalDataSegmentManager() {
+		new Thread(replyThread, "LocalDataSegmentManager-replyCommand").start();
+	}
+
+	private class RunCommand implements Runnable {
+		
+		DataSegmentKey key;
+		Command cmd;
+		
+		public RunCommand(DataSegmentKey key, Command cmd) {
+			this.key = key;
+			this.cmd = cmd;
+		}
+		
+		@Override
+		public void run() {
+			key.runCommand(cmd);
+		}
+		
+	}
+	
+	public void submitCommand(DataSegmentKey key, Command cmd) {
+		dataSegmentExecutor.execute(new RunCommand(key, cmd));
+	}
+	
+	public DataSegmentKey getDataSegmentKey(String key) {
+		DataSegmentKey dsKey = dataSegments.get(key);
+		if (dsKey != null)
+			return dsKey;
+		if (key == null)
+			return null;
+		DataSegmentKey newDataSegmentKey = new DataSegmentKey();
+		DataSegmentKey dataSegmentKey = dataSegments.putIfAbsent(key, newDataSegmentKey);
+		if (dataSegmentKey == null) {
+			dataSegmentKey = newDataSegmentKey;
+		}
+		return dataSegmentKey;
+	}
+	
+	@Override
+	public void put(String key, Object val) {
+		DataSegmentKey dataSegmentKey = getDataSegmentKey(key);
+		Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, null, null, reverseKey);
+		dataSegmentKey.runCommand(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+	
+	@Override
+	public void quickPut(String key, Object val) {
+		put(key, val);
+	}
+	
+	/**
+	 * Enqueue update command to the queue of each DataSegment key
+	 */
+	
+	@Override
+	public void update(String key, Object val) {
+		DataSegmentKey dataSegmentKey = getDataSegmentKey(key);
+		Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null, reverseKey);
+		dataSegmentKey.runCommand(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+	
+	
+	@Override
+	public void quickUpdate(String key, Object val) {
+		update(key, val);
+	}
+
+	
+	
+	@Override
+	public void take(Receiver receiver, CodeSegment cs) {
+		DataSegmentKey dataSegmentKey = getDataSegmentKey(receiver.key);
+		int seq = this.seq.getAndIncrement();
+		Command cmd = new Command(CommandType.TAKE, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null);
+		dataSegmentKey.runCommand(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+
+	@Override
+	public void quickTake(Receiver receiver, CodeSegment cs) {
+		take(receiver, cs);		
+	}
+	
+	@Override
+	public void peek(Receiver receiver, CodeSegment cs) {
+		DataSegmentKey dataSegmentKey = getDataSegmentKey(receiver.key);
+		int seq = this.seq.getAndIncrement();
+		Command cmd = new Command(CommandType.PEEK, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null);
+		dataSegmentKey.runCommand(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+	
+	@Override
+	public void quickPeek(Receiver receiver, CodeSegment cs) {
+		peek(receiver, cs);
+	}
+
+
+	@Override
+	public void remove(String key) {
+		DataSegmentKey dataSegmentKey = getDataSegmentKey(key);
+		Command cmd = new Command(CommandType.REMOVE, null, key, null, 0, 0, replyQueue, null, null);
+		dataSegmentKey.runCommand(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+	
+	@Override public void finish() {
+		System.exit(0);
+	}
+
+	@Override
+	public void close() {
+		
+	}
+
+	public void recommand(Receiver receiver, CodeSegment cs) {
+		DataSegmentKey dataSegmentKey = getDataSegmentKey(receiver.key);
+		int seq = this.seq.getAndIncrement();
+		Command cmd = new Command(receiver.type, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null);
+		dataSegmentKey.runCommand(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+		
+	}
+
+	@Override
+	public void ping(String returnKey) {
+		
+	}
+
+	@Override
+	public void response(String returnKey) {
+				
+	}
+
+	@Override
+	public void shutdown(String key) {
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/datasegment/ReceiveLocalData.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,55 @@
+package alice.datasegment;
+
+import java.io.IOException;
+
+import org.msgpack.type.ArrayValue;
+import org.msgpack.type.Value;
+
+import alice.codesegment.SingletonMessage;
+import alice.datasegment.ReceiverData;
+
+public class ReceiveLocalData implements ReceiverData {
+	private Object obj;
+
+	public ReceiveLocalData(Object obj2) {
+		this.obj = obj2;
+	}
+
+	public String asString() {
+		return (String) obj;
+	}
+
+	public int asInteger() {
+		return (Integer) obj;
+	}
+
+	public Float asFloat() {
+		return (Float) obj;
+	}
+
+	public ArrayValue asArray(){
+		return (ArrayValue) obj;
+	}
+	
+	@SuppressWarnings("unchecked")
+	public <T> T asClass(Class<T> clazz) {
+		return (T) obj;
+
+	}
+
+	@Override
+	public Value getVal() {
+		try {
+			return SingletonMessage.getInstance().unconvert(obj);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	@Override
+	public Object getObj() {
+		return obj;
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/datasegment/ReceiveRemoteData.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,69 @@
+package alice.datasegment;
+
+import java.io.IOException;
+
+import org.msgpack.type.ArrayValue;
+import org.msgpack.type.Value;
+import org.msgpack.type.ValueType;
+
+import alice.codesegment.SingletonMessage;
+
+public class ReceiveRemoteData implements ReceiverData {
+	public Value val;
+
+	public ReceiveRemoteData() {
+	}
+
+	public ReceiveRemoteData(Value val2) {
+		this.val = val2;
+	}
+
+	public String asString() {
+		if (val.getType() == ValueType.RAW) {
+			return val.asRawValue().getString();
+		}
+		return null;
+	}
+
+	public int asInteger() {
+		if (val.getType() == ValueType.INTEGER) {
+			return val.asIntegerValue().getInt();
+		}
+		return 0;
+	}
+
+	public Float asFloat() {
+		if (val.getType() == ValueType.FLOAT) {
+			return val.asFloatValue().getFloat();
+		}
+		return 0.0f;
+	}
+
+	public ArrayValue asArray(){
+		if (val.getType() == ValueType.ARRAY){
+			return val.asArrayValue();
+		}
+		return null;
+	}
+	
+	public <T> T asClass(Class<T> clazz) {
+		try {
+			return SingletonMessage.getInstance().convert(val, clazz);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return null;
+
+	}
+
+	@Override
+	public Value getVal() {
+		return val;
+	}
+
+	@Override
+	public Object getObj() {
+		return val;
+	}
+	
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/datasegment/Receiver.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,112 @@
+package alice.datasegment;
+
+
+import alice.codesegment.InputDataSegment;
+
+/**
+ * MessagePack implementation and DataSegment Receiver
+ * @author kazz
+ *
+ */
+public class Receiver {
+	private ReceiverData data = new ReceiveRemoteData();
+	public InputDataSegment ids;
+	public int index;
+	public String from;
+	public CommandType type;
+	public String managerKey;
+	public String key;
+
+	public Receiver(InputDataSegment ids, CommandType type) {
+		this.ids = ids;
+		this.type = type;
+		ids.register();
+		
+	}
+	
+	public void setQuickKey(String managerKey, String key){
+		setQuickKey(managerKey, key, 0);
+	}
+	
+	public void setQuickKey(String managerKey, String key, int index) {
+		this.managerKey = managerKey;
+		this.key = key;
+		switch (type) {
+		case PEEK:
+			ids.quickPeek(this);
+			break;
+		case TAKE:
+			ids.quickTake(this);
+			break;
+		default:
+			break;
+		}
+		ids.setKey();
+	}
+	
+	public void setKey(String managerKey, String key) {
+		setKey(managerKey, key, 0);
+	}
+
+	public void setKey(String managerKey, String key, int index) {
+		this.managerKey = managerKey;
+		this.key = key;
+		this.index = index;
+		switch (type) {
+		case PEEK:
+			ids.peek(this);
+			break;
+		case TAKE:
+			ids.take(this);
+			break;
+		default:
+			break;
+		}
+		ids.setKey();
+	}
+	
+	public void setKey(String key) {
+		setKey(key, 0);
+	}
+
+	public void setKey(String key, int index) {
+		this.key = key;
+		this.index = index;
+		switch (type) {
+		case PEEK:
+			ids.peek(this);
+			break;
+		case TAKE:
+			ids.take(this);
+			break;
+		default:
+			break;
+		}
+		ids.setKey();
+	}
+
+	public void setData(ReceiverData r) {
+		data = r;
+	}
+
+	public int asInteger() {
+		return data.asInteger();
+	}
+
+	public String asString() {
+		return data.asString();
+	}
+	
+	public <T> T asClass(Class<T> clazz) {
+		return data.asClass(clazz);
+	}
+	
+	public Object getObj() {
+		return data.getObj();
+	}
+
+	public Object getVal() {
+		return data.getVal();
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/datasegment/ReceiverData.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,16 @@
+package alice.datasegment;
+
+import org.msgpack.type.ArrayValue;
+import org.msgpack.type.Value;
+
+public interface ReceiverData {
+
+	public String asString();
+	public int asInteger();
+	public Float asFloat() ;
+	public ArrayValue asArray();
+	public <T> T asClass(Class<T> clazz);
+	public Value getVal();
+	public Object getObj();
+	
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/datasegment/RemoteDataSegmentManager.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,166 @@
+package alice.datasegment;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.channels.SocketChannel;
+
+import org.apache.log4j.Logger;
+
+import alice.codesegment.CodeSegment;
+import alice.daemon.Connection;
+import alice.daemon.IncomingTcpConnection;
+import alice.daemon.OutboundTcpConnection;
+import alice.topology.HostMessage;
+import alice.topology.manager.reconnection.SendError;
+
+public class RemoteDataSegmentManager extends DataSegmentManager {
+	
+	Connection connection;
+	Logger logger;
+	
+	public RemoteDataSegmentManager(String connectionKey, final String reverseKey, final String hostName, final int port, final boolean rFlag) {
+		logger = Logger.getLogger(connectionKey);
+		connection = new Connection();
+		final RemoteDataSegmentManager manager = this;
+		new Thread(replyThread, "RemoteDataSegmentManager-" + connectionKey).start();
+		new Thread("Connect-" + connectionKey) {
+			public void run() {
+				boolean connect = true;
+				do {
+					try {
+						SocketChannel sc = SocketChannel.open(new InetSocketAddress(hostName, port));
+						connection.socket = sc.socket();
+						connection.socket.setTcpNoDelay(true);
+						connect = false;
+						logger.info("Connect to " + connection.getInfoString());
+					} catch (IOException e) {
+						try {
+							Thread.sleep(50);
+						} catch (InterruptedException e1) {
+							e1.printStackTrace();
+						}
+					}
+				} while (connect&&!rFlag);
+				new IncomingTcpConnection(connection, manager, reverseKey).start();
+				new OutboundTcpConnection(connection).start();
+				// if connection failed need to stop these thread 
+				if (connect){
+					new SendError(new HostMessage(hostName, port)).execute();
+				}
+			}
+		}.start();
+	}
+	
+	/**
+	 * send put command to target DataSegment
+	 */
+	@Override
+	public void put(String key, Object val) {
+		Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, null, null, null);
+		connection.sendCommand(cmd); // put command on the transmission thread
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+	
+	@Override
+	public void quickPut(String key, Object val) {
+		Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, null, null, null);
+		connection.write(cmd); // put command is executed right now
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+	
+	@Override
+	public void update(String key, Object val) {
+		Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null, null);
+		connection.sendCommand(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+	
+	@Override
+	public void quickUpdate(String key, Object val) {
+		Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null, null);
+		connection.write(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+
+	@Override
+	public void take(Receiver receiver, CodeSegment cs) {
+		int seq = this.seq.getAndIncrement();
+		Command cmd = new Command(CommandType.TAKE, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null);
+		seqHash.put(seq, cmd);
+		connection.sendCommand(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+	
+	public void quickTake(Receiver receiver, CodeSegment cs) {
+		int seq = this.seq.getAndIncrement();
+		Command cmd = new Command(CommandType.TAKE, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null, true);
+		seqHash.put(seq, cmd);
+		connection.write(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+
+	@Override
+	public void peek(Receiver receiver, CodeSegment cs) {
+		int seq = this.seq.getAndIncrement();
+		Command cmd = new Command(CommandType.PEEK, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null);
+		seqHash.put(seq, cmd);
+		connection.sendCommand(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+	
+	public void quickPeek(Receiver receiver, CodeSegment cs) {
+		int seq = this.seq.getAndIncrement();
+		Command cmd = new Command(CommandType.PEEK, receiver, receiver.key, null, receiver.index, seq, replyQueue, cs, null, true);
+		seqHash.put(seq, cmd);
+		connection.write(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+		
+	}
+
+	@Override
+	public void remove(String key) {
+		Command cmd = new Command(CommandType.REMOVE, null, key, null, 0, 0, null, null, null);
+		connection.sendCommand(cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
+
+	@Override
+	public void finish() {
+		Command cmd = new Command(CommandType.FINISH, null, null, null, 0, 0, null, null, null);
+		connection.sendCommand(cmd);
+	}
+
+	@Override
+	public void close() {
+		Command cmd = new Command(CommandType.CLOSE, null, null, null, 0, 0, null, null, null);
+		connection.sendCommand(cmd);
+	}
+
+	@Override
+	public void ping(String returnKey) {
+		Command cmd = new Command(CommandType.PING, null, returnKey, null, 0, 0, null, null, null);
+		connection.write(cmd);
+	}
+	
+	@Override
+	public void response(String returnKey) {
+		Command cmd = new Command(CommandType.RESPONSE, null, returnKey, null, 0, 0, null, null, null);
+		connection.write(cmd);
+	}
+
+	@Override
+	public void shutdown(String key) {
+		connection.close();
+	}
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/api/FlipCodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,21 @@
+package alice.test.codesegment.api;
+
+import alice.codesegment.CodeSegment;
+
+public class FlipCodeSegment extends CodeSegment{
+	
+	private String key;
+	public FlipCodeSegment(String _key){
+		this.key = _key;
+	}
+	
+	@Override
+	public void run() {
+		Integer num = 0;
+		ods.put(key, num);
+		
+		//System.out.println("Key is " +key);
+		new FlipTest(key);
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/api/FlipTest.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,38 @@
+package alice.test.codesegment.api;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class FlipTest extends CodeSegment{
+	
+	private Receiver arg1 = ids.create(CommandType.PEEK);
+	public static long t = 0;
+	public static boolean flag = false;
+	public static int count = 10000;
+	public FlipTest(String key){
+		arg1.setKey(key);
+	}
+	
+	public FlipTest(String key, int index){
+		arg1.setKey(key, index);
+	}
+
+	@Override
+	public void run() {
+		if(flag){
+			System.out.println(System.currentTimeMillis() - t +" ms");
+			System.exit(0);
+		}
+		t = System.currentTimeMillis();
+		for (int i=0;i<count;i++)
+			ods.flip(arg1);
+			//ods.put(arg1.key ,arg1.getObj());
+		flag=true;
+
+		new FlipTest(arg1.key,count);
+				
+	}
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/api/PeekCodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,29 @@
+package alice.test.codesegment.api;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class PeekCodeSegment extends CodeSegment{
+	private Receiver info0 = ids.create(CommandType.PEEK);
+	public PeekCodeSegment(String key) {
+		info0.setKey(key);
+	}
+
+	@Override
+	public void run() {
+		if (StartCodeSegment.count>10000){
+			System.out.println(System.currentTimeMillis()-StartCodeSegment.t +" ms");
+			StartCodeSegment.count = 0;
+			
+			if (++StartCodeSegment.cnt>100){
+				System.exit(0);
+			}
+		} else {
+			if(StartCodeSegment.count==1)StartCodeSegment.t = System.currentTimeMillis();
+			StartCodeSegment.count++;
+		}
+		new PeekCodeSegment(info0.key);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/api/PutCodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,32 @@
+package alice.test.codesegment.api;
+
+import alice.codesegment.CodeSegment;
+
+public class PutCodeSegment extends CodeSegment{
+	
+	private static int count = 0;
+	
+	@Override
+	public synchronized void run() {
+		
+		int[] array = new int[1000];
+		for (int i = 0;i< 999; i++)
+			array[i] = i;
+		
+		if (count % 10 == 0)
+			System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "MB");
+		if (count >= 10000000) {
+			System.exit(0);
+		}
+		ods.put("local", "num", array);
+		count++;
+		try {
+			wait(100);
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+		new PutCodeSegment().execute();
+	}
+	
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/api/StartCodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,54 @@
+package alice.test.codesegment.api;
+
+import java.util.Random;
+
+import alice.codesegment.CodeSegment;
+import alice.test.codesegment.local.bitonicsort.DataList;
+
+public class StartCodeSegment extends CodeSegment {
+	String[] args;
+	public static int count = 1;
+	public static int cnt = 1;
+	public static long t = 0;
+	
+	
+	public StartCodeSegment(String[] args){
+		this.args = args;
+	}
+
+	@Override
+	public void run() {
+		for (String arg : args) {
+			if ("-update".equals(arg)) {
+				UpdateCodeSegment cs1 = new UpdateCodeSegment();
+				cs1.ds1.setKey("key");
+				int[] array = new int[65536];
+				array[0] = 0;
+				ods.update("local", "key", array);
+
+			} else if ("-put".equals(arg)) {
+				new PutCodeSegment().execute();
+
+			} else if ("-take".equals(arg)) {
+				new PutCodeSegment().execute();
+				new TakeCodeSegment("num");
+
+			} else if ("-flip".equals(arg)) {
+				new FlipCodeSegment("key").execute();
+			} else if ("-peek".equals(arg)) {
+				System.out.println("start peek Test");
+				String key = "peek";
+				int size = 100000;
+				DataList list = new DataList(size);
+				Random rnd = new Random();
+				for (int cnt = 0; cnt < size; cnt++) {
+					list.table[cnt] = rnd.nextInt(100000) + 10;
+				}
+				ods.put(key, list);
+				new PeekCodeSegment(key);
+			}
+		}
+		 
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/api/TakeCodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,19 @@
+package alice.test.codesegment.api;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class TakeCodeSegment extends CodeSegment {
+	
+	Receiver ds1 = ids.create(CommandType.TAKE);
+	
+	public TakeCodeSegment(String key){
+		this.ds1.setKey(key);
+	}	
+	@Override
+	public void run() {
+		new TakeCodeSegment(ds1.key);
+		
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/api/TestApiAlice.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,16 @@
+package alice.test.codesegment.api;
+
+import alice.daemon.AliceDaemon;
+import alice.daemon.Config;
+
+public class TestApiAlice {
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		new AliceDaemon(new Config(args)).listen();
+		new StartCodeSegment(args).execute();
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/api/UpdateCodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,28 @@
+package alice.test.codesegment.api;
+
+import org.msgpack.type.Value;
+import org.msgpack.type.ValueFactory;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class UpdateCodeSegment extends CodeSegment {
+	Receiver ds1 = ids.create(CommandType.PEEK);
+
+	@Override
+	public void run() {
+		UpdateCodeSegment cs1 = new UpdateCodeSegment();
+		cs1.ds1.setKey("key", ds1.index);
+		Value[] array = ((Value)ds1.getVal()).asArrayValue().getElementArray();
+		int val = array[0].asIntegerValue().getInt();
+		if (val % 10 == 0)
+			System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "MB");
+		if (val >= 10000000) {
+			System.exit(0);
+		}
+		array[0] = ValueFactory.createIntegerValue(val + 1);
+		ods.update("local", "key", array);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/SingletonTestCodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,34 @@
+package alice.test.codesegment.local;
+
+import org.msgpack.type.Value;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class SingletonTestCodeSegment extends CodeSegment {
+	Receiver arg1 = ids.create(CommandType.PEEK);
+	private static SingletonTestCodeSegment instance = new SingletonTestCodeSegment();
+	private SingletonTestCodeSegment(){}
+	
+	public static SingletonTestCodeSegment getInstance(){
+		return instance;
+	}
+	
+	@Override
+	public void run() {
+		System.out.println("type = " + arg1.type);
+		System.out.println("index = " + arg1.index);
+		System.out.println("data = " + arg1.getVal());
+		System.out.println(((Value)arg1.getVal()).getType());
+		
+		if (arg1.index == 10) {
+			System.exit(0);
+			return;
+		}
+		
+		this.recycle();
+		ods.update("local", "key2", "String data");
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/StartCodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,20 @@
+package alice.test.codesegment.local;
+
+import alice.codesegment.CodeSegment;
+
+public class StartCodeSegment extends CodeSegment {
+
+	@Override
+	public void run() {
+		System.out.println("run StartCodeSegment");
+		
+		TestCodeSegment cs = new TestCodeSegment();
+		cs.arg1.setKey("key1"); // unbound datasegment key1 is created and connect to cs.
+								// cs is waiting for local.key1
+		System.out.println("create TestCodeSegment");
+		
+		ods.update("local", "key1", "String data"); // bind string data to datasegment local.key1
+													// this startup TestCodeSegment.
+ 	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/TestCodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,32 @@
+package alice.test.codesegment.local;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+import org.msgpack.type.Value;
+
+public class TestCodeSegment extends CodeSegment {
+	
+	// create input datasegment arg1
+	Receiver arg1 = ids.create(CommandType.PEEK);
+	
+	@Override
+	public void run() {
+		System.out.println("type = " + arg1.type);
+		System.out.println("index = " + arg1.index);
+		System.out.println("data = " + arg1.getVal());
+		System.out.println(((Value)arg1.getVal()).getType());
+		
+		if (arg1.index == 10) {
+			System.exit(0);
+			return;
+		}
+		
+		TestCodeSegment cs = new TestCodeSegment();
+		cs.arg1.setKey("key1", arg1.index);
+		
+		// DataSegment.get("local").update
+		ods.update("local", "key1", "String data");
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/TestLocalAlice.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,12 @@
+package alice.test.codesegment.local;
+
+import alice.daemon.AliceDaemon;
+import alice.daemon.Config;
+
+public class TestLocalAlice {
+	public static void main(String args[]) {
+		new AliceDaemon(new Config(args)).listen(); // logger off
+		new StartCodeSegment().execute();
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/bitonicsort/DataInfo.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,16 @@
+package alice.test.codesegment.local.bitonicsort;
+
+import org.msgpack.annotation.Message;
+
+@Message
+public class DataInfo {
+	public int index;
+	public int ptr;
+	
+	public DataInfo(){}
+	
+	public DataInfo(int _index, int _ptr){
+		index = _index;
+		ptr = _ptr;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/bitonicsort/DataList.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,75 @@
+package alice.test.codesegment.local.bitonicsort;
+
+import org.msgpack.annotation.Message;
+
+@Message
+public class DataList {
+
+	public int[] table;
+	
+	public DataList(int size){
+		table = new int[size];
+	}
+	
+	public DataList(int[] numbers){
+		table = numbers;
+	}
+	
+	public DataList createDataList(int start, int size){
+		int[] table2 = new int[size];
+		int end = start+size;
+		for (int i=start,j=0;i<end;i++,j++){
+			table2[j] = table[i];
+		}
+		return new DataList(table2);
+	}
+	
+	public void swap(int i, int j){
+		int tmp = table[i]; 
+		table[i] = table[j];
+		table[j] = tmp;
+	}
+	
+	public void showData(){
+		for (int aTable : table) {
+			System.out.print(aTable + " ");
+		}
+		System.out.println();
+	}
+	
+	public void showData(int range){
+		for(int i = 0;i<range;i++){
+			System.out.print(table[i]+ " ");
+			
+		}
+		System.out.println();
+	}
+	
+	public void showSize(){
+		System.out.print("size is "+this.table.length+". ");
+	}
+	
+	public int getSize(){
+		return this.table.length;
+	}
+
+	public static void merge(DataList list1, DataList list2) {
+		int[] t1 = list1.table; 
+		int[] t2 = list2.table; 
+		int[] t0 = list1.table.clone(); // copy to avoid destroy t1
+		int i = 0, j= 0,n=0;
+        while (i< t0.length) {
+            if (n>=t1.length) { // switch to the second list
+                t1 = t2; n = 0;
+            }
+            if (j>=t2.length || t0[i] < t2[j]) { 
+                t1[n] = t0[i];  // including when  j reaches end of t2
+                i++; n++;
+            } else {
+                t1[n] = t2[j];
+                j++; n++;
+            }
+        }               
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/bitonicsort/LocalBitonicSort.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,13 @@
+package alice.test.codesegment.local.bitonicsort;
+
+import alice.daemon.AliceDaemon;
+import alice.daemon.Config;
+
+public class LocalBitonicSort {
+	public static void main(String[] args){
+		new AliceDaemon(new Config(args)).listen(); // logger off
+		
+		SortConfig conf = new SortConfig(args);
+		new SetInfo(conf).execute();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/bitonicsort/MakeData.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,31 @@
+package alice.test.codesegment.local.bitonicsort;
+
+import java.util.Random;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class MakeData extends CodeSegment {
+	
+	private Receiver info1 = ids.create(CommandType.PEEK);
+	private Receiver info2 = ids.create(CommandType.TAKE);
+
+	public MakeData(){
+		info1.setKey("sortconf");
+		info2.setKey("data");
+	}
+	
+	@Override
+	public void run() {
+		// This conversion over head should be remove.
+		SortConfig conf = info1.asClass(SortConfig.class);
+		DataList list = info2.asClass(DataList.class);
+		int size = conf.getLength();
+		Random rnd = new Random();
+		for (int i = 0; i < size; i++){
+			list.table[i] = rnd.nextInt(100000)+10;
+		}
+		ods.update("list", list);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/bitonicsort/RangeInfo.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,16 @@
+package alice.test.codesegment.local.bitonicsort;
+
+import org.msgpack.annotation.Message;
+
+@Message
+public class RangeInfo {
+	public int range;
+	public boolean lastFlag;
+	
+	public RangeInfo(){}
+	public RangeInfo(int i,boolean flag){
+		range = i;
+		lastFlag = flag;
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/bitonicsort/SetInfo.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,40 @@
+package alice.test.codesegment.local.bitonicsort;
+
+import alice.codesegment.CodeSegment;
+
+public class SetInfo extends CodeSegment {
+
+	private SortConfig conf;
+	public static String[] range;
+	public static String[] array;
+	public static String[] count;
+	
+	public SetInfo(SortConfig conf) {
+		this.conf = conf;
+	}
+
+	@Override
+	public void run() {
+		ods.put("sortconf", conf);
+		ods.put("data", new DataList(conf.length));
+		// sortconf and datasegments should be passed directory.
+		
+		create_keys();
+		new MakeData();
+		new SetTask();
+	}
+
+	private void create_keys() {
+		range = new String[conf.length];
+		array = new String[conf.length];
+		count = new String[conf.length];
+		
+		for(int i = 0 ; i < conf.length ; i++) {
+			range[i] = "range" + i;
+			array[i] = "array" + i;
+			count[i] = "count" + i;
+		}
+		
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/bitonicsort/SetTask.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,48 @@
+package alice.test.codesegment.local.bitonicsort;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class SetTask extends CodeSegment {
+	public static long t;
+	private Receiver info1 = ids.create(CommandType.PEEK);
+	private Receiver info2 = ids.create(CommandType.TAKE);
+	
+	SetTask(){
+		info1.setKey("sortconf");
+		info2.setKey("list");
+	}
+	
+	@Override
+	public void run() {
+		SortConfig conf = info1.asClass(SortConfig.class);
+		DataList list = info2.asClass(DataList.class);
+		
+		int sort_count = conf.getSplitNum()*2;
+		ods.put("sort_count", sort_count*2);
+	
+		int block_num = (conf.getLength() + sort_count- 1) / sort_count;
+		ods.put("block_num", block_num);
+		
+		System.out.println("sort start");
+		t = System.currentTimeMillis();
+		{
+			int i;
+			for (i = 0; i < sort_count / 2; i++) {
+				// anonymous datasegmaents should be used.
+				ods.put(SetInfo.range[i], new RangeInfo(i,i==(sort_count/2)-1));
+				ods.update(SetInfo.array[i*2], list.createDataList(i*2*block_num, block_num));
+				ods.update(SetInfo.array[i*2+1], list.createDataList((i*2+1)*block_num, block_num));
+				ods.update(SetInfo.count[i], 0);
+				new SortPhase(SetInfo.range[i],SetInfo.array[i*2],SetInfo.array[i*2+1],0,SetInfo.count[i]);
+				
+			}
+			new ShowData(i*2, sort_count);
+			
+		}
+		
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/bitonicsort/ShowData.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,43 @@
+package alice.test.codesegment.local.bitonicsort;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class ShowData extends CodeSegment{
+	
+	private Receiver[] info;
+	
+	public ShowData(int cnt, int index) {
+		info = new Receiver[cnt];
+		for (int i= 0;i < cnt; i++)
+			info[i] = ids.create(CommandType.PEEK);
+		for (int i= 0;i < cnt; i++)
+			info[i].setKey(SetInfo.array[i],index);
+		
+	}
+	
+	@Override
+	public void run() {
+		System.out.println(System.currentTimeMillis() -SetTask.t +" ms");
+		int size = 0;
+		for (Receiver anInfo : info) {
+			DataList dlist = anInfo.asClass(DataList.class);
+			size += dlist.table.length;
+		}
+		
+		DataList list = new DataList(size);
+		
+		int start = 0;
+		for (Receiver anInfo : info) {
+			DataList dlist = anInfo.asClass(DataList.class);
+			System.arraycopy(dlist.table, 0, list.table, start, dlist.table.length);
+			start += dlist.table.length;
+		}
+		System.out.println("size check :"+ list.table.length);
+		Sort.check(list);
+		System.exit(0);
+	}
+	
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/bitonicsort/Sort.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,63 @@
+package alice.test.codesegment.local.bitonicsort;
+
+public class Sort {
+	
+	// this method has "stack overflow" problem
+	public static void quickSort(DataList data){
+		int[] stack = new int[8192];
+		int sp = 0;
+		int begin = 0;
+		int end = data.table.length-1; // index is up to length-1
+		while(true){
+			while(begin < end){
+				if (end-begin< 40){
+					bubbleSort(data,begin,end);
+					break;
+				} else {
+					int where = (begin+end)/2;
+					int pivot = data.table[where];
+					data.table[where] = data.table[begin];
+					int p = begin;
+					for (int i=begin+1;i<=end;i++){
+						if (data.table[i]<pivot){
+							p++;
+							if (i!=p)data.swap(p,i);
+						}
+					}
+					data.table[begin] = data.table[p];
+					data.table[p] = pivot;
+					stack[sp++] = p+1;
+					stack[sp++] = end;
+					end=p-1;
+				}
+			}
+			if (sp==0) return;
+			end = stack[--sp];
+			begin = stack[--sp];
+			
+		}
+	}
+	
+	public static void bubbleSort(DataList data ,int begin,int end){
+		for (int i=begin;i<end;i++){
+			for (int j=end;j>i;j--){
+				if (data.table[i] > data.table[j]){
+					data.swap(i,j);
+				}
+			}
+		}
+		
+		
+	}
+	
+	public static void check(DataList data){
+		System.out.println("checking ....");
+		for (int i = 0; i< data.table.length-1; i++){
+			if (data.table[i] > data.table[i+1]){
+				System.out.println("MISS "+data.table[i]+" > "+data.table[i+1]+" Position is "+i);
+				return;
+			}
+		}
+		System.out.println("sort is succeed");
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/bitonicsort/SortConfig.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,39 @@
+package alice.test.codesegment.local.bitonicsort;
+
+import org.msgpack.annotation.Message;
+
+@Message
+public class SortConfig {
+	public int length = 1200;
+	public int MAX_BLOCK_SIZE = 1024;
+	public int cpu = 1;
+	
+	public SortConfig(){}
+	
+	public SortConfig(String[] args){
+		for (int i=0;i<args.length; i++){
+			if ("-l".equals(args[i])){
+				length = Integer.parseInt(args[++i]);	
+			} else if ("-b".equals(args[i])){
+				MAX_BLOCK_SIZE = Integer.parseInt(args[++i]);	
+			}
+		}
+		if (length<MAX_BLOCK_SIZE) MAX_BLOCK_SIZE = length;
+	}
+
+	public int getLength() {
+		return length;
+	}
+
+	public int getblockSize() {
+		return MAX_BLOCK_SIZE;
+	}
+	
+	public int getSplitNum(){
+		if (length / cpu < MAX_BLOCK_SIZE){
+			return cpu;
+		} else {
+			return (length + MAX_BLOCK_SIZE -1) / MAX_BLOCK_SIZE;
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/bitonicsort/SortPhase.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,60 @@
+package alice.test.codesegment.local.bitonicsort;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class SortPhase extends CodeSegment{
+	private Receiver info0 = ids.create(CommandType.PEEK); // range
+	private Receiver info1 = ids.create(CommandType.TAKE); // Array1
+	private Receiver info2 = ids.create(CommandType.TAKE); // Array2
+	private Receiver info3 = ids.create(CommandType.PEEK); // sort_count
+	private Receiver info4 = ids.create(CommandType.TAKE); // count
+	
+	
+	public SortPhase(String key0, String key1, String key2, int index, String key4){
+		info0.setKey(key0);
+		info1.setKey(key1,index);
+		info2.setKey(key2,index);
+		info3.setKey("sort_count");
+		info4.setKey(key4);
+	}
+	
+	@Override
+	public void run() {
+		RangeInfo info = info0.asClass(RangeInfo.class);
+		DataList list1 = info1.asClass(DataList.class);
+		DataList list2 = info2.asClass(DataList.class);
+		int sort_count = info3.asInteger();
+		int count = info4.asInteger();
+		
+		int i = info.range;
+		//System.out.println("CS"+i+" "+info1.key+" "+info2.key+" dataIndex "+info1.index +" count "+count);
+		Sort.quickSort(list1);
+		Sort.quickSort(list2);
+		DataList.merge(list1,list2);
+		
+		if (count%2==0&&i==0){
+			ods.flip(info1); // first block index is less than others. So put data twice.
+		} else if (count%2==0&&info.lastFlag){
+			ods.flip(info2); // Same reason 
+		}
+		
+		ods.flip(info1);
+		ods.flip(info2);
+		
+		if (count%2==0&&info.lastFlag&&count+2<sort_count/2){
+			new SortPhase(info0.key, info1.key, info2.key,count+2,info4.key);
+			ods.update(info4.key, count+2);
+		} else {
+			String f = (count%2==1) ? SetInfo.array[2*i] : SetInfo.array[2*i+1];
+			String b = (count%2==1) ? SetInfo.array[2*i+1] : SetInfo.array[2*i+2];
+			
+			new SortPhase(info0.key, f, b, count+1, info4.key);
+			ods.update(info4.key, count+1);
+		}
+		
+		
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/bitonicsort/SortTest.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,55 @@
+package alice.test.codesegment.local.bitonicsort;
+
+import java.util.Random;
+
+public class SortTest {
+	
+	public static void main(String args[]){
+		int size1 = 1000000;
+		int size2 = 1000;
+		int MAX = 1000000;
+		long t;
+		DataList list1 = new DataList(size1);
+		DataList list2 = new DataList(size1);
+		DataList list3 = new DataList(size2);
+		
+		Random rnd = new Random();
+		for (int i = 0; i < size1; i++){
+			int num = rnd.nextInt(MAX)+10;
+			list1.table[i] = num;
+			list2.table[i] = num;
+		}
+		for (int i = 0; i < size2; i++){
+			int num = rnd.nextInt(MAX)+10;
+			list3.table[i] = num;
+		}
+		
+		// bubbleSort
+		t = System.currentTimeMillis();
+		Sort.bubbleSort(list3,0,list3.table.length-1);
+		System.out.println("bubble sort : "+ (System.currentTimeMillis()-t)+" ms");
+		Sort.check(list3);
+		
+		// quickSort
+		t = System.currentTimeMillis();
+		Sort.quickSort(list1);
+		System.out.println("quick sort1 : "+ (System.currentTimeMillis()-t)+" ms");
+		Sort.check(list1);
+		
+		t = System.currentTimeMillis();
+		Sort.quickSort(list2);
+		System.out.println("quick sort2 : "+ (System.currentTimeMillis()-t)+" ms");
+		Sort.check(list2);
+		
+		// merge Test
+	    DataList.merge(list1, list2);
+	    Sort.check(list1);
+	    Sort.check(list2);
+	    
+	    // separate Test
+	    list1.showData(50);
+	    list1.createDataList(0, 25).showSize();
+	    list1.createDataList(0, 25).showData();
+	    list1.createDataList(25, 25).showData();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/wordcount/CorrectResult.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,36 @@
+package alice.test.codesegment.local.wordcount;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class CorrectResult extends CodeSegment{
+
+	private Receiver[] array;
+	
+	public CorrectResult(int size) {
+		array = new Receiver[size];
+		for (int i=0;i<size;i++){
+			array[i] = ids.create(CommandType.TAKE);
+		}
+		for (int i=0;i<size;i++)
+			array[i].setKey("result");
+	}
+
+	@Override
+	public void run() {
+		int line_num = 0;
+		int word_num = 0;
+		Result result;
+		for (Receiver anArray : array) {
+			result = anArray.asClass(Result.class);
+			line_num += result.line_num;
+			word_num += result.word_num;
+		}
+		System.out.println(System.currentTimeMillis() - StartWordCount.t);
+		System.out.println(line_num+" "+word_num);
+		System.exit(0);
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/wordcount/Range.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,16 @@
+package alice.test.codesegment.local.wordcount;
+
+public class Range {
+
+	public char[] array;
+	public char nextchar;
+	
+	public Range(int size){
+		this.array = new char[size];
+	}
+
+	public Range(char[] _array) {
+		this.array = _array;
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/wordcount/ReadFileTest.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,46 @@
+package alice.test.codesegment.local.wordcount;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+public class ReadFileTest {
+	
+	public static void main(String[] args){
+		WordConfig conf = new WordConfig(args);
+		BufferedReader br = null;
+		int i = 0;
+		try {
+			br= new BufferedReader(
+					new InputStreamReader(
+							new FileInputStream(
+									new File(conf.filename)
+									)));
+			int size = 4; // Kbyte
+			
+			Range range = new Range(size);
+			int check = br.read(range.array);
+			for (;check!=-1;i++){
+			
+				char[] array;
+				array = new char[size];
+				check = br.read(array);
+				range.nextchar = array[0];
+				System.out.print(range.array); // ods
+				System.out.println(range.nextchar);
+				range = new Range(array);
+			} 
+			System.out.println(i);
+		} catch (FileNotFoundException e) {
+			System.out.println("file was not found");
+			System.exit(1);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/wordcount/Result.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,14 @@
+package alice.test.codesegment.local.wordcount;
+
+import org.msgpack.annotation.Message;
+
+@Message
+public class Result {
+	public int line_num;
+	public int word_num;
+	
+	public Result(int line,int word){
+		line_num = line;
+		word_num = word;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/wordcount/SeparateArray.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,53 @@
+package alice.test.codesegment.local.wordcount;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import alice.codesegment.CodeSegment;
+
+public class SeparateArray extends CodeSegment{
+	private WordConfig conf;
+	
+	SeparateArray(WordConfig conf){
+		this.conf = conf;
+	}
+	
+	@Override
+	public void run() {	
+		// cpu分だけTaskをあらかじめ作成
+	 	int cpu_num = Runtime.getRuntime().availableProcessors();
+	 	for (int cnt =0;cnt < cpu_num;cnt++){
+	 		new WordCount();
+	 	}
+		BufferedReader br = null;
+		int i = 0;
+		try {
+			br= new BufferedReader(
+					new InputStreamReader(
+							new FileInputStream(
+									new File(conf.filename)
+									)));
+			int size = conf.division * 1024; // Kbyte
+			Range range = new Range(size);
+			int check = br.read(range.array);
+			for (;check!=-1;i++){			
+				char[] array;
+				array = new char[size];
+				check = br.read(array);
+				range.nextchar = array[0];
+				ods.put("array", range);
+				range = new Range(array);
+			} 
+			new CorrectResult(i);
+		} catch (FileNotFoundException e) {
+			System.exit(1);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/wordcount/StartWordCount.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,16 @@
+package alice.test.codesegment.local.wordcount;
+
+import alice.daemon.AliceDaemon;
+import alice.daemon.Config;
+
+
+public class StartWordCount {
+	public static long t = System.currentTimeMillis();
+	public static void main(String[] args){
+		
+		new AliceDaemon(new Config(args)).listen(); // logger off
+		
+		WordConfig conf = new WordConfig(args);
+		new SeparateArray(conf).execute();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/wordcount/WordConfig.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,23 @@
+package alice.test.codesegment.local.wordcount;
+
+public class WordConfig {
+	public String filename;
+	public static String[] array;
+	public int division = 16;
+	
+	public WordConfig(String[] args) {
+		for (int i=0;i<args.length; i++){
+			if ("-f".equals(args[i])){
+				filename = args[++i];	
+			} else if ("-d".equals(args[i])){
+				division = Integer.parseInt(args[++i]);	
+			}
+		}
+		
+		if (filename==null){
+			System.out.println("Usage: WordCount -f FILENAME");
+			System.exit(0);
+		}
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/local/wordcount/WordCount.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,47 @@
+package alice.test.codesegment.local.wordcount;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class WordCount extends CodeSegment{
+	
+	private Receiver info1 = ids.create(CommandType.TAKE);
+	
+	public WordCount(){
+		info1.setKey("array");
+	}
+
+	@Override
+	public void run() {
+		Range r = info1.asClass(Range.class);
+		int word_flag = 0;
+	    int word_num = 0;
+	    int line_num = 0;
+	    int i = 0;
+		for (; i < r.array.length; i++) {
+			if (r.array[i] == 0x20) { // 空白                                                                                                                                
+				word_flag = 1;
+			} else if (r.array[i] == 0x0A) { // 改行
+				line_num += 1;
+				word_flag = 1;
+			} else {
+				word_num += word_flag;
+				word_flag = 0;
+			}
+		}
+		word_num += word_flag;
+		if (r.nextchar!='\0'){ // null means last block
+			if ((r.array[i-1] == 0x0A||r.array[i-1] == 0x20) &&
+					(r.nextchar == 0x0A||r.nextchar == 0x20)){
+				word_num--;
+			}
+		}
+		
+		Result result = new Result(line_num,word_num);
+		ods.put("result", result);
+		recycle();//new WordCount();
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/remote/RemoteIncrement.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,26 @@
+package alice.test.codesegment.remote;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class RemoteIncrement extends CodeSegment {
+
+	public Receiver num = ids.create(CommandType.TAKE);
+	
+	/**
+	 * Increment DataSegment value up to 10
+	 */
+	@Override
+	public void run() {
+		int num = this.num.asInteger();
+		System.out.println("[CodeSegment] " + num++);
+		if (num == 10) System.exit(0);
+
+		RemoteIncrement cs = new RemoteIncrement();
+		cs.num.setKey("remote", "num");
+		
+		ods.put("local", "num", num);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/remote/RemoteStartCodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,15 @@
+package alice.test.codesegment.remote;
+
+import alice.codesegment.CodeSegment;
+
+public class RemoteStartCodeSegment extends CodeSegment {
+	
+	@Override
+	public void run() {
+		RemoteIncrement cs = new RemoteIncrement();
+		cs.num.setKey("remote", "num");
+		
+		ods.put("local", "num", 0);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/remote/TestRemoteAlice.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,16 @@
+package alice.test.codesegment.remote;
+
+import alice.daemon.AliceDaemon;
+import alice.datasegment.DataSegment;
+
+public class TestRemoteAlice {
+
+	public static void main(String[] args) {
+		TestRemoteConfig conf = new TestRemoteConfig(args);
+
+		new AliceDaemon(conf).listen();
+		DataSegment.connect(conf.key, "", conf.hostname, conf.connectPort, false);
+		new RemoteStartCodeSegment().execute();
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/codesegment/remote/TestRemoteConfig.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,24 @@
+package alice.test.codesegment.remote;
+
+import alice.daemon.Config;
+
+public class TestRemoteConfig extends Config {
+
+	public String hostname;
+	public int connectPort = 10000;
+	public String key;
+
+	public TestRemoteConfig(String[] args) {
+		super(args);
+		for (int i = 0; i< args.length; i++) {
+			if ("-h".equals(args[i])) {
+				hostname = args[++i];
+			} else if ("-cp".equals(args[i])) {
+				connectPort = Integer.parseInt(args[++i]);
+			} else if ("-key".equals(args[i])) {
+				key = args[++i];
+			}
+		}
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/concurrent/AliceConcurrentTest.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,18 @@
+package alice.test.concurrent;
+
+public class AliceConcurrentTest {
+
+	public static void main(String args[]) {
+		
+		int count = 1;
+		
+		for (int i = 0; i< args.length; i++) {
+			if ("-c".equals(args[i])) {
+				count = Integer.parseInt(args[++i]);
+			}
+		}
+		
+		new StartConcurrent(count).execute();
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/concurrent/AliceFinish.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,25 @@
+package alice.test.concurrent;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class AliceFinish extends CodeSegment {
+
+	private int num;
+	
+	public Receiver ds1 = ids.create(CommandType.TAKE);
+	
+	public AliceFinish(int threadNum) {
+		this.num = threadNum; 
+	}
+
+	@Override
+	public void run() {
+		if (--num == 0) System.exit(0);
+		
+		AliceFinish cs1 = new AliceFinish(num);
+		cs1.ds1.setKey("finish");
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/concurrent/SleepCodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,31 @@
+package alice.test.concurrent;
+
+import org.msgpack.type.ValueFactory;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class SleepCodeSegment extends CodeSegment {
+
+	public Receiver ds1 = ids.create(CommandType.TAKE);
+	
+	private int num;
+	
+	public SleepCodeSegment(int i) {
+		this.num = i;
+	}
+
+	@Override
+	public void run() {
+		try {
+			Thread.sleep(1000);
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+		System.out.println("[CodeSegment-" + num + "] Hello, World!");
+		
+		ods.put("local", "finish", ValueFactory.createNilValue());
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/concurrent/StartConcurrent.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,32 @@
+package alice.test.concurrent;
+
+import org.msgpack.type.ValueFactory;
+
+import alice.codesegment.CodeSegment;
+
+public class StartConcurrent extends CodeSegment {
+
+	private int count;
+	
+	public StartConcurrent(int count) {
+		this.count = count;
+	}
+
+	@Override
+	public void run() {
+		int threadNum = Runtime.getRuntime().availableProcessors() * count;
+		
+		AliceFinish cs1 = new AliceFinish(threadNum);
+		cs1.ds1.setKey("finish");
+		
+		for (int i = 0; i < threadNum; i++) {
+			SleepCodeSegment cs2 = new SleepCodeSegment(i);
+			cs2.ds1.setKey("wait");
+		}
+		
+		for (int i = 0; i < threadNum; i++) {
+			ods.put("local", "wait", ValueFactory.createNilValue());
+		}
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/reflection/CSTemplate.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,16 @@
+package alice.test.reflection;
+
+import alice.codesegment.CodeSegment;
+
+public class CSTemplate extends CodeSegment{
+
+	public CSTemplate(){
+		
+	}
+	
+	@Override
+	public void run() {
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/reflection/ReflectionTest.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,51 @@
+package alice.test.reflection;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtConstructor;
+import javassist.CtField;
+import javassist.CtMethod;
+
+public class ReflectionTest {
+
+	public static void main(String[] args){
+		try {
+			new ReflectionTest().createCS();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		System.out.println("TEST END");
+	}
+
+	public void createCS() throws Exception{
+		
+		ClassPool cp = ClassPool.getDefault();
+		CtClass tep = cp.get("alice.test.reflection.CSTemplate");
+		CtClass rec = cp.get("alice.datasegment.Receiver");
+
+		// ---- define Field -----
+		//CtField f1 = CtField.make("alice.datasegment.Receiver arg1 = ids.create(alice.datasegment.CommandType.PEEK);", tep);
+		//tep.addField(f1);
+		CtField f1 = new CtField(rec,"arg1",tep);
+		tep.addField(f1,"ids.create(alice.datasegment.CommandType.PEEK)");
+
+		// ---- define Constructor -----
+		CtConstructor c = tep.getConstructor("()V");
+		c.insertAfter("arg1.setKey(\"key1\");");
+
+		// ---- define run -----
+		CtMethod m = tep.getMethod("run", "()V");
+		m.insertAfter("System.out.println(\"type = \" + arg1.type);");
+		m.insertAfter("System.out.println(\"index = \" + arg1.index);");
+		m.insertAfter("System.out.println(\"data = \" + arg1.getVal());");
+		m.insertAfter("System.out.println(((org.msgpack.type.Value)arg1.getVal()).getType());");
+		m.insertAfter("if (arg1.index==10){ System.exit(0);}");
+		m.insertAfter("new alice.test.reflection.CSTemplate();");
+		m.insertAfter("ods.update(\"key1\", \"String Data\");");
+
+		Class<?> clazz = tep.toClass(); // load Class 
+		@SuppressWarnings("unused")
+		CSTemplate cs = (CSTemplate)clazz.newInstance(); // create instance
+		
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/AutoIncrement.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,47 @@
+package alice.test.topology.aquarium;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class AutoIncrement extends CodeSegment {
+	
+	private Receiver position = ids.create(CommandType.PEEK);
+	private Receiver number = ids.create(CommandType.PEEK);
+	private static final float MIN = -1.3f;
+	
+	public AutoIncrement(String key, int index) {
+		this.number.setKey("maxsize");
+		this.position.setKey(key, index);
+	}
+
+	@Override
+	public void run() {
+		float max = this.number.asInteger() * 2 - 1 + 0.3f;
+		FishPoint fp = this.position.asClass(FishPoint.class);
+		if (fp.getX() + 0.01 > max) {
+			fp.setXYZ(MIN, fp.getY(), fp.getZ());
+		} else if (fp.getX() + 0.01 < MIN) {
+			fp.setXYZ(max, fp.getY(), fp.getZ());
+		}
+		else {
+			fp.setXYZ(fp.getX() + 0.01f, fp.getY(), fp.getZ());
+		}
+		
+		ods.update(position.key, fp);
+		synchronized (this) {
+			try {
+				// TODO
+				// Waiting should be done in Alice kernel
+				// ids.create(CommandType.WAIT);
+			 
+				wait(20);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+		}
+		
+		new AutoIncrement(this.position.key, this.position.index);
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/CheckLocalIndex.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,33 @@
+package alice.test.topology.aquarium;
+
+import java.util.List;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class CheckLocalIndex extends CodeSegment {
+
+	private Receiver data = ids.create(CommandType.PEEK);
+	private Receiver list = ids.create(CommandType.PEEK);
+	
+	public CheckLocalIndex(String key, int index){
+		this.list.setKey("_CLIST");
+		this.data.setKey(key, index);
+	}
+	
+	@Override
+	public void run() {
+		@SuppressWarnings("unchecked")
+		List<String> r = list.asClass(List.class);
+		for (String node : r) {
+			if (!node.equals(data.from)) {
+				System.out.println(data.from);
+				ods.update(node, data.key, data.getVal());
+			}
+		}
+		new CheckLocalIndex(data.key, data.index);
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/CheckMyName.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,97 @@
+package alice.test.topology.aquarium;
+
+import java.util.Random;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+
+public class CheckMyName extends CodeSegment {
+ 	private Receiver host = ids.create(CommandType.PEEK);
+	private Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
+	private String key = "fish";
+	
+	public CheckMyName(){
+		host.setKey("host");
+	}
+	
+	@Override
+	public void run(){
+		String name = host.asString();
+		Matcher matcher = pattern.matcher(name);
+		
+		matcher.find();
+		String type = matcher.group(1);
+		int num = new Integer(matcher.group(2));
+		ods.put("host_num", num*2);
+		MakeFrame frame =  new MakeFrame(name,num*2);
+		ods.put("num", 1);
+		
+		if (type.equals("cli")){
+			System.out.println("cli"+num);
+			new TakeMynum();	
+		}else if (type.equals("node")){
+			System.out.println("node"+num);
+			if (num != 0){
+				new TakeMynum();
+			} else {
+				new SendMaxsize(0);
+			}
+		}
+		new CheckLocalIndex("maxsize",0);
+		
+		ods.update(key, new FishPoint(-0.1f,-0.1f));
+		new SetLocation(new MakeObject(frame), key, 0);
+		new CheckLocalIndex(key,1);
+		for (int i = 0; i < 3 ; i++){
+			key = "fish"+i;
+			if (num == 0) new AutoIncrement(key,0);
+			ods.update(key, new FishPoint((float)Math.random(),
+					(float)Math.random(), (float)Math.random()));
+			new SetLocation(new MakeObject(frame), key, 0);
+			new CheckLocalIndex(key,1);
+		}
+		
+		for (int i = 3; i < 6 ; i++){
+			key = "fish"+i;
+			if (num == 1) new AutoIncrement(key,0);
+			Random rnd = new Random();
+			int tmp = rnd.nextInt(3);
+			int rand = tmp + 1;
+			ods.update(key, new FishPoint( (float)rand, 
+					-(float)Math.random(), -(float)Math.random()));
+			new SetLocation(new MakeObject(frame), key, 0);
+			new CheckLocalIndex(key,1);
+		}
+		
+		for (int i = 6; i < 9 ; i++){
+			key = "fish"+i;
+			if (num == 2) new AutoIncrement(key,0);
+			Random rnd = new Random();
+			int tmp = rnd.nextInt(3); 
+			int rand = tmp + 3;
+			ods.update(key, new FishPoint( (float)rand, 
+					(float)Math.random(), -(float)Math.random()));
+			new SetLocation(new MakeObject(frame), key, 0);
+			new CheckLocalIndex(key,1);
+		}
+		
+		for (int i = 9; i < 12 ; i++){
+			key = "fish"+i;
+			if (num == 3) new AutoIncrement(key,0);
+			
+			Random rnd = new Random();
+			int tmp = rnd.nextInt(3); 
+			int rand = tmp + 5;
+			
+			ods.update(key, new FishPoint( (float)rand, 
+					-(float)Math.random(), (float)Math.random()));
+			new SetLocation(new MakeObject(frame), key, 0);
+			new CheckLocalIndex(key,1);
+		}
+		
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/FishMovementConfig.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,12 @@
+package alice.test.topology.aquarium;
+
+import alice.topology.node.TopologyNodeConfig;
+
+public class FishMovementConfig extends TopologyNodeConfig {
+	
+	public FishMovementConfig(String[] args){
+		super(args);
+	} 
+	
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/FishMovementTopology.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,11 @@
+package alice.test.topology.aquarium;
+import alice.topology.node.TopologyNode;
+
+public class FishMovementTopology {
+	public static void main(String[] args){
+		FishMovementConfig conf = new FishMovementConfig(args);
+		new TopologyNode(conf, new StartFishMovement());
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/FishPoint.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,48 @@
+package alice.test.topology.aquarium;
+
+import org.msgpack.annotation.Message;
+
+@Message
+public class FishPoint {
+	// public fields are serialized.
+	public float x = 0.0f;
+	public float y = 0.0f;
+	public float z = 0.0f;
+	
+	public FishPoint(){}
+	
+	public FishPoint(float x,float y){
+		this.x = x;
+		this.y = y;
+	}
+	
+	public FishPoint(float x,float y,float z){
+		this.x = x;
+		this.y = y;
+		this.z = z;
+	}
+	
+	public void setXY(float x,float y){
+		this.x = x;
+		this.y = y;
+	}
+	
+	public void setXYZ(float x,float y,float z){
+		this.x = x;
+		this.y = y;
+		this.z = z;
+	}
+	
+	public float getX(){
+		return this.x;
+	}
+	
+	public float getY(){
+		return this.y;
+	}
+	
+	public float getZ(){
+		return this.z;
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/KeyInputCodeSegment.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,55 @@
+package alice.test.topology.aquarium;
+
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+public class KeyInputCodeSegment implements KeyListener{
+		
+	MakeFrame frame;
+	public KeyInputCodeSegment(MakeFrame frame) {
+		this.frame = frame;
+	}
+
+	@Override
+	public void keyPressed(KeyEvent event) {
+		//System.out.println(event.getKeyCode());
+		switch(event.getKeyCode())
+		{
+		case 37: // left
+			new SendLocation(-0.1f,0.0f,0.0f); 
+			break;
+		case 38: // up
+			new SendLocation(0.0f,0.1f,0.0f);
+			break;
+		case 39: // right
+			new SendLocation(0.1f,0.0f,0.0f);
+			break;
+		case 40: // down
+			new SendLocation(0.0f,-0.1f,0.0f);
+			break;
+		case 76: // l
+			new SendLocation(0.0f,0.0f,0.1f);
+			break;
+		case 78: // "n"
+			new RefreshWindow(frame);
+			break;
+		case 79: // "o"
+			new SendLocation(0.0f,0.0f,-0.1f);
+			break;
+		case 82: // "r"
+			new ResetFish().execute();
+			break;
+		}
+	}
+
+	@Override
+	public void keyReleased(KeyEvent event) {
+		
+	}
+
+	@Override
+	public void keyTyped(KeyEvent event) {
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/MakeFrame.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,114 @@
+package alice.test.topology.aquarium;
+
+import java.awt.GraphicsConfiguration;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import javax.imageio.ImageIO;
+import javax.media.j3d.Background;
+import javax.media.j3d.BoundingSphere;
+import javax.media.j3d.BranchGroup;
+import javax.media.j3d.DirectionalLight;
+import javax.media.j3d.ImageComponent2D;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.vecmath.Color3f;
+import javax.vecmath.Point3d;
+import javax.vecmath.Vector3f;
+
+import com.sun.j3d.utils.universe.SimpleUniverse;
+
+public class MakeFrame {
+	
+	private static final int F_SIZE_X = 800;
+	private static final int F_SIZE_Y = 800;
+	private ViewChange canvas;
+	private JFrame frame;
+	private ObjectList list = new ObjectList();
+	
+	public MakeFrame(String str,float x) {
+	    System.loadLibrary("jawt"); 
+		frame = new JFrame(str);
+		frame.setSize(F_SIZE_X, F_SIZE_Y);
+		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+		
+		JPanel cp = new JPanel();
+		cp.setLayout(null);
+		frame.add(cp);
+		
+		GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
+		canvas = new ViewChange(x,0.01f,config);
+		canvas.setBounds(0,0, F_SIZE_X, F_SIZE_Y);
+		cp.add(canvas);
+		
+		canvas.universe.addBranchGraph(createLight());
+		canvas.universe.addBranchGraph(setBackground());
+		
+		canvas.addKeyListener(new KeyInputCodeSegment(this));
+		frame.setVisible(true);
+		
+	}
+	
+	private BranchGroup setBackground() {
+		BranchGroup scene = new BranchGroup();
+		BufferedImage img = null;
+		try {
+			URL url = getClass().getClassLoader().getResource("image1.jpg");
+			if (url!=null) {
+			    img = ImageIO.read(url);
+			} else {
+			    img = ImageIO.read(new File("image/image1.jpg"));
+			}
+		} catch (IOException e) {
+		  	e.printStackTrace();
+		}
+		ImageComponent2D image = 
+				new ImageComponent2D(ImageComponent2D.FORMAT_RGBA8,img);
+		Background background = new Background(image);
+		background.setImageScaleMode(Background.SCALE_FIT_ALL);
+		BoundingSphere bounds = new BoundingSphere(new Point3d(), 10.0);
+		background.setApplicationBounds(bounds);
+		scene.addChild(background);
+		return scene;
+		
+	}
+	
+	private BranchGroup createLight() {
+		BranchGroup scene = new BranchGroup();
+		Color3f light_color  = new Color3f(1.7f,1.7f,1.7f);
+		Vector3f light_direction = new Vector3f(0.0f,0.0f,-1.0f);
+		DirectionalLight light = new DirectionalLight(light_color,light_direction);
+		BoundingSphere bounds = new BoundingSphere(new Point3d(), 10.0);
+		light.setInfluencingBounds(bounds);
+		scene.addChild(light);
+		return scene;
+	}
+	
+	public void register(MakeObject obj){
+		list.table.add(obj);
+		BranchGroup group = obj.createBranch();
+		this.canvas.universe.addBranchGraph(group);
+	}
+	
+	public ViewChange getCanvas(){
+		return this.canvas;
+	}
+	
+	public JFrame getJFrame(){
+		return this.frame;
+	}
+	
+	public ObjectList getList(){
+		return this.list;
+	}
+	
+	static public void main(String [] args) {
+	    MakeFrame test = new MakeFrame("Test", 0);
+	    test.setBackground();
+	    test.createLight();
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/MakeObject.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,115 @@
+package alice.test.topology.aquarium;
+
+import java.awt.Image;
+import java.awt.MediaTracker;
+import java.awt.Toolkit;
+import java.io.FileNotFoundException;
+import java.net.URL;
+
+import javax.media.j3d.Appearance;
+import javax.media.j3d.BranchGroup;
+import javax.media.j3d.Texture;
+import javax.media.j3d.Transform3D;
+import javax.media.j3d.TransformGroup;
+import javax.vecmath.Matrix4d;
+
+import com.sun.j3d.loaders.IncorrectFormatException;
+import com.sun.j3d.loaders.ParsingErrorException;
+import com.sun.j3d.loaders.Scene;
+import com.sun.j3d.loaders.objectfile.ObjectFile;
+
+import com.sun.j3d.utils.image.TextureLoader;
+
+public class MakeObject {
+	
+	private Transform3D transform;  
+	private TransformGroup transform_group;
+	private ViewChange canvas;
+	private Matrix4d matrix;
+	private double s;
+
+	
+	public MakeObject(MakeFrame frame){
+		this.canvas = frame.getCanvas();
+		this.s = 0.3;
+		frame.register(this);
+	}
+	
+	public BranchGroup createBranch(){
+		BranchGroup scene = new BranchGroup();
+		/*Box box = new Box(0.1f,0.1f,0.0f,
+				Box.GENERATE_NORMALS|Box.GENERATE_TEXTURE_COORDS,createAppearance());*/
+		ObjectFile obj = new ObjectFile(ObjectFile.RESIZE);
+		Scene img = null;
+		try{
+			URL url=getClass().getClassLoader().getResource("TUNA");
+			img = obj.load(url);
+		} catch(FileNotFoundException e){
+			System.err.println(e);
+			System.exit(1);
+		} catch(ParsingErrorException e){
+			System.err.println(e);
+			System.exit(1);
+		} catch(IncorrectFormatException e){
+			System.err.println(e);
+			System.exit(1);
+		}
+		
+		transform_group = new TransformGroup();
+		setLocation(-2.0f,-2.0f); //set out of window
+		transform_group.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+		transform_group.addChild(img.getSceneGroup());
+		scene.addChild(transform_group);
+		return scene;		
+	}
+	
+	// no use method
+	public Appearance createAppearance(){
+		Appearance app = new Appearance();
+		Image image = null; 	
+		Toolkit toolkit = Toolkit.getDefaultToolkit();
+		URL url = getClass().getClassLoader().getResource("fish.jpg");
+		image = toolkit.getImage(url);
+		MediaTracker mt = new MediaTracker(canvas);
+		mt.addImage(image, 0);
+		mt.checkAll(true);
+		try {
+			mt.waitForID(0);
+			
+		}catch (InterruptedException e){
+			e.printStackTrace();
+			
+		}
+		Texture texture = new TextureLoader(image,canvas).getTexture();
+		app.setTexture(texture);
+		return app;
+		
+	}
+	
+	public void setScale(float size){
+		s = size;
+	}
+	
+	public void setLocation(float x,float y){
+		transform = new Transform3D();
+		matrix = new Matrix4d(s,0,0,x,
+							  0,s,0,y,
+							  0,0,s,0,
+							  0,0,0,1);
+		transform.set(matrix);
+		transform_group.setTransform(transform);
+	}
+	
+	public void setLocation(float x,float y,float z){
+		transform = new Transform3D();
+		matrix = new Matrix4d(s,0,0,x,
+				  			  0,s,0,y,
+				  			  0,0,s,z,
+				  			  0,0,0,1);
+		transform.set(matrix);
+		transform_group.setTransform(transform);
+	}
+	
+	
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/MouseViewEvent.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,52 @@
+package alice.test.topology.aquarium;
+
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
+
+public class MouseViewEvent implements MouseMotionListener {
+	
+	int new_x, new_y;
+	int pre_x, pre_y;
+	ViewChange v;
+	
+	public MouseViewEvent(ViewChange v) {
+		this.v = v;
+		
+	}
+
+	@Override
+	public void mouseDragged(MouseEvent event) {
+		new_x = event.getX();
+		new_y = event.getY();
+		
+		v.theta -= v.sensitivity * (new_y - pre_y);
+		v.phi += v.sensitivity * (new_x - pre_x);
+		v.camera_y = v.distance * (float)Math.sin(v.theta);
+		v.camera_xz = v.distance * (float)Math.cos(v.theta);
+	
+		v.camera_x =  v.camera_xz * (float)Math.sin(v.phi);
+		v.camera_z =  v.camera_xz * (float)Math.cos(v.phi);	
+		v.Vector_camera_pos.x = v.camera_x;
+		v.Vector_camera_pos.y = v.camera_y;
+		v.Vector_camera_pos.z = v.camera_z;
+		
+		v.Transform_camera_pos.setIdentity();
+		v.Transform_camera_pos.setTranslation(v.Vector_camera_pos);
+		
+		v.Transform_camera_theta.rotX(-v.theta);
+		v.Transform_camera_phi.rotY(v.phi);
+		v.Transform_camera_phi.mul(v.Transform_camera_theta);
+		v.Transform_camera_pos.mul(v.Transform_camera_phi);
+		v.Camera.setTransform(v.Transform_camera_pos);
+		pre_x = event.getX();
+		pre_y = event.getY();
+		
+	}	
+	
+	@Override
+	public void mouseMoved(MouseEvent event) {
+		pre_x = event.getX();
+		pre_y = event.getY();	
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/ObjectList.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,8 @@
+package alice.test.topology.aquarium;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ObjectList {
+	public List<MakeObject> table = new ArrayList<MakeObject>();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/RefreshWindow.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,28 @@
+package alice.test.topology.aquarium;
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class RefreshWindow extends CodeSegment {
+	private Receiver num = ids.create(CommandType.PEEK);
+	private Receiver host = ids.create(CommandType.PEEK);
+	private MakeFrame frame;
+	
+	public RefreshWindow(MakeFrame frame){
+		this.host.setKey("host");
+		this.num.setKey("host_num");
+		this.frame = frame;
+	}
+	
+	@Override
+	public void run() {
+		frame.getJFrame().dispose();
+		ObjectList list = frame.getList();
+		frame = new MakeFrame(host.asString(),num.asInteger());
+		for (MakeObject obj : list.table) {
+			frame.register(obj);
+		}
+	}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/ResetFish.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,16 @@
+package alice.test.topology.aquarium;
+
+import alice.codesegment.CodeSegment;
+
+public class ResetFish extends CodeSegment {
+	
+	public ResetFish(){}
+
+	@Override
+	public void run() {
+		FishPoint fp = new FishPoint(0.0f,0.0f,0.0f);
+		ods.update("fish", fp);
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/SendLocation.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,30 @@
+package alice.test.topology.aquarium;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+
+public class SendLocation extends CodeSegment {
+	
+	private Receiver position = ids.create(CommandType.PEEK);
+	float x;
+	float y;
+	float z;
+	
+	public SendLocation(float x,float y,float z){
+		this.x = x;
+		this.y = y;
+		this.z = z;
+		position.setKey("fish");
+	}
+	
+	@Override
+	public void run() {
+		FishPoint fp = this.position.asClass(FishPoint.class);
+		fp.setXYZ(fp.getX()+x, fp.getY()+y, fp.getZ()+z);
+		ods.update("fish", fp);
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/SendMaxsize.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,22 @@
+package alice.test.topology.aquarium;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class SendMaxsize extends CodeSegment{
+
+	private Receiver max = ids.create(CommandType.PEEK);
+	
+	public SendMaxsize(int index){
+		this.max.setKey("num", index);
+	}
+	
+	@Override
+	public void run() {
+		int size = max.asInteger();
+		ods.update("maxsize",size);
+		new SendMaxsize(this.max.index);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/SetLocation.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,27 @@
+package alice.test.topology.aquarium;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+
+public class SetLocation extends CodeSegment{
+	
+	private Receiver position = ids.create(CommandType.PEEK);
+	private MakeObject obj;
+	
+	public SetLocation(MakeObject obj ,String key, int index){
+		this.obj = obj;
+		this.position.setKey(key,index);
+	}
+	
+	@Override
+	public void run(){
+		FishPoint fp = this.position.asClass(FishPoint.class);
+		obj.setLocation(fp.getX(), fp.getY(), fp.getZ());
+		new SetLocation(obj, position.key, position.index);
+					
+	}
+	
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/StartFishMovement.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,12 @@
+package alice.test.topology.aquarium;
+
+import alice.codesegment.CodeSegment;
+
+public class StartFishMovement extends CodeSegment{
+	@Override
+	public void run(){
+		new CheckMyName();
+	}
+	
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/TakeMynum.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,27 @@
+package alice.test.topology.aquarium;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class TakeMynum extends CodeSegment {
+	
+	private Receiver mynum = ids.create(CommandType.TAKE);
+	
+	public TakeMynum(){
+		this.mynum.setKey("num");
+	}
+	
+	public TakeMynum(int index){
+		this.mynum.setKey("num", index);
+	}
+
+	@Override
+	public void run() {
+		new TakePnum(this.mynum);
+		ods.put("num", 0);
+		new TakeMynum(this.mynum.index+1);
+	}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/TakePnum.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,24 @@
+package alice.test.topology.aquarium;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class TakePnum extends CodeSegment {
+	// this CodeSegment has bug
+	
+	private Receiver pnum = ids.create(CommandType.TAKE);
+	private Receiver mynum;
+	
+	public TakePnum(Receiver data){
+		this.pnum.setKey("parent", "num");
+		this.mynum = data;
+	}
+
+	@Override
+	public void run() {
+		ods.update("parent", "num", 
+				this.pnum.asInteger()+this.mynum.asInteger());
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/aquarium/ViewChange.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,58 @@
+package alice.test.topology.aquarium;
+
+import java.awt.*;
+
+import javax.media.j3d.*;
+import javax.vecmath.*;
+import com.sun.j3d.utils.universe.*;
+
+public class ViewChange extends Canvas3D {
+
+	private static final long serialVersionUID = 1L;
+	float sensitivity;
+	float distance = 2.5f;
+	float camera_x, camera_y, camera_z, camera_xz, camera_xy, camera_yz = 0;
+	float phi =  0; // flow
+	float theta = 0;
+	
+	SimpleUniverse universe;
+	TransformGroup Camera;
+	Transform3D Transform_camera_pos;
+	Transform3D Transform_camera_phi;
+	Transform3D Transform_camera_theta;
+	Vector3f Vector_camera_pos;
+	
+	public ViewChange(float x, float Sensitivity, GraphicsConfiguration config){
+		super(config);
+		
+		sensitivity = Sensitivity;
+		universe = new SimpleUniverse(this);
+		ViewingPlatform vp = universe.getViewingPlatform();
+		Camera = vp.getViewPlatformTransform();
+
+		camera_y = distance * (float)Math.sin(theta);
+		camera_xz = distance * (float)Math.cos(theta);
+		System.out.println(x);
+		camera_x = x;
+		camera_z =  camera_xz * (float)Math.cos(phi);
+		
+		Vector_camera_pos = new Vector3f(camera_x, camera_y, camera_z);
+		Transform_camera_pos = new Transform3D();
+		Transform_camera_pos.setTranslation(Vector_camera_pos);
+		Transform_camera_phi = new Transform3D();
+		Transform_camera_theta = new Transform3D();
+		Transform_camera_theta.rotX(-theta);
+		Transform_camera_phi.rotY(phi);
+		Transform_camera_theta.mul(Transform_camera_phi);
+		Transform_camera_pos.mul(Transform_camera_theta);
+
+		Camera.setTransform(Transform_camera_pos);
+
+		addMouseMotionListener(new MouseViewEvent(this));
+		
+	}
+	
+	
+	
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/fish/AssignStartX.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,40 @@
+package alice.test.topology.fish;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class AssignStartX extends CodeSegment {
+
+	public Receiver routing = ids.create(CommandType.PEEK);
+	public int startX;
+	public int index;
+
+	public AssignStartX(int startX, int index) {
+		this.startX = startX;
+		this.index = index;
+	}
+	
+	@Override
+	public void run() {
+		System.out.println("AssignStartX: " + startX);
+		
+		RoutingTable routing = this.routing.asClass(RoutingTable.class);
+		int x = startX;
+		System.out.println("RoutingTable: " + this.routing.getVal());
+		if (this.index >= this.routing.index) {
+			AssignStartX cs = new AssignStartX(startX, index);
+			cs.routing.setKey("local", "routing", this.routing.index);
+			return;
+		}
+		for (Routing r : routing.table) {
+			System.out.println(r.name);
+			ods.update(r.name, "startX", x);
+			System.out.println("Assign: " + r.name + ".startX = " + x);
+			x += r.width;
+		}
+		PeekStartX cs = new PeekStartX(this.routing.index);
+		cs.startX.setKey("local", "startX", this.index);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/fish/CheckMyName.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,58 @@
+package alice.test.topology.fish;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class CheckMyName extends CodeSegment {
+	
+	private Receiver host = ids.create(CommandType.PEEK);
+	
+	public CheckMyName(){
+		host.setKey("host");
+	}
+	
+	@Override
+	public void run() {
+		String name = host.asString();
+		Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
+		Matcher matcher = pattern.matcher(name);
+		
+		matcher.find();
+		String type = matcher.group(1);
+		int num = new Integer(matcher.group(2));
+		
+		if (type.equals("cli")) {
+			System.out.println("********************I am cli" + num);
+			ods.update("local", "width", 400);
+			
+			GetStartX cs = new GetStartX();
+			cs.startX.setKey("local", "startX");
+			
+		} else if (type.equals("node")) {
+			System.out.println("********************I am node" + num);
+			WidthReceiver cs = new WidthReceiver();
+			cs.widths.setKey("local", "widths");
+			cs.routing.setKey("local", "routing");
+			
+			PeekStartX cs2 = new PeekStartX(0);
+			cs2.startX.setKey("local", "startX");
+			
+			ods.put("local", "routing", new RoutingTable());
+			if (num == 0) { // First node ("node0") check
+				StartStartX cs3 = new StartStartX();
+				cs3.width.setKey("local", "width");
+				//ods.update("local", "startX", 0);
+				return;
+			}
+		}
+		
+		SendWidth cs = new SendWidth();
+		cs.width.setKey("local", "width");
+
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/fish/DistributedFish.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,13 @@
+package alice.test.topology.fish;
+
+import alice.topology.node.TopologyNode;
+
+public class DistributedFish {
+
+	public static void main(String[] args) {
+		FishConfig conf = new FishConfig(args);
+		new TopologyNode(conf, new StartFish());
+
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/fish/FishConfig.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,12 @@
+package alice.test.topology.fish;
+
+import alice.topology.node.TopologyNodeConfig;
+
+public class FishConfig extends TopologyNodeConfig {
+
+	public FishConfig(String[] args) {
+		super(args);
+		
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/fish/GetStartX.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,21 @@
+package alice.test.topology.fish;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class GetStartX extends CodeSegment {
+
+	public Receiver startX = ids.create(CommandType.PEEK);
+	
+	@Override
+	public void run() {
+		int startX = this.startX.asInteger();
+		
+		System.out.println("GetStartX: " + startX);
+		
+		GetStartX cs = new GetStartX();
+		cs.startX.setKey("local", "startX", this.startX.index);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/fish/PeekStartX.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,23 @@
+package alice.test.topology.fish;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class PeekStartX extends CodeSegment {
+
+	public Receiver startX = ids.create(CommandType.PEEK);
+	public int index;
+	
+	public PeekStartX(int index) {
+		this.index = index;
+	}
+	
+	@Override
+	public void run() {
+		int startX = this.startX.asInteger();
+		AssignStartX cs = new AssignStartX(startX, this.startX.index);
+		cs.routing.setKey("routing", this.startX.index);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/fish/Routing.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,35 @@
+package alice.test.topology.fish;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.msgpack.annotation.Message;
+import org.msgpack.annotation.Optional;
+
+@Message
+public class Routing {
+
+	public String name;
+	public int id;
+	public int width;
+	@Optional public int startX;
+	
+	public Routing() {}
+	
+	public Routing(String name, int width) {
+		this.name = name;
+		this.width = width;
+		Pattern pattern = Pattern.compile("^child([0-9]+)$");
+		Matcher matcher = pattern.matcher(name);
+		matcher.find();
+		id = new Integer(matcher.group(1));
+	}
+
+	public Routing(String name, int id, int width, int startX) {
+		this.name = name;
+		this.id = id;
+		this.width = width;
+		this.startX = startX;
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/fish/RoutingTable.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,14 @@
+package alice.test.topology.fish;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.msgpack.annotation.Message;
+
+@Message
+public class RoutingTable {
+
+	int sumWidth = 0;
+	List<Routing> table = new ArrayList<Routing>();
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/fish/SendWidth.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,22 @@
+package alice.test.topology.fish;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class SendWidth extends CodeSegment {
+	
+	Receiver width = ids.create(CommandType.PEEK);
+
+	@Override
+	public void run() {
+		int width = this.width.asInteger();
+		ods.put("parent", "widths", width);
+		
+		System.out.println("send widths: " + width);
+		
+		SendWidth cs = new SendWidth();
+		cs.width.setKey("width", this.width.index);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/fish/StartFish.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,13 @@
+package alice.test.topology.fish;
+
+import alice.codesegment.CodeSegment;
+
+public class StartFish extends CodeSegment {
+
+	@Override
+	public void run() {
+		new CheckMyName(); // separate processing
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/fish/StartStartX.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,18 @@
+package alice.test.topology.fish;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class StartStartX extends CodeSegment {
+	
+	public Receiver width = ids.create(CommandType.PEEK);
+	
+	@Override
+	public void run() {
+		ods.update("local", "startX", 0);
+		StartStartX cs = new StartStartX();
+		cs.width.setKey("local", "width", this.width.index);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/fish/WidthReceiver.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,55 @@
+package alice.test.topology.fish;
+
+import java.util.Collections;
+import java.util.Comparator;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class WidthReceiver extends CodeSegment {
+	
+	public Receiver widths = ids.create(CommandType.TAKE);
+	public Receiver routing = ids.create(CommandType.PEEK);	
+	
+	@Override
+	public void run() {
+		int width = this.widths.asInteger();
+		String from = this.widths.from;
+		RoutingTable routing = this.routing.asClass(RoutingTable.class);
+		Routing newRouting = new Routing(from, width);
+		boolean update = false;
+		for (Routing r : routing.table) {
+			if (r.id == newRouting.id) {
+				routing.sumWidth -= r.width;
+				routing.sumWidth += newRouting.width;
+				r.width = width;
+				update = true;
+				break;
+			}
+		}
+		if (!update) {
+			routing.table.add(newRouting);
+			Collections.sort(routing.table, new Comparator<Routing>() {
+				@Override
+				public int compare(Routing o1, Routing o2) {
+					return o1.id - o2.id;
+				}
+			});
+			routing.sumWidth += width;
+		}
+		
+		System.out.println("SUM WIDTH: " + routing.sumWidth);
+		
+		System.out.println("NODE NUM: " + routing.table.size());
+		
+		ods.update("width", routing.sumWidth);
+		ods.update("routing", routing);
+		
+		WidthReceiver cs = new WidthReceiver();
+		cs.widths.setKey("widths", this.widths.index);
+		cs.routing.setKey("routing");
+		//cs.routing.setKey("routing", this.routing.index);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/ring/CheckMyName.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,39 @@
+package alice.test.topology.ring;
+
+import org.apache.log4j.Logger;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class CheckMyName extends CodeSegment {
+
+	public Receiver ds1 = ids.create(CommandType.PEEK);
+	
+	private Logger logger = Logger.getLogger(CheckMyName.class);
+	private RingTopologyConfig conf;
+	
+	public CheckMyName(RingTopologyConfig conf) {
+		this.conf = conf;
+	}
+	
+	@Override
+	public void run() {
+		String host = this.ds1.asString();
+		logger.debug(host);
+		if (host.equals("node0")) {
+			ods.put("local", "c", new byte[conf.size]);
+			FirstRingMessagePassing cs1 = new FirstRingMessagePassing(conf.count, conf.nodeNum);
+			cs1.ds1.setKey("c");
+			RingFinish cs2 = new RingFinish("manager");
+			cs2.finish.setKey("finish");
+		} else {
+			ods.close("manager");
+			RingMessagePassing cs1 = new RingMessagePassing();
+			cs1.ds1.setKey("c");
+			RingFinish cs2 = new RingFinish("right");
+			cs2.finish.setKey("finish");
+		}
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/ring/FirstRingMessagePassing.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,43 @@
+package alice.test.topology.ring;
+
+import org.msgpack.type.ValueFactory;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class FirstRingMessagePassing extends CodeSegment {
+	
+	public Receiver ds1 = ids.create(CommandType.TAKE);
+	private long startTime;
+	private int count;
+	private int nodeNum;
+	
+	public FirstRingMessagePassing(long startTime, int count, int nodeNum) {
+		this.startTime = startTime;
+		this.count = count;
+		this.nodeNum = nodeNum;
+	}
+	
+	public FirstRingMessagePassing(int count, int nodeNum) { // at first
+		this.startTime = System.nanoTime();
+		this.count = count;
+		this.nodeNum = nodeNum;
+	}
+	
+	@Override
+	public void run() {
+		ods.put("right", "c", ds1.getVal()); // copy whole DataSegment to the right
+		if (ds1.index > count) {        // after count time update of ds1
+			ods.put("right", "finish", ValueFactory.createNilValue());
+			long endTime = System.nanoTime();
+			long time = endTime - startTime;
+			System.out.println(nodeNum + " " + time / count / 1000000.0);
+			return;
+		}
+		
+		FirstRingMessagePassing cs = new FirstRingMessagePassing(startTime, count, nodeNum);
+		cs.ds1.setKey("c");
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/ring/RingFinish.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,24 @@
+package alice.test.topology.ring;
+
+import org.msgpack.type.ValueFactory;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class RingFinish extends CodeSegment {
+	
+	private String sendKey;
+	public Receiver finish = ids.create(CommandType.TAKE);
+	
+	public RingFinish(String sendKey) {
+		this.sendKey = sendKey;
+	}
+
+	@Override
+	public void run() {
+		ods.put(sendKey, "finish", ValueFactory.createNilValue());
+		ods.finish(sendKey);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/ring/RingMessagePassing.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,18 @@
+package alice.test.topology.ring;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class RingMessagePassing extends CodeSegment {
+
+	public Receiver ds1 = ids.create(CommandType.TAKE);
+
+	@Override
+	public void run() {
+		ods.put("right", "c", this.ds1.getVal());
+		RingMessagePassing cs = new RingMessagePassing();
+		cs.ds1.setKey("c");
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/ring/RingTopology.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,12 @@
+package alice.test.topology.ring;
+
+import alice.topology.node.TopologyNode;
+
+public class RingTopology {
+	
+	public static void main(String[] args) {
+		RingTopologyConfig conf = new RingTopologyConfig(args);
+		new TopologyNode(conf, new StartRing(conf));
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/ring/RingTopologyConfig.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,24 @@
+package alice.test.topology.ring;
+
+import alice.topology.node.TopologyNodeConfig;
+
+public class RingTopologyConfig extends TopologyNodeConfig {
+	
+	public int count = 10;
+	public int size = 10;
+	public int nodeNum = 10;
+	
+	public RingTopologyConfig(String[] args) {
+		super(args);
+		for (int i = 0; i < args.length; i++) {
+			if ("-count".equals(args[i])) {
+				this.count = Integer.parseInt(args[++i]);
+			} else if ("-size".equals(args[i])) {
+				this.size = Integer.parseInt(args[++i]);
+			} else if ("-nodeNum".equals(args[i])) {
+				this.nodeNum = Integer.parseInt(args[++i]);
+			}
+		}
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/ring/StartRing.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,16 @@
+package alice.test.topology.ring;
+
+import alice.codesegment.CodeSegment;
+
+public class StartRing extends CodeSegment {
+	private RingTopologyConfig conf;
+	public StartRing(RingTopologyConfig conf) {
+		this.conf = conf;
+	}
+	@Override
+	public void run() {
+		CheckMyName cs = new CheckMyName(conf);
+		cs.ds1.setKey("host");
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/share/AutoIncrement.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,28 @@
+package alice.test.topology.share;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class AutoIncrement extends CodeSegment {
+	
+	public Receiver position = ids.create(CommandType.PEEK);	
+		
+	public AutoIncrement(String key,int index){
+		this.position.setKey(key, index);
+	}
+
+	@Override
+	public void run() {
+		synchronized(this){
+			try {
+				wait(50);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+		}
+		ods.update(position.key, new DataInfo(System.nanoTime()));
+		new AutoIncrement(position.key ,position.index);
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/share/CheckLocalIndex.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,44 @@
+package alice.test.topology.share;
+
+import java.util.List;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class CheckLocalIndex extends CodeSegment {
+
+	private Receiver data = ids.create(CommandType.PEEK);
+	private Receiver list = ids.create(CommandType.PEEK);
+	private Receiver host = ids.create(CommandType.PEEK);
+
+	
+	public CheckLocalIndex(String key, int index) {
+		this.host.setKey("host");
+		this.list.setKey("_CLIST");
+		this.data.setKey(key, index);
+	}
+	
+	@Override
+	public void run() {
+		@SuppressWarnings("unchecked")
+		List<String> r = list.asClass(List.class);
+		int count = 0;
+		boolean flag = false;
+		for (String node : r) {
+			if (node.equals("parent")) {
+				flag = true;
+			}
+			if (!node.equals(this.data.from)) {
+				ods.update(node, data.key, data.getVal());
+				count++;
+			}
+		}
+		if (count == 0 && flag) {
+			ods.put("parent", "data", data.getVal());
+		}
+		new CheckLocalIndex(data.key, data.index);
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/share/CheckMyName.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,48 @@
+package alice.test.topology.share;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+
+public class CheckMyName extends CodeSegment {
+	Receiver host = ids.create(CommandType.PEEK);
+	Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
+	String key = "fish";
+	
+	public CheckMyName(){
+		this.host.setKey("host");
+	}
+	
+	@Override
+	public void run(){
+		
+		String name = host.asString();
+		Matcher matcher = pattern.matcher(name);
+		
+		matcher.find();
+		String type = matcher.group(1);
+		int num = new Integer(matcher.group(2));
+			
+		if (type.equals("cli")){
+			System.out.println("cli"+num);
+			new SendData(0);
+			
+		}else if (type.equals("node")){
+			System.out.println("node"+num);
+			if (num != 0){
+				new SendData(0);
+			}else{
+				new LookUpData("data",0);
+			}
+		}
+		for (int i =0 ;i<1000000;i++){}
+		ods.update(key, new DataInfo());
+		
+		if (num == 0) new AutoIncrement(key,0);
+		new CheckLocalIndex(key,1);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/share/DataInfo.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,22 @@
+package alice.test.topology.share;
+
+import org.msgpack.annotation.Message;
+
+@Message
+public class DataInfo {
+	public long setTime = 0;
+		
+	public DataInfo(){}
+	
+	public DataInfo(long t){
+		setTime = t;
+	}
+	
+	public void setTime(long t){
+		setTime = t;
+	}
+	
+	public long getTime(){
+		return setTime;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/share/LookUpData.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,32 @@
+package alice.test.topology.share;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class LookUpData extends CodeSegment{
+
+	private Receiver data = ids.create(CommandType.PEEK);
+	String key;
+	int depth;
+	
+	public LookUpData(String key,int index){
+		this.key = key;
+		this.data.setKey(key, index);
+	}
+	
+	public LookUpData(String key,int index, int depth){
+		this.key = key;
+		this.depth = depth;
+		this.data.setKey(key, index);
+	}
+
+	@Override
+	public void run(){
+		new LookUpData(this.key,this.data.index);
+		DataInfo di = data.asClass(DataInfo.class);
+		System.out.println(System.nanoTime()-di.getTime());
+
+	}
+	
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/share/SendData.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,20 @@
+package alice.test.topology.share;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class SendData extends CodeSegment{
+	private Receiver data = ids.create(CommandType.PEEK);
+	
+	public SendData(int index){
+		this.data.setKey("data", index);
+	}
+	
+	@Override
+	public void run(){
+		new SendData(this.data.index);
+		ods.put("parent", "data", this.data.getVal());
+	}
+	
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/share/ShareConfig.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,12 @@
+package alice.test.topology.share;
+
+import alice.topology.node.TopologyNodeConfig;
+
+public class ShareConfig extends TopologyNodeConfig {
+	
+	public ShareConfig(String[] args){
+		super(args);
+	} 
+	
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/share/ShareTopology.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,11 @@
+package alice.test.topology.share;
+import alice.topology.node.TopologyNode;
+
+public class ShareTopology {
+	public static void main(String[] args){
+		ShareConfig conf = new ShareConfig(args);
+		new TopologyNode(conf, new StartFishMovement());
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/topology/share/StartFishMovement.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,12 @@
+package alice.test.topology.share;
+
+import alice.codesegment.CodeSegment;
+
+public class StartFishMovement extends CodeSegment{
+	@Override
+	public void run(){
+		new CheckMyName();
+	}
+	
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/HostMessage.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,40 @@
+package alice.topology;
+
+import org.msgpack.annotation.Message;
+
+@Message
+public class HostMessage {
+	
+	public String name;
+	public int port;
+	public String connectionName;
+	public String reverseName;
+	public String absName;
+	public boolean reconnectFlag = false;
+	
+	public HostMessage() { }
+	public HostMessage(String name, int port) {
+		this.name = name;
+		this.port = port;
+	}
+
+	public HostMessage(String name, int port, String connectionName, String reverseName) {
+		this.name = name;
+		this.port = port;
+		this.connectionName = connectionName;
+		this.reverseName = reverseName;
+	}
+	
+	public void setABSName(String name){
+		absName = name;
+	}
+	
+	public String getABSName(){
+		return absName;
+	}
+	
+	public void setFlag(){
+		this.reconnectFlag = true;
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/ConfigWaiter.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,31 @@
+package alice.topology.manager;
+
+import org.msgpack.type.ValueFactory;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+import alice.topology.manager.reconnection.ReceiveError;
+
+public class ConfigWaiter extends CodeSegment {
+	
+	public Receiver done = ids.create(CommandType.TAKE);
+	public int count;
+	
+	public ConfigWaiter(int nodeNum) {
+		this.count = nodeNum;
+	}
+
+	@Override
+	public void run() {
+		count--;
+		if (count == 0) {
+			ods.put("local", "start", ValueFactory.createNilValue());
+			new ReceiveError();
+			return;
+		}
+		ConfigWaiter cs3 = new ConfigWaiter(count);
+		cs3.done.setKey("local", "done");
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/IncomingHosts.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,67 @@
+package alice.topology.manager;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+
+import org.msgpack.type.ValueFactory;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.DataSegment;
+import alice.datasegment.Receiver;
+import alice.topology.HostMessage;
+
+public class IncomingHosts extends CodeSegment {
+	
+	HashMap<String, LinkedList<NodeInfo>> topology;
+	LinkedList<String> nodeNames;
+	Receiver host = ids.create(CommandType.TAKE);
+	Receiver connection = ids.create(CommandType.TAKE);
+	
+	public IncomingHosts(HashMap<String, LinkedList<NodeInfo>> topology, LinkedList<String> nodeNames) {
+		this.topology = topology;
+		this.nodeNames = nodeNames;
+	}
+
+	@Override
+	public void run() {
+		HostMessage host = this.host.asClass(HostMessage.class);
+		@SuppressWarnings("unchecked")
+		HashMap<String, ArrayList<HostMessage>> connectionList = this.connection.asClass(HashMap.class);
+		
+		String nodeName = nodeNames.poll();
+		// Manager connect to Node
+		
+		DataSegment.connect(nodeName, "", host.name, host.port, host.reconnectFlag);
+		ods.put(nodeName, "host", nodeName);
+		LinkedList<NodeInfo> nodes = topology.get(nodeName);
+		ArrayList<HostMessage> list;
+		for (NodeInfo nodeInfo : nodes) {
+			HostMessage newHost = new HostMessage(host.name, host.port, nodeInfo.connectionName, nodeInfo.reverseName);
+			ods.put("local", nodeInfo.sourceNodeName, newHost);
+			
+			if (connectionList.containsKey(nodeInfo.sourceNodeName)){
+				list = connectionList.get(nodeInfo.sourceNodeName);
+			} else {
+				list = new ArrayList<HostMessage>();
+				connectionList.put(nodeInfo.sourceNodeName, list);
+				
+			}			
+			list.add(newHost);
+		}
+		ods.update("local", "connection", connectionList);
+		
+		if (nodeNames.isEmpty()) {
+			// configuration finish
+			for (String key : topology.keySet()) {
+				ods.put("local", key, ValueFactory.createNilValue());
+			}
+		} else {
+			IncomingHosts cs = new IncomingHosts(topology, nodeNames);
+			cs.host.setKey("local", "host");
+			cs.connection.setKey("local", "connection");
+		}
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/NodeInfo.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,14 @@
+package alice.topology.manager;
+
+public class NodeInfo {
+	
+	public String sourceNodeName;
+	public String connectionName;
+	public String reverseName;
+	
+	public NodeInfo(String source, String connection) {
+		this.sourceNodeName = source;
+		this.connectionName = connection;
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/StartTopologyManager.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,93 @@
+package alice.topology.manager;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+
+import org.apache.log4j.Logger;
+
+import alice.codesegment.CodeSegment;
+import alice.topology.HostMessage;
+
+import com.alexmerz.graphviz.ParseException;
+import com.alexmerz.graphviz.Parser;
+import com.alexmerz.graphviz.objects.Edge;
+import com.alexmerz.graphviz.objects.Graph;
+import com.alexmerz.graphviz.objects.Node;
+
+public class StartTopologyManager extends CodeSegment {
+
+	TopologyManagerConfig conf;
+	Logger logger = Logger.getLogger(StartTopologyManager.class);
+
+	public StartTopologyManager(TopologyManagerConfig conf) {
+		this.conf = conf;
+	}
+
+	@Override
+	public void run() {
+		LinkedList<String> nodeNames = new LinkedList<String>();
+		HashMap<String, LinkedList<NodeInfo>> topology = new HashMap<String, LinkedList<NodeInfo>>();
+		int nodeNum = 0;
+		try {
+			FileReader reader = new FileReader(new File(conf.confFilePath));
+			Parser parser = new Parser();
+			parser.parse(reader);
+			ArrayList<Graph> graphs = parser.getGraphs();
+			for (Graph graph : graphs) {
+				ArrayList<Node> nodes = graph.getNodes(false);
+				nodeNum = nodes.size();
+				for (Node node : nodes) {
+					String nodeName = node.getId().getId();
+					nodeNames.add(nodeName);
+					topology.put(nodeName, new LinkedList<NodeInfo>());
+				}
+				ArrayList<Edge> edges = graph.getEdges();
+				HashMap<String, NodeInfo> hash = new HashMap<String, NodeInfo>();
+				for (Edge edge : edges) {
+					String connection = edge.getAttribute("label");
+					String source = edge.getSource().getNode().getId().getId();
+					String target = edge.getTarget().getNode().getId().getId();
+					LinkedList<NodeInfo> sources = topology.get(target);
+					NodeInfo nodeInfo = new NodeInfo(source, connection);
+					sources.add(nodeInfo);
+					hash.put(source + "," + target, nodeInfo);
+				}
+				for (Edge edge : edges) {
+					String connection = edge.getAttribute("label");
+					String source = edge.getSource().getNode().getId().getId();
+					String target = edge.getTarget().getNode().getId().getId();
+					NodeInfo nodeInfo = hash.get(target + "," + source);
+					if (nodeInfo != null) {
+						nodeInfo.reverseName = connection;
+					}
+				}
+			}
+			
+		} catch (FileNotFoundException e) {
+			logger.error("File not found: " + conf.confFilePath);
+			e.printStackTrace();
+		} catch (ParseException e) {
+			logger.error("File format error: " + conf.confFilePath);
+			e.printStackTrace();
+		}
+		HashMap<String, ArrayList<HostMessage>> connectionList = new HashMap<String, ArrayList<HostMessage>>();
+		ods.put("connection", connectionList);
+		ods.put("_ABSIPTABLE" ,new ArrayList<HostMessage>());
+		
+		new createABSIPList();
+		
+		IncomingHosts cs1 = new IncomingHosts(topology, nodeNames);
+		cs1.host.setKey("host");
+		cs1.connection.setKey("connection");
+		
+		ConfigWaiter cs3 = new ConfigWaiter(nodeNum);
+		cs3.done.setKey("local", "done");
+		
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/TopologyFinish.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,14 @@
+package alice.topology.manager;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class TopologyFinish extends CodeSegment {
+	public Receiver finish = ids.create(CommandType.TAKE);
+	@Override
+	public void run() {
+		System.exit(0);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/TopologyManager.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,13 @@
+package alice.topology.manager;
+
+import alice.daemon.AliceDaemon;
+
+public class TopologyManager {
+
+	public static void main(String[] args) {
+		TopologyManagerConfig conf = new TopologyManagerConfig(args);
+		new AliceDaemon(conf).listen();
+		new StartTopologyManager(conf).execute();
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/TopologyManagerConfig.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,18 @@
+package alice.topology.manager;
+
+import alice.daemon.Config;
+
+public class TopologyManagerConfig extends Config {
+	
+	public String confFilePath;
+	
+	public TopologyManagerConfig(String[] args) {
+		super(args);
+		for (int i = 0; i < args.length; i++) {
+			if ("-conf".equals(args[i])) {
+				confFilePath = args[++i];
+			}
+		}
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/createABSIPList.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,31 @@
+package alice.topology.manager;
+
+import java.util.List;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+import alice.topology.HostMessage;
+
+public class createABSIPList extends CodeSegment{
+	private Receiver rData = ids.create(CommandType.TAKE);
+	private Receiver hlist = ids.create(CommandType.PEEK);
+	
+	public createABSIPList(){
+		rData.setKey("_ABS_IP");
+		hlist.setKey("_ABSIPTABLE");
+	}
+	
+	@Override
+	public void run() {
+		HostMessage host = rData.asClass(HostMessage.class);
+		@SuppressWarnings("unchecked")
+		List<HostMessage> ABSIPList = hlist.asClass(List.class);
+		ABSIPList.add(host);
+		ods.update("_ABSIPTABLE", ABSIPList);
+		
+		new createABSIPList();
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/CheckExistTask.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,20 @@
+package alice.topology.manager.keeparive;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class CheckExistTask extends CodeSegment{
+	private Receiver info = ids.create(CommandType.PEEK); // TaskInfo
+	
+	public CheckExistTask(){
+		info.setKey("_TASKINFO");
+	}
+	
+	@Override
+	public void run() {
+		new CreateSchedule();
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/CreateSchedule.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,24 @@
+package alice.topology.manager.keeparive;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class CreateSchedule extends CodeSegment{
+	private Receiver info1 = ids.create(CommandType.TAKE); // WaitingList 
+	private Receiver info2 = ids.create(CommandType.TAKE); // TaskInfo
+	
+	public CreateSchedule(){
+		info1.setKey("_WAITINGLIST");
+		info2.setKey("_TASKINFO");
+	}
+
+	@Override
+	public void run() {
+		ListManager manager = info1.asClass(ListManager.class);
+		TaskInfo newTask = info2.asClass(TaskInfo.class);
+		manager.addTask(newTask);
+		ods.update("_WAITINGLIST", manager);
+		new CheckExistTask();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/CreateTask.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,34 @@
+package alice.topology.manager.keeparive;
+
+import java.util.List;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class CreateTask extends CodeSegment{
+	private Receiver info = ids.create(CommandType.PEEK);
+	
+	public CreateTask(){
+		info.setKey("_CLIST");
+	}
+	
+	@Override
+	public void run(){
+		ods.put("_WAITINGLIST", new ListManager());
+		@SuppressWarnings("unchecked")
+		List<String> list = info.asClass(List.class);
+		
+		new CheckExistTask();
+		TaskExecuter.getInstance().setKey();
+		for (String manager : list){
+			int i = 5;
+			TaskInfo task = new TaskInfo(TaskType.PING);
+			task.setInfo(manager, "_FORM_"+manager, i * 1000);
+			ods.put("_TASKINFO", task);
+			i +=5;
+		}
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/KeepAlive.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,12 @@
+package alice.topology.manager.keeparive;
+
+import alice.topology.node.TopologyNode;
+import alice.topology.node.TopologyNodeConfig;
+
+public class KeepAlive {
+	public static void main(String[] args) {
+		TopologyNodeConfig conf = new TopologyNodeConfig(args);
+		new TopologyNode(conf, new StartKeepAlive());
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/ListManager.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,85 @@
+package alice.topology.manager.keeparive;
+
+import java.util.LinkedList;
+
+public class ListManager {
+	private LinkedList<TaskInfo> list = new LinkedList<TaskInfo>();
+
+	public LinkedList<TaskInfo> getTaskList() {
+		return list;
+	}
+
+	public void addTask(TaskInfo newInfo) {
+		TaskExecuter exec = TaskExecuter.getInstance();
+		TaskInfo nowTask = exec.getNowTask();
+		if (nowTask == null) { // active task is nothing
+			add(newInfo);
+		} else {
+			long remainingTime = exec.getRemainingTime();
+			if (remainingTime > newInfo.getSleepTime()) {
+				// active task is longer than newTask.
+				TaskInfo task = nowTask.clone();
+				task.setSleepTime(remainingTime);
+				list.addFirst(task);
+				add(newInfo);
+				exec.ignore();
+			} else {
+				// newTask is longer than active task.
+				newInfo.setSleepTime(newInfo.getSleepTime() - remainingTime);
+				add(newInfo);
+			}
+		}
+		show();
+	}
+
+	private void add(TaskInfo newInfo){
+		int cnt = 0;
+		for (TaskInfo info : list){
+			if (info.getSleepTime() < newInfo.getSleepTime()){
+				newInfo.setSleepTime(newInfo.getSleepTime() - info.getSleepTime());	
+			} else if (info.getSleepTime() == newInfo.getSleepTime()){
+				// newInfo.getSleepTime() - info.getSleepTime() must be Zero
+				newInfo.setSleepTime(0);
+				cnt++;
+				break;
+			} else if (info.getSleepTime() > newInfo.getSleepTime()){
+				info.setSleepTime(info.getSleepTime() - newInfo.getSleepTime());
+				break;
+			}
+			cnt++;
+		}
+		list.add(cnt, newInfo);
+	}
+	
+	public boolean deleteTask(TaskInfo task){
+		boolean matchFlag = false;
+		int cnt = 0;
+		for (TaskInfo t: list){
+			if (t.getType().equals(task.getType())){
+				matchFlag = true;
+				if (cnt+1 < list.size() ){ // next task exists.
+					TaskInfo next = list.get(cnt+1);
+					next.setSleepTime(next.getSleepTime()+task.getSleepTime());
+				}
+				list.remove(cnt);
+				break;
+			} else {
+				cnt++;
+			}
+		}	
+		return matchFlag;
+	}
+	
+	public void show(){
+		if (TaskExecuter.getInstance().getNowTask()!=null){
+			System.out.print("NOW | ");
+			System.out.print(TaskExecuter.getInstance().getNowTask().getSleepTime());
+			System.out.print(" | ");
+		}
+		for (TaskInfo info : list){
+			System.out.print(info.getSleepTime());
+			System.out.print(" | ");
+		}
+		System.out.println();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/ListManagerTest.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,46 @@
+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.show();
+			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.show();
+			i +=1;
+		}
+		
+		manager = new ListManager();
+		System.out.println(TaskExecuter.getInstance().getRemainingTime());
+		TaskExecuter.getInstance().setNowTask(taskA);
+		TaskExecuter.getInstance().skip();
+		System.out.println(TaskExecuter.getInstance().getRemainingTime());
+
+	}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/RemoveTask.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,33 @@
+package alice.topology.manager.keeparive;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class RemoveTask extends CodeSegment {
+	private Receiver info1 = ids.create(CommandType.TAKE); // list
+	private Receiver info2 = ids.create(CommandType.TAKE); // remove task
+
+	public RemoveTask(){
+		info1.setKey("_WAITINGLIST");
+		info2.setKey("_REMOVETASK");
+	}
+
+	@Override
+	public void run() {
+		ListManager list = info1.asClass(ListManager.class); // explicit cast
+		TaskInfo task = info2.asClass(TaskInfo.class);
+		TaskExecuter exec = TaskExecuter.getInstance();
+		if (exec.compareNowTask(task)){
+			// case: remove task is state countdown.
+			exec.skip();
+		} else {
+			// case: remove task is still in the waiting queue.
+			boolean removeFlag = list.deleteTask(task);
+			if (!removeFlag){
+				ods.put("_REMOVETASK", task);
+			}
+		}
+		ods.update("_WAITINGLIST", list);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/RespondData.java	Wed Apr 16 18:26:07 2014 +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;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/RespondPing.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,43 @@
+package alice.topology.manager.keeparive;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.DataSegment;
+import alice.datasegment.Receiver;
+
+public class RespondPing extends CodeSegment{
+	private Receiver respond = ids.create(CommandType.TAKE);
+	private long pingedTime = System.currentTimeMillis();
+	
+	public RespondPing(String key) {
+		respond.setKey(key);
+	}
+
+	@Override
+	public void run() {
+		RespondData d = respond.asClass(RespondData.class);
+		System.out.print("ping from "+d.from);
+		System.out.println(" Recieved time "+(d.time - pingedTime));
+		if (d.time - pingedTime > 60 * 1000){
+			// need check, this connection is alive. may be close 
+			DataSegment.get(d.from).close();
+		} else {
+			// if nowTask close d.from's socket cancel. 
+			// if not remove close task in the Queue.
+			TaskExecuter exec = TaskExecuter.getInstance();
+			TaskInfo task = new TaskInfo(TaskType.CLOSE);
+			task.setInfo(d.from, null, 0);
+			if (exec.compareNowTask(task)){
+				// case: remove task is state countdown.
+				exec.skip(); // countdown
+			} else {
+				// case: remove task is still in the waiting queue.
+				ods.put("_REMOVETASK",task);
+				new RemoveTask();
+			}
+			TaskInfo task2 = new TaskInfo(TaskType.PING);
+			task2.setInfo(d.from, "_FORM_"+d.from, 5 * 1000);
+			ods.put("_TASKINFO", task2);
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/StartKeepAlive.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,13 @@
+package alice.topology.manager.keeparive;
+
+import alice.codesegment.CodeSegment;
+
+public class StartKeepAlive extends CodeSegment {
+
+	@Override
+	public void run() {
+		new CreateTask();
+
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/TaskExecuter.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,128 @@
+package alice.topology.manager.keeparive;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.DataSegment;
+import alice.datasegment.Receiver;
+
+public class TaskExecuter extends CodeSegment {
+	private Receiver info = ids.create(CommandType.TAKE);
+	private TaskInfo nowTask;
+	private boolean sleepFlag = false;
+	private boolean skipFlag = false;
+	private long startTime = 0;
+	private long remainingTime = 0; 
+	private static TaskExecuter instance = new TaskExecuter();
+
+	private TaskExecuter() {}
+	public static TaskExecuter getInstance() {
+		return instance;
+	}
+
+	public void setKey() {
+		ids.init();
+		info.setKey("_WAITINGLIST");
+	}
+
+	@Override
+	public synchronized void run()  {
+		ListManager list = info.asClass(ListManager.class);
+		if (list.getTaskList().size() == 0){
+			remainingTime = 0;
+			ods.update("_WAITINGLIST", list);
+		} else {
+			nowTask = list.getTaskList().poll();
+			ods.update("_WAITINGLIST", list);
+			
+			if (skipFlag) {
+				skipFlag = false;
+				nowTask.setSleepTime(remainingTime + nowTask.getSleepTime());
+				remainingTime = 0;
+			}
+			
+			startTime = System.currentTimeMillis();
+			System.out.println(nowTask.getSleepTime()+" "+nowTask.getType());
+			if (nowTask.getSleepTime() != 0){
+				sleepFlag = true;
+				try {
+					wait(nowTask.getSleepTime());
+				} catch (InterruptedException e) {
+					e.printStackTrace();
+				}
+				sleepFlag = false;
+			}
+			
+			if (!skipFlag){
+				// ping or close
+				if (nowTask.getType() == TaskType.PING) {
+					ods.ping(nowTask.getManagerKey(), nowTask.getReturnKey());
+					TaskInfo task = new TaskInfo(TaskType.CLOSE);
+					task.setInfo(nowTask.getManagerKey(), 10 * 1000);
+					ods.put("_TASKINFO", task);
+					new RespondPing(nowTask.getReturnKey());
+				} else if (nowTask.getType() == TaskType.CLOSE) {
+					// no response from the Remote DataSegment. So close this connection.
+					System.out.println("SHOTDOWN");
+					DataSegment.get(nowTask.getManagerKey()).close();
+				}
+			}
+			nowTask = null;
+			startTime = 0;
+		}
+		setKey();
+	}
+	
+	public synchronized void skip() {
+		if (sleepFlag){
+			skipFlag = true;
+			if (startTime == 0){
+				remainingTime = nowTask.getSleepTime();
+			} else {
+				remainingTime = nowTask.getSleepTime() - (System.currentTimeMillis() - startTime);
+			}
+			nowTask = null;			
+			notify();
+		}
+	}
+
+	public synchronized void ignore() {
+		if (sleepFlag){
+			skipFlag = true;
+			remainingTime = 0;
+			nowTask = null;
+			notify();			
+		}
+	}
+
+	public synchronized TaskInfo getNowTask() {
+		return nowTask;
+	}
+
+	// only use in ListManagerTest
+	public synchronized void setNowTask(TaskInfo info) {
+		nowTask = info;
+	}
+
+	public synchronized long getRemainingTime() {
+		if (sleepFlag) {
+			if (startTime !=0) {
+				return nowTask.getSleepTime() - (System.currentTimeMillis() - startTime);
+			} else {
+				return nowTask.getSleepTime();
+			}
+		} else {
+			return remainingTime;
+		}
+	}
+
+	public boolean compareNowTask(TaskInfo task) {
+		if (nowTask != null){
+			if (nowTask.getType().equals(task.getType())
+					&& nowTask.getManagerKey().equals(task.getManagerKey())){
+				return true;
+			} 
+		}
+		return false;
+	}
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/TaskInfo.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,56 @@
+package alice.topology.manager.keeparive;
+
+public class TaskInfo {
+	private TaskType type;
+	private long sleepTime;
+	private String managerKey;
+	private String returnKey;
+	
+	public TaskInfo(TaskType t){
+		type = t;
+	}
+	
+	public void setInfo(String managerKey, long time){
+		this.managerKey = managerKey;
+		sleepTime = time;
+	}
+	
+	public void setInfo(String managerKey, String returnKey, long time){
+		this.managerKey = managerKey;
+		this.returnKey = returnKey;
+		sleepTime = time;
+	}
+	
+	public TaskType getType(){
+		return type;
+	}
+	
+	public long getSleepTime(){
+		return sleepTime;
+	}
+	
+	public void setSleepTime(long time){
+		sleepTime = time;
+	}
+
+	public String getManagerKey(){
+		return managerKey;
+	}
+	
+	public String getReturnKey(){
+		return returnKey;
+	}
+	
+	public TaskInfo clone(){
+		TaskInfo task = new TaskInfo(type);
+		task.setInfo(managerKey, returnKey, sleepTime);
+		return task;
+	}
+	
+	public void show(){
+		System.out.print(type);
+		System.out.print(" "+  this.sleepTime);
+		System.out.print(" "+ this.managerKey);
+		System.out.println(" "+  this.returnKey);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/keeparive/TaskType.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,6 @@
+package alice.topology.manager.keeparive;
+
+public enum TaskType {
+	PING,
+	CLOSE,
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/reconnection/CheckABSName.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,47 @@
+package alice.topology.manager.reconnection;
+
+import java.util.List;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.DataSegment;
+import alice.datasegment.Receiver;
+import alice.topology.HostMessage;
+
+public class CheckABSName extends CodeSegment{
+	private Receiver abs = ids.create(CommandType.PEEK);
+	private Receiver host = ids.create(CommandType.TAKE);
+	private HostMessage message;
+	
+	public CheckABSName(HostMessage mes) {
+		message = mes;
+		abs.setKey("_ABSIPTABLE");
+		host.setKey("host");
+	}
+
+	@Override
+	public void run() {
+		System.out.println("CheckABSName");
+		@SuppressWarnings("unchecked")
+		List<HostMessage> ABSIPList = abs.asClass(List.class);
+		HostMessage hostInfo = host.asClass(HostMessage.class);
+		for (HostMessage mes : ABSIPList){
+			if (mes.name.equals(message.name)&&mes.port == message.port){
+				DataSegment.remove(mes.getABSName());
+				DataSegment.connect(mes.getABSName(), "", hostInfo.name, hostInfo.port, hostInfo.reconnectFlag);
+				ods.put(mes.getABSName(), "host", mes.getABSName());
+				ods.put("_RECABSNAME", mes.getABSName());
+				ods.put("_HMCLONE", new HostMessage(mes.name, mes.port));		
+				mes.port = hostInfo.port;
+				mes.name = hostInfo.name;
+				ods.update("_ABSIPTABLE", ABSIPList);
+				new CheckConnectionList();
+				return;
+			}
+		}
+		ods.put("host", hostInfo);
+		new ReceiveError();
+		System.out.println("not match");
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/reconnection/CheckConnectionList.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,70 @@
+package alice.topology.manager.reconnection;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.msgpack.type.ValueFactory;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+import alice.topology.HostMessage;
+
+public class CheckConnectionList extends CodeSegment {
+
+	private Receiver name = ids.create(CommandType.TAKE);
+	private Receiver connection = ids.create(CommandType.TAKE);
+	private Receiver abs = ids.create(CommandType.PEEK);
+	private Receiver clone = ids.create(CommandType.TAKE);
+	
+	public CheckConnectionList(){
+		name.setKey("_RECABSNAME");
+		connection.setKey("connection");
+		abs.setKey("_ABSIPTABLE");
+		clone.setKey("_HMCLONE");
+	}
+	
+	@Override
+	public void run() {
+		@SuppressWarnings("unchecked")
+		HashMap<String, ArrayList<HostMessage>> connectionList = connection.asClass(HashMap.class);
+		@SuppressWarnings("unchecked")
+		List<HostMessage> ABSIPList = abs.asClass(List.class);
+		String absName = name.asClass(String.class);
+		HostMessage oldInfo =  clone.asClass(HostMessage.class);
+		HostMessage newInfo = null; 
+		for (HostMessage mes : ABSIPList){
+			if (mes.absName.equals(absName)){
+				newInfo = mes;
+				break;
+			}
+		}
+		
+		List<HostMessage> clist = connectionList.get(absName);
+		for (HostMessage mes : clist){
+			mes.setFlag();
+			ods.put(absName, mes);
+			for (HostMessage mes2 : ABSIPList){
+				if (mes.name.equals(mes2.name)&&mes.port == mes2.port){
+					String absName2 = mes2.getABSName();
+					List<HostMessage> clist2 = connectionList.get(absName2);
+					for (HostMessage mes3 : clist2){
+						if (mes3.name.equals(oldInfo.name)&&mes3.port == oldInfo.port){
+							mes3.name = newInfo.name;
+							mes3.port = newInfo.port;
+							mes3.setFlag();
+							ods.put(absName2, "_RECODATA", mes3);
+							break;
+						}
+					}
+					break;
+				}			
+			}
+		}
+		System.out.println("SendHost Data");
+		ods.put(absName, ValueFactory.createNilValue());
+		ods.update("connection", connectionList);
+		new ReceiveError();
+	}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/reconnection/ReceiveError.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,33 @@
+package alice.topology.manager.reconnection;
+
+import java.io.IOException;
+import java.net.Socket;
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+import alice.topology.HostMessage;
+
+public class ReceiveError extends CodeSegment {
+	public Receiver reportInfo = ids.create(CommandType.TAKE);
+	
+	public ReceiveError(){
+		reportInfo.setKey("_ERROR");
+	}
+	
+	@Override
+	public void run() {		
+		HostMessage message = reportInfo.asClass(HostMessage.class);
+		try {
+			System.out.println("Receive Error "+ message.port);
+			Socket socket = new Socket(message.name, message.port);
+			socket.close();
+			System.out.println("alive "+message.port);
+		} catch (IOException e) {
+			System.out.println("Receive Error "+ message.port);
+			new CheckABSName(message);
+			return;
+		}
+		new ReceiveError();
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/reconnection/ReceiveReconnectData.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,26 @@
+package alice.topology.manager.reconnection;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.DataSegment;
+import alice.datasegment.Receiver;
+import alice.topology.HostMessage;
+
+public class ReceiveReconnectData extends CodeSegment{
+	private Receiver hostData = ids.create(CommandType.TAKE);
+
+	public ReceiveReconnectData(){
+		hostData.setKey("_RECODATA");
+	}
+	
+	@Override
+	public void run() {
+		HostMessage host = hostData.asClass(HostMessage.class);
+		DataSegment.remove(host.connectionName);
+		DataSegment.connect(host.connectionName, host.reverseName, host.name, host.port, host.reconnectFlag);
+		ods.put(host.connectionName, "reverseKey", host.reverseName);
+		new ReceiveReconnectData();
+	}
+	
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/manager/reconnection/SendError.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,18 @@
+package alice.topology.manager.reconnection;
+
+import alice.codesegment.CodeSegment;
+import alice.topology.HostMessage;
+
+public class SendError extends CodeSegment{
+	private HostMessage message;
+	
+	public SendError(HostMessage mes){
+		message = mes;
+	}
+	
+	@Override
+	public void run() {
+		ods.put("manager", "_ERROR", message);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/node/ConfigurationFinish.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,36 @@
+package alice.topology.node;
+
+import org.msgpack.type.ValueFactory;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+import alice.topology.manager.reconnection.ReceiveReconnectData;
+
+public class ConfigurationFinish extends CodeSegment {
+
+	public Receiver reverseCount = ids.create(CommandType.PEEK);
+	public Receiver configNodeNum = ids.create(CommandType.PEEK);
+	private CodeSegment startCS;
+	
+	public ConfigurationFinish(CodeSegment startCS) {
+		this.startCS = startCS;
+	}
+	
+	@Override
+	public void run() {
+		if (reverseCount.getVal().equals(configNodeNum.getVal())) {
+			new ReceiveReconnectData();
+			
+			ods.put("manager", "done", ValueFactory.createNilValue());
+			Start cs = new Start(startCS);
+			cs.done.setKey("manager", "start");
+			return;
+		}
+		
+		ConfigurationFinish cs3 = new ConfigurationFinish(startCS);
+		cs3.reverseCount.setKey("local", "reverseCount", this.reverseCount.index);
+		cs3.configNodeNum.setKey("local", "configNodeNum");
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/node/IncomingAbstractHostName.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,26 @@
+package alice.topology.node;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+import alice.topology.HostMessage;
+
+public class IncomingAbstractHostName extends CodeSegment {
+
+	public Receiver absName = ids.create(CommandType.PEEK);
+	private HostMessage host; // need CodeSegment	
+	
+	public IncomingAbstractHostName(HostMessage _host){
+		host = _host;
+	}
+	
+	@Override
+	public void run() {
+		String absName = this.absName.asString();
+		IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, 0);
+		cs.hostInfo.setKey("manager", absName);
+		host.setABSName(absName);
+		ods.put("manager","_ABS_IP", host);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/node/IncomingConnectionInfo.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,49 @@
+package alice.topology.node;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.DataSegment;
+import alice.datasegment.Receiver;
+import alice.topology.HostMessage;
+
+public class IncomingConnectionInfo extends CodeSegment {
+
+	public Receiver hostInfo = ids.create(CommandType.TAKE);
+	private List<String> connectionList;
+	private String absName;
+	private int count;
+	
+	public IncomingConnectionInfo(String absName, int count) {
+		this.absName = absName;
+		this.count = count;
+		this.connectionList = new ArrayList<String>();
+	}
+	
+	public IncomingConnectionInfo(String absName, int count, List<String> connectionList) {
+		this.absName = absName;
+		this.count = count;
+		this.connectionList = connectionList;
+	}
+
+	@Override
+	public void run() {
+		if (this.hostInfo.getVal() == null) {
+			ods.put("local", "configNodeNum", count);
+			return;
+		}
+		
+		HostMessage hostInfo = this.hostInfo.asClass(HostMessage.class);
+		//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);
+		ods.update("_CLIST", connectionList);
+		IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, ++count, connectionList);
+		cs.hostInfo.setKey("manager", absName);
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/node/IncomingReverseKey.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,30 @@
+package alice.topology.node;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.DataSegment;
+import alice.datasegment.Receiver;
+import org.msgpack.type.Value;
+
+public class IncomingReverseKey extends CodeSegment {
+
+	public Receiver reverseKey = ids.create(CommandType.TAKE);
+	public Receiver reverseCount = ids.create(CommandType.PEEK);
+	
+	@Override
+	public void run() {
+		String reverseKey = ((Value)this.reverseKey.getVal()).asRawValue().getString();
+		String from = this.reverseKey.from;
+		DataSegment.getAccept(from).reverseKey = reverseKey;
+		
+		int reverseCount = this.reverseCount.asInteger();
+		reverseCount++;
+		ods.update("local", "reverseCount", reverseCount);
+		
+		
+		IncomingReverseKey cs = new IncomingReverseKey();
+		cs.reverseKey.setKey("local", "reverseKey");
+		cs.reverseCount.setKey("local", "reverseCount");
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/node/Start.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,28 @@
+package alice.topology.node;
+
+import org.apache.log4j.Logger;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class Start extends CodeSegment {
+	
+	public Receiver done = ids.create(CommandType.PEEK);
+	private Logger logger = Logger.getLogger(Start.class);
+	private CodeSegment startCS;
+	
+	public Start(CodeSegment startCS) {
+		this.startCS = startCS;
+	}
+	
+	@Override
+	public void run() {
+		logger.info("Configuration finished.");
+		if (startCS == null)
+			return;
+		startCS.execute();
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/node/StartTopologyNode.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,69 @@
+package alice.topology.node;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.Enumeration;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.DataSegment;
+import alice.topology.HostMessage;
+
+public class StartTopologyNode extends CodeSegment {
+
+	private TopologyNodeConfig conf;
+	private CodeSegment startCS;
+	
+	public StartTopologyNode(TopologyNodeConfig conf, CodeSegment startCS) {
+		this.conf = conf;
+		this.startCS = startCS;
+	}
+	
+	@Override
+	public void run() {
+		DataSegment.connect("manager", "", conf.managerHostName, conf.managerPort, false);
+		String localHostName = null;
+		try {
+			localHostName = InetAddress.getLocalHost().getHostName();
+		} catch (UnknownHostException e) {
+			e.printStackTrace();
+		}
+		
+		HostMessage host = new HostMessage(localHostName, conf.localPort);
+		ods.put("manager", "host", host);
+		
+		IncomingAbstractHostName cs = new IncomingAbstractHostName(host);
+		cs.absName.setKey("local", "host");
+		
+		IncomingReverseKey cs2 = new IncomingReverseKey();
+		cs2.reverseKey.setKey("local", "reverseKey");
+		cs2.reverseCount.setKey("local", "reverseCount");
+		
+		ods.put("local", "reverseCount", 0);
+		
+		ConfigurationFinish cs3 = new ConfigurationFinish(startCS);
+		cs3.reverseCount.setKey("local", "reverseCount");
+		cs3.configNodeNum.setKey("local", "configNodeNum");
+		
+	}
+
+	@SuppressWarnings("unused")
+	private String getIPAddress() throws SocketException {
+		Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
+
+		while(interfaces.hasMoreElements()){
+			NetworkInterface network = interfaces.nextElement();
+			Enumeration<InetAddress> addresses = network.getInetAddresses();
+
+			while(addresses.hasMoreElements()){
+				String address = addresses.nextElement().getHostAddress();
+				if(!"127.0.0.1".equals(address) && !"0.0.0.0".equals(address)){
+					return address;
+				}
+			}
+		}
+		return "127.0.0.1";
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/node/TopologyNode.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,18 @@
+package alice.topology.node;
+
+import alice.codesegment.CodeSegment;
+import alice.daemon.AliceDaemon;
+
+public class TopologyNode {
+
+	public TopologyNode(TopologyNodeConfig conf, CodeSegment startCS) {
+		new AliceDaemon(conf).listen();
+		new StartTopologyNode(conf, startCS).execute();
+	}
+	
+	public static void main(String[] args) {
+		TopologyNodeConfig conf = new TopologyNodeConfig(args);
+		new TopologyNode(conf, null);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/topology/node/TopologyNodeConfig.java	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,21 @@
+package alice.topology.node;
+
+import alice.daemon.Config;
+
+public class TopologyNodeConfig extends Config {
+	
+	String managerHostName;
+	int managerPort;
+	
+	public TopologyNodeConfig(String[] args) {
+		super(args);
+		for (int i = 0; i< args.length; i++) {
+			if ("-host".equals(args[i])) {
+				managerHostName = args[++i];
+			} else if ("-port".equals(args[i])) {
+				managerPort = Integer.parseInt(args[++i]);
+			}
+		}
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/log4j.xml	Wed Apr 16 18:26:07 2014 +0900
@@ -0,0 +1,13 @@
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+   <appender name="Appender1" class="org.apache.log4j.FileAppender">
+      <param name="File" value="alice.log" ></param>
+      <layout class="org.apache.log4j.PatternLayout">
+         <param name="ConversionPattern" value="%d %-5p %c - %m [%t] (%F:%L)%n"/>
+      </layout>
+   </appender>
+   <root>
+      <level value="debug" />
+      <appender-ref ref="Appender1" />
+   </root>
+</log4j:configuration>