14
|
1 package alice.test.codesegment;
|
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.net.InetSocketAddress;
|
|
5 import java.nio.channels.SocketChannel;
|
|
6
|
|
7 import alice.daemon.AliceDaemon;
|
|
8 import alice.daemon.Config;
|
|
9 import alice.daemon.Connection;
|
|
10 import alice.datasegment.DataSegment;
|
|
11 import alice.datasegment.RemoteDataSegmentManager;
|
|
12
|
|
13 public class TestRemoteAlice {
|
|
14
|
|
15 public static void main(String[] args) {
|
|
16 Config conf = new Config(args);
|
15
|
17
|
20
|
18 new AliceDaemon(conf).listen();
|
15
|
19
|
14
|
20 boolean connect = true;
|
|
21 do {
|
|
22 try {
|
|
23 SocketChannel sc = SocketChannel.open(new InetSocketAddress(conf.hostname, conf.connectPort));
|
|
24 Connection connection = new Connection(sc.socket());
|
|
25 RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connection);
|
|
26 DataSegment.regist(conf.key, manager);
|
|
27 connect = false;
|
|
28 } catch (IOException e) {
|
|
29 try {
|
|
30 Thread.sleep(500);
|
|
31 } catch (InterruptedException e1) {
|
|
32 e1.printStackTrace();
|
|
33 }
|
|
34 }
|
|
35 } while (connect);
|
|
36
|
19
|
37 new RemoteStartCodeSegment().execute();
|
14
|
38 }
|
|
39
|
|
40 }
|