diff src/alice/test/codesegment/remote/TestRemoteAlice.java @ 22:2ca2d961a8d2

implements outline of TopologyManager
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Tue, 17 Jan 2012 00:40:27 +0900
parents src/alice/test/codesegment/TestRemoteAlice.java@0bb03861b5cd
children ca079a730d0b
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/codesegment/remote/TestRemoteAlice.java	Tue Jan 17 00:40:27 2012 +0900
@@ -0,0 +1,39 @@
+package alice.test.codesegment.remote;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.channels.SocketChannel;
+
+import alice.daemon.AliceDaemon;
+import alice.daemon.Connection;
+import alice.datasegment.DataSegment;
+import alice.datasegment.RemoteDataSegmentManager;
+
+public class TestRemoteAlice {
+
+	public static void main(String[] args) {
+		TestRemoteConfig conf = new TestRemoteConfig(args);
+
+		new AliceDaemon(conf).listen();
+		
+		boolean connect = true;
+		do {
+			try {
+				SocketChannel sc = SocketChannel.open(new InetSocketAddress(conf.hostname, conf.connectPort));
+				Connection connection = new Connection(sc.socket());
+				RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connection);
+				DataSegment.regist(conf.key, manager);
+				connect = false;
+			} catch (IOException e) {
+				try {
+					Thread.sleep(500);
+				} catch (InterruptedException e1) {
+					e1.printStackTrace();
+				}
+			}
+		} while (connect);
+		
+		new RemoteStartCodeSegment().execute();
+	}
+
+}