Mercurial > hg > Members > riono > TreeVNC_ja_comment
changeset 470:f7210f834403
add unique node id
author | mir3636 |
---|---|
date | Wed, 03 Aug 2016 19:09:11 +0900 |
parents | 3332879d1bd0 |
children | c1b4befc5933 |
files | src/main/java/jp/ac/u_ryukyu/treevnc/TreeManagement.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNetwork.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNode.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommand.java |
diffstat | 5 files changed, 19 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeManagement.java Fri Jul 29 16:03:51 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeManagement.java Wed Aug 03 19:09:11 2016 +0900 @@ -171,7 +171,7 @@ public void connectTo(TreeVNCNode newparent, TreeVNCNode n) throws IOException { TreeVncProtocol vc1 = new TreeVncProtocol(n.getHostname(),n.getPort()); - short nodeId = (short) ( n.getTreeNum() + ( treeId << 12 )); + short nodeId = (short) n.getId(); vc1.connectTo(newparent.getHostname(), newparent.getPort(), isLeader(n), nodeId); } @@ -191,10 +191,12 @@ * Determine tree topology and send CONNECT_TO command * @param hostname * @param port + * @param id */ - public void decideWhereToConnect(String hostname, int port, String localhostname) { + public void decideWhereToConnect(String hostname, int port, String localhostname, int id) { TreeVNCNode node = new TreeVNCNode(hostname, port, localhostname); node.setTreeNum(nodeList.size()); + node.setId(id); InetAddress ipAddress = null; try {
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Fri Jul 29 16:03:51 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Wed Aug 03 19:09:11 2016 +0900 @@ -70,6 +70,7 @@ private DatagramSocket socket = null; private byte[] originalInitData = null; private boolean childrenMulticast = true; + private int uniqueNodeId = 0; // uniquenodeid in all trees public TreeRFBProto(boolean isTreeManager, ViewerInterface viewer) { nets.setMyRfb(this); @@ -754,6 +755,10 @@ return treeManager; } + public int getNewNodeId () { + return uniqueNodeId++; + } + /** * change VNCServer is called when host change. *
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNetwork.java Fri Jul 29 16:03:51 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNetwork.java Wed Aug 03 19:09:11 2016 +0900 @@ -12,7 +12,6 @@ public class TreeVNCNetwork { - private HashMap<String, TreeManagement> interfaces = new HashMap<String, TreeManagement>(); private TreeRFBProto myRfb; private boolean useHostName = false; @@ -96,5 +95,4 @@ } - }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNode.java Fri Jul 29 16:03:51 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNode.java Wed Aug 03 19:09:11 2016 +0900 @@ -3,7 +3,8 @@ public class TreeVNCNode { String hostname; int port; - int treeNum; + int treeNum; //tree position + int id; //unique node id in all trees String localhostname; public TreeVNCNode(String hostname, int port, String localhostname) { @@ -36,5 +37,11 @@ hostname = localhostname; } + public int getId() { + return id; + } + public void setId(int id) { + this.id = id; + } }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommand.java Fri Jul 29 16:03:51 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommand.java Wed Aug 03 19:09:11 2016 +0900 @@ -88,7 +88,8 @@ * @param myHostName */ void handleWhereToConnect(int port, String hostname, String myHostName) { - rfb.getTreeManager(intf).decideWhereToConnect(hostname,port,myHostName); + int id = rfb.getNewNodeId(); + rfb.getTreeManager(intf).decideWhereToConnect(hostname,port,myHostName,id); } /**