Mercurial > hg > Database > Alice
changeset 374:5ceb1c4db167 multicast
create setter and getter for TopologyNodeConfig member-variables
author | sugi |
---|---|
date | Wed, 04 Jun 2014 00:18:26 +0900 |
parents | f6f6e481c00c |
children | e58f5f74748e |
files | src/main/java/alice/topology/node/StartTopologyNode.java src/main/java/alice/topology/node/TopologyNodeConfig.java |
diffstat | 2 files changed, 22 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/topology/node/StartTopologyNode.java Tue Jun 03 17:14:17 2014 +0900 +++ b/src/main/java/alice/topology/node/StartTopologyNode.java Wed Jun 04 00:18:26 2014 +0900 @@ -1,11 +1,7 @@ package alice.topology.node; import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; import java.net.UnknownHostException; -import java.util.Enumeration; - import alice.codesegment.CodeSegment; import alice.datasegment.DataSegment; import alice.topology.HostMessage; @@ -22,7 +18,7 @@ @Override public void run() { - DataSegment.connect("manager", "", conf.managerHostName, conf.managerPort, false); + DataSegment.connect("manager", "", conf.getManagerHostName(), conf.getManagerPort(), false); String localHostName = null; try { localHostName = InetAddress.getLocalHost().getHostName(); @@ -47,23 +43,5 @@ cs3.configNodeNum.setKey("local", "configNodeNum"); } - - @SuppressWarnings("unused") - private String getIPAddress() throws SocketException { - Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); - - while(interfaces.hasMoreElements()){ - NetworkInterface network = interfaces.nextElement(); - Enumeration<InetAddress> addresses = network.getInetAddresses(); - - while(addresses.hasMoreElements()){ - String address = addresses.nextElement().getHostAddress(); - if(!"127.0.0.1".equals(address) && !"0.0.0.0".equals(address)){ - return address; - } - } - } - return "127.0.0.1"; - } - + }
--- a/src/main/java/alice/topology/node/TopologyNodeConfig.java Tue Jun 03 17:14:17 2014 +0900 +++ b/src/main/java/alice/topology/node/TopologyNodeConfig.java Wed Jun 04 00:18:26 2014 +0900 @@ -4,18 +4,34 @@ public class TopologyNodeConfig extends Config { - String managerHostName; - int managerPort; + private String managerHostName; + private int managerPort; public TopologyNodeConfig(String[] args) { super(args); for (int i = 0; i< args.length; i++) { if ("-host".equals(args[i])) { - managerHostName = args[++i]; + setManagerHostName(args[++i]); } else if ("-port".equals(args[i])) { - managerPort = Integer.parseInt(args[++i]); + setManagerPort(Integer.parseInt(args[++i])); } } } + public String getManagerHostName() { + return managerHostName; + } + + public void setManagerHostName(String managerHostName) { + this.managerHostName = managerHostName; + } + + public int getManagerPort() { + return managerPort; + } + + public void setManagerPort(int managerPort) { + this.managerPort = managerPort; + } + }