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
|
|
18 final AliceDaemon daemon = new AliceDaemon(conf);
|
|
19 new Thread() {
|
|
20
|
|
21 @Override
|
|
22 public void run() {
|
|
23 // TODO Auto-generated method stub
|
|
24 daemon.listen();
|
|
25 }
|
|
26
|
|
27 }.start();
|
|
28
|
14
|
29 boolean connect = true;
|
|
30 do {
|
|
31 try {
|
|
32 SocketChannel sc = SocketChannel.open(new InetSocketAddress(conf.hostname, conf.connectPort));
|
|
33 Connection connection = new Connection(sc.socket());
|
|
34 RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connection);
|
|
35 DataSegment.regist(conf.key, manager);
|
|
36 connect = false;
|
|
37 } catch (IOException e) {
|
|
38 try {
|
|
39 Thread.sleep(500);
|
|
40 } catch (InterruptedException e1) {
|
|
41 e1.printStackTrace();
|
|
42 }
|
|
43 }
|
|
44 } while (connect);
|
|
45
|
19
|
46 new RemoteStartCodeSegment().execute();
|
14
|
47 }
|
|
48
|
|
49 }
|