# HG changeset patch # User e095732 # Date 1359030196 -32400 # Node ID d7816b9b72e9d406e20fe98247be9db232292480 # Parent abe00abb2fd8c7f97ad7163ccfc2fb99c0154934 minor change diff -r abe00abb2fd8 -r d7816b9b72e9 src/alice/daemon/AliceDaemon.java --- 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; diff -r abe00abb2fd8 -r d7816b9b72e9 src/alice/test/codesegment/local/StartCodeSegment.java --- 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); diff -r abe00abb2fd8 -r d7816b9b72e9 src/alice/test/codesegment/local/TestCodeSegment.java --- 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"); } diff -r abe00abb2fd8 -r d7816b9b72e9 src/alice/test/topology/share/CheckMyName.java --- 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); diff -r abe00abb2fd8 -r d7816b9b72e9 src/alice/topology/node/StartTopologyNode.java --- 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 interfaces = NetworkInterface.getNetworkInterfaces(); + + while(interfaces.hasMoreElements()){ + NetworkInterface network = interfaces.nextElement(); + Enumeration 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"; + } + }