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.codesegment.CodeSegment;
|
|
8 import alice.daemon.AliceDaemon;
|
|
9 import alice.daemon.Config;
|
|
10 import alice.daemon.Connection;
|
|
11 import alice.datasegment.DataSegment;
|
|
12 import alice.datasegment.RemoteDataSegmentManager;
|
|
13
|
|
14 public class TestRemoteAlice {
|
|
15
|
|
16 public static void main(String[] args) {
|
|
17 Config conf = new Config(args);
|
15
|
18 System.out.println(conf.port);
|
|
19 System.out.println(conf.hostname);
|
|
20 System.out.println(conf.connectPort);
|
|
21 System.out.println(conf.key);
|
|
22
|
|
23 final AliceDaemon daemon = new AliceDaemon(conf);
|
|
24 new Thread() {
|
|
25
|
|
26 @Override
|
|
27 public void run() {
|
|
28 // TODO Auto-generated method stub
|
|
29 daemon.listen();
|
|
30 }
|
|
31
|
|
32 }.start();
|
|
33
|
14
|
34 boolean connect = true;
|
|
35 do {
|
|
36 try {
|
|
37 SocketChannel sc = SocketChannel.open(new InetSocketAddress(conf.hostname, conf.connectPort));
|
|
38 Connection connection = new Connection(sc.socket());
|
|
39 RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connection);
|
|
40 DataSegment.regist(conf.key, manager);
|
|
41 connect = false;
|
|
42 System.out.println("connected");
|
|
43 } catch (IOException e) {
|
|
44 try {
|
15
|
45 System.out.println("wait");
|
14
|
46 Thread.sleep(500);
|
|
47 } catch (InterruptedException e1) {
|
|
48 e1.printStackTrace();
|
|
49 }
|
|
50 }
|
|
51 } while (connect);
|
|
52
|
|
53 CodeSegment cs = new RemoteStartCodeSegment();
|
|
54 cs.ids.execute();
|
|
55 }
|
|
56
|
|
57 }
|