|
From: Jonathan L. <le...@us...> - 2006-11-28 19:19:25
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5502/src/edu/harvard/syrah/pyxida/nc Modified Files: NCManager.java Log Message: added USE_ICMP Index: NCManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/NCManager.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** NCManager.java 28 Nov 2006 18:49:34 -0000 1.11 --- NCManager.java 28 Nov 2006 19:19:24 -0000 1.12 *************** *** 16,20 **** import edu.harvard.syrah.sbon.comm.AddressFactory; import edu.harvard.syrah.sbon.comm.AddressIF; ! import edu.harvard.syrah.sbon.comm.obj.*; //MEDTODO add proxy coordinates --- 16,20 ---- import edu.harvard.syrah.sbon.comm.AddressFactory; import edu.harvard.syrah.sbon.comm.AddressIF; ! import edu.harvard.syrah.sbon.comm.obj. *; //MEDTODO add proxy coordinates *************** *** 27,34 **** */ public class NCManager { ! private static final Log log = new Log(NCManager.class); // Number of dimensions ! private static final int NC_NUM_DIMS = Integer.parseInt(Config.getProperty("pyxida.dimensions", "5")); // Height is set within NCClient and is the "last dimension" --- 27,34 ---- */ public class NCManager { ! static final Log log = new Log(NCManager.class); // Number of dimensions ! static final int NC_NUM_DIMS = Integer.parseInt(Config.getProperty("pyxida.dimensions", "5")); // Height is set within NCClient and is the "last dimension" *************** *** 39,43 **** // JTLTODO: You need to test the regex below. It should work ! private String bootstrapList[] = Config.getProperty("pyxida.bootstraplist", "glenora.eecs.harvard.edu sb01.eecs.harvard.edu sb02.eecs.harvard.edu sb10.eecs.harvard.edu sb11.eecs.harvard.edu").split("[\\s]"); /** --- 39,45 ---- // JTLTODO: You need to test the regex below. It should work ! // String bootstrapList[] = Config.getProperty("pyxida.bootstraplist", "glenora.eecs.harvard.edu sb01.eecs.harvard.edu sb02.eecs.harvard.edu sb03.eecs.harvard.edu").split("[\\s]"); ! String bootstrapList[] = Config.getProperty("pyxida.bootstraplist", "glenora.eecs.harvard.edu sb01.eecs.harvard.edu").split("[\\s]"); ! Set<AddressIF> bootstrapAddrs; /** *************** *** 86,89 **** --- 88,92 ---- downNeighbors = new HashSet<AddressIF>(); pendingNeighbors = new HashSet<AddressIF>(); + bootstrapAddrs = new HashSet<AddressIF>(); log.debug("Resolving bootstrap list"); *************** *** 95,98 **** --- 98,103 ---- log.debug("remoteNode='" + remoteNode + "'"); AddressIF remoteAddr = addrMap.get(remoteNode); + // we keep these around in case we run out of neighbors in the future + bootstrapAddrs.add(remoteAddr); addPendingNeighbor(remoteAddr); } *************** *** 270,273 **** --- 275,279 ---- void addDownNeighbor(AddressIF node) { + if (node.equals(comm.getLocalAddress())) return; pendingNeighbors.remove(node); upNeighbors.remove(node); *************** *** 311,314 **** --- 317,324 ---- GossipRequestMsg msg = new GossipRequestMsg(localNC.nc.getSystemCoords(), getUpNeighbors(null)); + final long sendStamp = System.nanoTime(); + + log.debug ("Sending gossip request to "+neighbor); + comm.sendRequestMessage(msg, neighbor, new ObjCommRRCB<GossipResponseMsg>() { *************** *** 316,324 **** AddressIF remoteAddr, Long ts) { // LOWTODO can use time of this instead of ping time // if we want to not use jpcap pings // (running not at root) // ! // However however PRP not sure what the best way is to integrate this... // Ideally, all latency measurements should be done by the ping manager...? --- 326,336 ---- AddressIF remoteAddr, Long ts) { + double rtt = (System.nanoTime() - sendStamp) / 1000000d; + // LOWTODO can use time of this instead of ping time // if we want to not use jpcap pings // (running not at root) // ! // However PRP not sure what the best way is to integrate this... // Ideally, all latency measurements should be done by the ping manager...? *************** *** 328,331 **** --- 340,347 ---- addPendingNeighbors(responseMsg.nodes); + log.debug("app rtt of "+rtt+" to "+neighbor); + + if (Pyxida.USE_ICMP) { + // and ping him pingManager.addPingRequest(neighbor, new CB1<Double>() { *************** *** 336,349 **** addUpNeighbor(neighbor); // MEDTODO convert nclib to use floats // // JTLTODO: why do you want to use floats and not double? won't we run into // accuracy problems? ! long lat_ms = (long) Math.round(latency); long curr_time = System.currentTimeMillis(); // and update our coordinate localNC.nc.processSample(neighbor, responseMsg.remoteCoordinate, ! responseMsg.remoteError, lat_ms, responseMsg.remoteAge, curr_time, true); log.debug("update: "+localNC.nc); --- 352,367 ---- addUpNeighbor(neighbor); + log.debug("latency of "+latency+" to "+neighbor); + // MEDTODO convert nclib to use floats // // JTLTODO: why do you want to use floats and not double? won't we run into // accuracy problems? ! //long lat_ms = (long) Math.round(latency); long curr_time = System.currentTimeMillis(); // and update our coordinate localNC.nc.processSample(neighbor, responseMsg.remoteCoordinate, ! responseMsg.remoteError, latency, responseMsg.remoteAge, curr_time, true); log.debug("update: "+localNC.nc); *************** *** 360,363 **** --- 378,393 ---- } }); + } else { + // NOT using PingManager + long curr_time = System.currentTimeMillis(); + + // and update our coordinate + localNC.nc.processSample(neighbor, responseMsg.remoteCoordinate, + responseMsg.remoteError, rtt, + responseMsg.remoteAge, curr_time, true); + + log.debug("update: "+localNC.nc); + + } break; *************** *** 375,384 **** } AddressIF pickGossipNode() { // LOWTODO ask our ncClient if it has a preferred gossip node // if not, use somebody from our neighbor set ! return getUpNeighbor(); ! } --- 405,430 ---- } + void resetBootstrapNeighbors() { + for (AddressIF remoteAddr : bootstrapAddrs) { + if (!remoteAddr.equals(comm.getLocalAddress())) { + upNeighbors.remove(remoteAddr); + downNeighbors.remove(remoteAddr); + pendingNeighbors.add(remoteAddr); + } + } + } + AddressIF pickGossipNode() { + AddressIF neighbor; // LOWTODO ask our ncClient if it has a preferred gossip node // if not, use somebody from our neighbor set ! neighbor = getUpNeighbor(); ! if (neighbor == null) { ! resetBootstrapNeighbors(); ! neighbor = getUpNeighbor(); ! } ! assert (neighbor != null); ! return neighbor; } |