Mercurial > hg > Database > Alice
comparison src/main/java/alice/datasegment/CompressedRemoteDataSegmentManager.java @ 525:30a74eee59c7 dispose
working TestRemoteAlice
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 16 Apr 2015 20:33:53 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
524:061478079bc7 | 525:30a74eee59c7 |
---|---|
1 package alice.datasegment; | |
2 | |
3 import alice.daemon.Connection; | |
4 import alice.daemon.IncomingTcpConnection; | |
5 import alice.daemon.OutboundTcpConnection; | |
6 import org.apache.log4j.Logger; | |
7 | |
8 import java.io.IOException; | |
9 import java.net.InetSocketAddress; | |
10 import java.nio.channels.SocketChannel; | |
11 | |
12 /** | |
13 * Created by e125769 on 4/11/15. | |
14 */ | |
15 public class CompressedRemoteDataSegmentManager extends RemoteDataSegmentManager { | |
16 | |
17 public CompressedRemoteDataSegmentManager(){} | |
18 | |
19 public CompressedRemoteDataSegmentManager(final String connectionKey, final String reverseKey, final String hostName, final int port) { | |
20 logger = Logger.getLogger(connectionKey); | |
21 connection = new Connection(); | |
22 connection.name = connectionKey; | |
23 final RemoteDataSegmentManager manager = this; | |
24 //new Thread(replyThread, "RemoteDataSegmentManager-" + connectionKey).start(); | |
25 new Thread("Connect-" + connectionKey) { | |
26 public void run() { | |
27 boolean connect = true; | |
28 do { | |
29 try { | |
30 SocketChannel sc = SocketChannel.open(new InetSocketAddress(hostName, port)); | |
31 connection.socket = sc.socket(); | |
32 connection.socket.setTcpNoDelay(true); | |
33 connect = false; | |
34 logger.info("Connect to " + connection.getInfoString()); | |
35 } catch (IOException e) { | |
36 try { | |
37 Thread.sleep(50); | |
38 } catch (InterruptedException e1) { | |
39 e1.printStackTrace(); | |
40 } | |
41 } | |
42 } while (connect); | |
43 IncomingTcpConnection in = new IncomingTcpConnection(connection, manager, reverseKey); | |
44 in.setName(reverseKey+"-IncomingTcp"); | |
45 in.setPriority(MAX_PRIORITY); | |
46 in.start(); | |
47 OutboundTcpConnection out = new OutboundTcpConnection(connection); | |
48 out.setName(connectionKey+"-OutboundTcp"); | |
49 out.setPriority(MAX_PRIORITY); | |
50 out.start(); | |
51 } | |
52 }.start(); | |
53 } | |
54 } |