Mercurial > hg > Database > Alice
changeset 473:041ec04d4d45 dispose
refactor
author | sugi |
---|---|
date | Sun, 30 Nov 2014 00:00:48 +0900 |
parents | 116e0fde9233 |
children | 6a71732cd3ee |
files | src/main/java/alice/daemon/Connection.java src/main/java/alice/daemon/ConnectionInfo.java src/main/java/alice/topology/manager/SendNodeInfo.java src/main/java/alice/topology/node/DeleteConnection.java src/main/java/alice/topology/node/ExecuteEvent.java |
diffstat | 5 files changed, 14 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/daemon/Connection.java Tue Nov 25 16:17:33 2014 +0900 +++ b/src/main/java/alice/daemon/Connection.java Sun Nov 30 00:00:48 2014 +0900 @@ -65,7 +65,7 @@ public void putConnectionInfo() { if (name!=null){ - ConnectionInfo c = new ConnectionInfo(name, socket.getInetAddress().getHostAddress(), socket.getPort()); + ConnectionInfo c = new ConnectionInfo(name, socket); ReceiveData rData = new ReceiveData(c, false, false); DataSegment.getLocal().put("_DISCONNECT", rData, null); }
--- a/src/main/java/alice/daemon/ConnectionInfo.java Tue Nov 25 16:17:33 2014 +0900 +++ b/src/main/java/alice/daemon/ConnectionInfo.java Sun Nov 30 00:00:48 2014 +0900 @@ -1,18 +1,21 @@ package alice.daemon; +import java.net.Socket; + import org.msgpack.annotation.Message; @Message public class ConnectionInfo { - public String name; + public String nodeName; + public String hostname; public String addr; public int port; - public ConnectionInfo(){} + public ConnectionInfo(String name, Socket socket){ + this.nodeName = name; + this.hostname = socket.getInetAddress().getHostName(); + this.addr = socket.getInetAddress().getHostAddress(); + this.port = socket.getPort(); + } - public ConnectionInfo(String name, String addr, int port) { - this.name = name; - this.addr = addr; - this.port = port; - } }
--- a/src/main/java/alice/topology/manager/SendNodeInfo.java Tue Nov 25 16:17:33 2014 +0900 +++ b/src/main/java/alice/topology/manager/SendNodeInfo.java Sun Nov 30 00:00:48 2014 +0900 @@ -20,7 +20,7 @@ private Receiver info4 = ids.create(CommandType.TAKE); private Receiver info5 = ids.create(CommandType.TAKE); - private int BINATY_TREE = 2; + private static int BINATY_TREE = 2; public SendNodeInfo(){ info.setKey("newHost");
--- a/src/main/java/alice/topology/node/DeleteConnection.java Tue Nov 25 16:17:33 2014 +0900 +++ b/src/main/java/alice/topology/node/DeleteConnection.java Sun Nov 30 00:00:48 2014 +0900 @@ -17,7 +17,7 @@ @Override public void run() { - String name = getConnectionInfo().name; + String name = getConnectionInfo().nodeName; @SuppressWarnings("unchecked") List<String> list = info.asClass(List.class);
--- a/src/main/java/alice/topology/node/ExecuteEvent.java Tue Nov 25 16:17:33 2014 +0900 +++ b/src/main/java/alice/topology/node/ExecuteEvent.java Sun Nov 30 00:00:48 2014 +0900 @@ -1,6 +1,5 @@ package alice.topology.node; -import java.lang.reflect.Field; import java.util.List; import alice.codesegment.CloseEventCodeSegment; @@ -26,23 +25,18 @@ for (Class<T> clazz : eventList){ // set MetaInfo if ("CloseEventCodeSegment".equals(clazz.getSuperclass().getSimpleName())) { - Field f = clazz.getField("metaInfo"); CloseEventCodeSegment obj = (CloseEventCodeSegment) clazz.newInstance(); - f.set(obj, info1); + obj.metaInfo = info; obj.ids.setKey(); obj.ids.receive(); } else if ("CodeSegment".equals(clazz.getSuperclass().getSimpleName())){ clazz.newInstance(); - } else { - } } } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); - } catch (NoSuchFieldException e) { - e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); }