Mercurial > hg > Database > Alice
changeset 480:c06070403ed4 dispose
named IncomingTcp and OutboundTcp Thread
author | sugi |
---|---|
date | Fri, 05 Dec 2014 03:19:25 +0900 |
parents | 1550cb8429df |
children | 549cc29aca59 |
files | src/main/java/alice/daemon/AcceptThread.java src/main/java/alice/daemon/IncomingTcpConnection.java src/main/java/alice/datasegment/MulticastDataSegmentManager.java src/main/java/alice/datasegment/RemoteDataSegmentManager.java src/main/java/alice/topology/manager/SendNodeInfo.java src/main/java/alice/topology/node/IncomingReverseKey.java src/main/java/alice/topology/node/StartTopologyNode.java |
diffstat | 7 files changed, 28 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/daemon/AcceptThread.java Fri Dec 05 02:36:17 2014 +0900 +++ b/src/main/java/alice/daemon/AcceptThread.java Fri Dec 05 03:19:25 2014 +0900 @@ -28,12 +28,14 @@ log.info("Accept " + socket.getInetAddress().getHostName() + ":" + socket.getPort()); Connection connection = new Connection(socket); String key = "accept" + counter; - IncomingTcpConnection incoming = + IncomingTcpConnection in = new IncomingTcpConnection(connection, DataSegment.get("local"), key); - incoming.start(); - DataSegment.setAccept(key, incoming); - OutboundTcpConnection outbound = new OutboundTcpConnection(connection); - outbound.start(); + in.setName("IncomingTcp"); + in.start(); + DataSegment.setAccept(key, in); + OutboundTcpConnection out = new OutboundTcpConnection(connection); + out.setName("OutboundTcp"); + out.start(); counter++; } catch (IOException e) { e.printStackTrace();
--- a/src/main/java/alice/daemon/IncomingTcpConnection.java Fri Dec 05 02:36:17 2014 +0900 +++ b/src/main/java/alice/daemon/IncomingTcpConnection.java Fri Dec 05 03:19:25 2014 +0900 @@ -18,9 +18,9 @@ public class IncomingTcpConnection extends Thread { - public Connection connection; - public DataSegmentManager manager; - public String reverseKey; + private Connection connection; + protected DataSegmentManager manager; + protected String reverseKey; private LocalDataSegmentManager lmanager = DataSegment.getLocal(); public IncomingTcpConnection(DataSegmentManager manager) { @@ -91,7 +91,6 @@ break; } } catch (ClosedChannelException e) { - connection.putConnectionInfo(); return; } catch (EOFException e) { return; @@ -113,4 +112,9 @@ } return b; } + + public void setReverseKey(String name) { + this.reverseKey = name; + setName(name+"-IncomingTcp"); + } }
--- a/src/main/java/alice/datasegment/MulticastDataSegmentManager.java Fri Dec 05 02:36:17 2014 +0900 +++ b/src/main/java/alice/datasegment/MulticastDataSegmentManager.java Fri Dec 05 03:19:25 2014 +0900 @@ -32,8 +32,12 @@ SocketAddress sAddrs = new InetSocketAddress(mAddr,port); connection = new MulticastConnection(dcs, sAddrs); // sender - new IncomingUdpConnection((MulticastConnection) connection, receiver, this).start(); - new OutboundTcpConnection(connection).start(); // OutboundUdpConnection sender + IncomingUdpConnection in = new IncomingUdpConnection((MulticastConnection) connection, receiver, this); + in.setName("multicast-IncomingUdp"); + in.start(); + OutboundTcpConnection out = new OutboundTcpConnection(connection); // OutboundUdpConnection sender + out.setName(connectionKey+"OutboundUdp"); + out.start(); } catch (Exception e) { e.printStackTrace();
--- a/src/main/java/alice/datasegment/RemoteDataSegmentManager.java Fri Dec 05 02:36:17 2014 +0900 +++ b/src/main/java/alice/datasegment/RemoteDataSegmentManager.java Fri Dec 05 03:19:25 2014 +0900 @@ -13,9 +13,8 @@ import alice.daemon.OutboundTcpConnection; public class RemoteDataSegmentManager extends DataSegmentManager { - - Connection connection; - Logger logger; + protected Connection connection; + protected Logger logger; public RemoteDataSegmentManager(){} @@ -44,9 +43,11 @@ } } while (connect); IncomingTcpConnection in = new IncomingTcpConnection(connection, manager, reverseKey); + in.setName(reverseKey+"-IncomingTcp"); in.setPriority(MAX_PRIORITY); in.start(); OutboundTcpConnection out = new OutboundTcpConnection(connection); + out.setName(connectionKey+"-OutboundTcp"); out.setPriority(MAX_PRIORITY); out.start(); }
--- a/src/main/java/alice/topology/manager/SendNodeInfo.java Fri Dec 05 02:36:17 2014 +0900 +++ b/src/main/java/alice/topology/manager/SendNodeInfo.java Fri Dec 05 03:19:25 2014 +0900 @@ -41,7 +41,7 @@ String nodeName = "node"+comingHostCount; // Manager connect to Node - DataSegment.connect(nodeName, "", host.name, host.port); + DataSegment.connect(nodeName, nodeName, host.name, host.port); ods.put(nodeName, "host", nodeName); ods.put(nodeName, "cookie", cookie);
--- a/src/main/java/alice/topology/node/IncomingReverseKey.java Fri Dec 05 02:36:17 2014 +0900 +++ b/src/main/java/alice/topology/node/IncomingReverseKey.java Fri Dec 05 03:19:25 2014 +0900 @@ -14,7 +14,7 @@ public void run() { String reverseKey = this.reverseKey.asString(); String from = this.reverseKey.from; - DataSegment.getAccept(from).reverseKey = reverseKey; + DataSegment.getAccept(from).setReverseKey(reverseKey); int reverseCount = this.reverseCount.asInteger(); reverseCount++;
--- a/src/main/java/alice/topology/node/StartTopologyNode.java Fri Dec 05 02:36:17 2014 +0900 +++ b/src/main/java/alice/topology/node/StartTopologyNode.java Fri Dec 05 03:19:25 2014 +0900 @@ -20,7 +20,7 @@ @Override public void run() { - DataSegment.connect("manager", "", conf.getManagerHostName(), conf.getManagerPort()); + DataSegment.connect("manager", "manager", conf.getManagerHostName(), conf.getManagerPort()); String localHostName = null; try { localHostName = InetAddress.getLocalHost().getHostName();