Mercurial > hg > Members > tatsuki > Alice
changeset 175:d7816b9b72e9 working
minor change
author | e095732 |
---|---|
date | Thu, 24 Jan 2013 21:23:16 +0900 |
parents | abe00abb2fd8 |
children | 4658bf530834 |
files | src/alice/daemon/AliceDaemon.java src/alice/test/codesegment/local/StartCodeSegment.java src/alice/test/codesegment/local/TestCodeSegment.java src/alice/test/topology/share/CheckMyName.java src/alice/topology/node/StartTopologyNode.java |
diffstat | 5 files changed, 30 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/daemon/AliceDaemon.java Mon Jan 14 19:22:36 2013 +0900 +++ b/src/alice/daemon/AliceDaemon.java Thu Jan 24 21:23:16 2013 +0900 @@ -2,7 +2,6 @@ import java.io.FileWriter; import java.io.IOException; -import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.nio.channels.ServerSocketChannel;
--- a/src/alice/test/codesegment/local/StartCodeSegment.java Mon Jan 14 19:22:36 2013 +0900 +++ b/src/alice/test/codesegment/local/StartCodeSegment.java Thu Jan 24 21:23:16 2013 +0900 @@ -20,7 +20,7 @@ ods.put("local", "key1", 2); ods.put("local", "key1", 3); - new TestCodeSegment(); + new TestCodeSegment(1); System.out.println("create TestCodeSegment"); //ods.update("local", "key1", 0);
--- a/src/alice/test/codesegment/local/TestCodeSegment.java Mon Jan 14 19:22:36 2013 +0900 +++ b/src/alice/test/codesegment/local/TestCodeSegment.java Thu Jan 24 21:23:16 2013 +0900 @@ -9,7 +9,7 @@ static int count = 0; // create input datasegment arg1 - Receiver arg1 = ids.create(CommandType.PEEK); + Receiver arg1 = ids.create(CommandType.TAKE); public TestCodeSegment(){ arg1.setKey("key1"); }
--- a/src/alice/test/topology/share/CheckMyName.java Mon Jan 14 19:22:36 2013 +0900 +++ b/src/alice/test/topology/share/CheckMyName.java Thu Jan 24 21:23:16 2013 +0900 @@ -33,7 +33,7 @@ RoutingTable routing = new RoutingTable(); if (type.equals("cli")){ - //System.out.println("cli"+num); + System.out.println("cli"+num); routing.table.add(new Routing("parent")); ods.put("local", "list", routing); @@ -41,7 +41,7 @@ ods.put("parent", "member", name); new SendData(0); }else if (type.equals("node")){ - //System.out.println("node"+num); + System.out.println("node"+num); if (num != 0){ routing.table.add(new Routing("parent")); ods.put("parent", "member", name);
--- a/src/alice/topology/node/StartTopologyNode.java Mon Jan 14 19:22:36 2013 +0900 +++ b/src/alice/topology/node/StartTopologyNode.java Thu Jan 24 21:23:16 2013 +0900 @@ -1,7 +1,9 @@ package alice.topology.node; import java.net.InetAddress; -import java.net.UnknownHostException; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.Enumeration; import alice.codesegment.CodeSegment; import alice.datasegment.DataSegment; @@ -21,8 +23,12 @@ public void run() { DataSegment.connect("manager", "", conf.managerHostName, conf.managerPort); String localHostName = null; - // nocalHostName = InetAddress.getLocalHost().getHostName(); - localHostName = "192.168.128.41"; + //localHostName = InetAddress.getLocalHost().getHostName(); + try { + localHostName = getIPAddress(); + } catch (SocketException e) { + e.printStackTrace(); + } HostMessage host = new HostMessage(localHostName, conf.localPort); ods.put("manager", "host", host); @@ -39,4 +45,21 @@ cs3.configNodeNum.setKey("local", "configNodeNum"); } + 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"; + } + }