You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(123) |
Dec
(100) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(12) |
Feb
(80) |
Mar
(35) |
Apr
|
May
|
Jun
(28) |
Jul
(10) |
Aug
(6) |
Sep
|
Oct
|
Nov
(16) |
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
(8) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
(6) |
| 2009 |
Jan
(20) |
Feb
(1) |
Mar
(19) |
Apr
(12) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
|
From: Jonathan L. <le...@us...> - 2006-11-28 21:13:18
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15144/src/edu/harvard/syrah/pyxida Modified Files: Pyxida.java Log Message: fixed bug in pending neighbor list management Index: Pyxida.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/Pyxida.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Pyxida.java 28 Nov 2006 19:19:24 -0000 1.13 --- Pyxida.java 28 Nov 2006 21:13:13 -0000 1.14 *************** *** 64,67 **** --- 64,68 ---- case OK: { // Initialise the external APIs + /* apiManager = new APIManager(ncManager); apiManager.init(new CB0() { *************** *** 81,84 **** --- 82,87 ---- }); + + */ break; } |
|
From: Jonathan L. <le...@us...> - 2006-11-28 21:13:18
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15144/src/edu/harvard/syrah/pyxida/nc Modified Files: NCManager.java Log Message: fixed bug in pending neighbor list management Index: NCManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/NCManager.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** NCManager.java 28 Nov 2006 19:19:24 -0000 1.12 --- NCManager.java 28 Nov 2006 21:13:13 -0000 1.13 *************** *** 32,35 **** --- 32,37 ---- static final int NC_NUM_DIMS = Integer.parseInt(Config.getProperty("pyxida.dimensions", "5")); + public static final boolean WATCH_NEIGHBORS = Boolean.parseBoolean(Config.getConfigProps().getProperty("pyxida.ncmanager.watch_neighbors", "false")); + // Height is set within NCClient and is the "last dimension" // of the coordinates array. *************** *** 231,238 **** AddressIF upNeighbor; if (upNeighbors.size() == 0 || ! Pyxida.random.nextDouble() < pctUsePendingNeighbor) { upNeighbor = PUtil.getRandomObject(pendingNeighbors); } else { upNeighbor = PUtil.getRandomObject(upNeighbors); } --- 233,243 ---- AddressIF upNeighbor; if (upNeighbors.size() == 0 || ! (pendingNeighbors.size() > 0 && ! Pyxida.random.nextDouble() < pctUsePendingNeighbor)) { upNeighbor = PUtil.getRandomObject(pendingNeighbors); + log.debug("getUpNeighbor using pending: "+upNeighbor); } else { upNeighbor = PUtil.getRandomObject(upNeighbors); + log.debug("getUpNeighbor using up: "+upNeighbor); } *************** *** 264,268 **** --- 269,277 ---- !downNeighbors.contains(node)) { pendingNeighbors.add(node); + log.debug("addPendingNeighbor: "+node); + } else { + log.debug("!addPendingNeighbor: "+node); } + if (WATCH_NEIGHBORS) dumpNeighbors(); } *************** *** 272,275 **** --- 281,286 ---- pendingNeighbors.remove(node); upNeighbors.add(node); + log.debug("addUpNeighbor: "+node); + if (WATCH_NEIGHBORS) dumpNeighbors(); } *************** *** 279,282 **** --- 290,312 ---- upNeighbors.remove(node); downNeighbors.add(node); + log.debug("addDownNeighbor: "+node); + if (WATCH_NEIGHBORS) dumpNeighbors(); + } + + void dumpNeighbors () { + StringBuffer sb = new StringBuffer(); + sb.append("pending:"); + for (AddressIF node : pendingNeighbors) { + sb.append (" "+node); + } + sb.append(" up:"); + for (AddressIF node : upNeighbors) { + sb.append (" "+node); + } + sb.append(" down:"); + for (AddressIF node : downNeighbors) { + sb.append (" "+node); + } + log.debug(new String(sb)); } |
|
From: Jonathan L. <le...@us...> - 2006-11-28 19:19:25
|
Update of /cvsroot/pyxida/Pyxida/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5502/config Modified Files: pyxida.cfg Log Message: added USE_ICMP Index: pyxida.cfg =================================================================== RCS file: /cvsroot/pyxida/Pyxida/config/pyxida.cfg,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pyxida.cfg 27 Nov 2006 15:57:21 -0000 1.2 --- pyxida.cfg 28 Nov 2006 19:19:24 -0000 1.3 *************** *** 10,15 **** ############################## ! #format: ! #sbon.local.port=16170 ! #pyxida.bootstraplist="glenora.eecs.harvard.edu, sb01.eecs.harvard.edu, sb02.eecs.harvard.edu, sb10.eecs.harvard.edu, sb11.eecs.harvard.edu" --- 10,16 ---- ############################## ! pyxida.port=9 ! #pyxida.bootstraplist=glenora.eecs.harvard.edu sb01.eecs.harvard.edu sb02.eecs.harvard.edu sb10.eecs.harvard.edu sb11.eecs.harvard.edu ! ! #pyxida.use_icmp=false |
|
From: Jonathan L. <le...@us...> - 2006-11-28 19:19:25
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5502/src/edu/harvard/syrah/pyxida Modified Files: Pyxida.java Log Message: added USE_ICMP Index: Pyxida.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/Pyxida.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Pyxida.java 28 Nov 2006 18:49:35 -0000 1.12 --- Pyxida.java 28 Nov 2006 19:19:24 -0000 1.13 *************** *** 26,29 **** --- 26,32 ---- public static final int COMM_PORT = Integer.parseInt(Config.getConfigProps().getProperty("pyxida.port", "55500")); + public static final boolean USE_ICMP = Boolean.parseBoolean(Config.getConfigProps().getProperty("pyxida.use_icmp", "false")); + + private static Pyxida pyxida = null; |
|
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; } |
|
From: Jonathan L. <le...@us...> - 2006-11-28 19:19:25
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5502/src/edu/harvard/syrah/pyxida/ping Modified Files: PingManager.java Log Message: added USE_ICMP Index: PingManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping/PingManager.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PingManager.java 28 Nov 2006 18:49:35 -0000 1.9 --- PingManager.java 28 Nov 2006 19:19:24 -0000 1.10 *************** *** 4,7 **** --- 4,8 ---- import java.util.List; + import edu.harvard.syrah.pyxida.Pyxida; import edu.harvard.syrah.prp.Log; import edu.harvard.syrah.sbon.async.CBResult; *************** *** 24,28 **** public PingManager() { ! pingers.add(new ICMPPinger()); } --- 25,31 ---- public PingManager() { ! if (Pyxida.USE_ICMP) { ! pingers.add(new ICMPPinger()); ! } } |
|
From: Peter P. <pr...@us...> - 2006-11-28 18:49:48
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26619/src/edu/harvard/syrah/pyxida/ping Modified Files: PingManager.java Log Message: Implemented APIManager with XMLRPC API Implemented measurement call in PingManager (I didn't test either, so sent me bug reports.) Index: PingManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping/PingManager.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PingManager.java 27 Nov 2006 20:31:40 -0000 1.8 --- PingManager.java 28 Nov 2006 18:49:35 -0000 1.9 *************** *** 1,11 **** ! package edu.harvard.syrah.pyxida.ping; ! import java.util.HashSet; ! import java.util.Set; import edu.harvard.syrah.prp.Log; import edu.harvard.syrah.sbon.async.CBResult; import edu.harvard.syrah.sbon.async.CallbacksIF.CB0; import edu.harvard.syrah.sbon.async.CallbacksIF.CB1; import edu.harvard.syrah.sbon.comm.AddressFactory; import edu.harvard.syrah.sbon.comm.AddressIF; --- 1,13 ---- ! package edu.harvard.syrah.pyxida.ping; ! import java.util.LinkedList; ! import java.util.List; import edu.harvard.syrah.prp.Log; import edu.harvard.syrah.sbon.async.CBResult; + import edu.harvard.syrah.sbon.async.LoopIt; import edu.harvard.syrah.sbon.async.CallbacksIF.CB0; import edu.harvard.syrah.sbon.async.CallbacksIF.CB1; + import edu.harvard.syrah.sbon.async.CallbacksIF.CB2; import edu.harvard.syrah.sbon.comm.AddressFactory; import edu.harvard.syrah.sbon.comm.AddressIF; *************** *** 16,23 **** private static final String DEFAULT_PING_HOSTNAME = "www.google.com"; ! private AddressIF defaultPingAddr; ! private Set<PingerIF> pingerSet = new HashSet<PingerIF>(); public void init(final CB0 cbDone) { --- 18,29 ---- private static final String DEFAULT_PING_HOSTNAME = "www.google.com"; ! private AddressIF defaultPingAddr; ! private List<PingerIF> pingers = new LinkedList<PingerIF>(); ! ! public PingManager() { ! pingers.add(new ICMPPinger()); ! } public void init(final CB0 cbDone) { *************** *** 25,51 **** protected void cb(CBResult result, AddressIF addr) { PingManager.this.defaultPingAddr = addr; ! ! // TODO This needs to be made more generic ! ! //PingerIF pinger = new ICMPPinger(); ! //pingerSet.add(pinger); ! //pinger.init(defaultPingAddr, cbDone); ! ! cbDone.callOK(); ! ! } }); ! } public void addPingRequest(AddressIF nodeA, AddressIF nodeB, CB1<Float> cbMeasurement) { // TODO implement me ! ! // TODO use floats, not doubles (or longs) ! // This is to limit the amount of memory used within Azureus ! log.warn ("implement me"); } - } --- 31,60 ---- protected void cb(CBResult result, AddressIF addr) { PingManager.this.defaultPingAddr = addr; ! ! new LoopIt<PingerIF>(pingers, new CB2<PingerIF, CB0>() { ! protected void cb(CBResult result, PingerIF pinger, CB0 cbNextIter) { ! log.debug("Initialising pinger=" + pinger.getClass()); ! pinger.init(defaultPingAddr, cbNextIter); ! } ! }).execute(cbDone); ! } }); ! } + public void addPingRequest(AddressIF remoteNode, CB1<Double> cbMeasurement) { + + /* + * TODO replace this with a more advanced pinger selection depending on the target + * and its ping history etc. For now, we're picking the first pinger from the list. + */ + + PingerIF pinger = pingers.get(0); + pinger.ping(remoteNode, cbMeasurement); } public void addPingRequest(AddressIF nodeA, AddressIF nodeB, CB1<Float> cbMeasurement) { // TODO implement me ! throw new UnsupportedOperationException(); } } |
|
From: Peter P. <pr...@us...> - 2006-11-28 18:49:42
|
Update of /cvsroot/pyxida/Pyxida/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26619/lib Modified Files: sbon-async.jar Log Message: Implemented APIManager with XMLRPC API Implemented measurement call in PingManager (I didn't test either, so sent me bug reports.) Index: sbon-async.jar =================================================================== RCS file: /cvsroot/pyxida/Pyxida/lib/sbon-async.jar,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 Binary files /tmp/cvsossBPT and /tmp/cvskVtWV8 differ |
|
From: Peter P. <pr...@us...> - 2006-11-28 18:49:42
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26619/src/edu/harvard/syrah/pyxida Modified Files: Pyxida.java Log Message: Implemented APIManager with XMLRPC API Implemented measurement call in PingManager (I didn't test either, so sent me bug reports.) Index: Pyxida.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/Pyxida.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Pyxida.java 27 Nov 2006 16:24:59 -0000 1.11 --- Pyxida.java 28 Nov 2006 18:49:35 -0000 1.12 *************** *** 62,66 **** // Initialise the external APIs apiManager = new APIManager(ncManager); ! apiManager.init(); break; } --- 62,81 ---- // Initialise the external APIs apiManager = new APIManager(ncManager); ! apiManager.init(new CB0() { ! protected void cb(CBResult result) { ! switch (result.state) { ! case OK: { ! log.main("Pyxida node initialised correctly."); ! break; ! } ! case TIMEOUT: ! case ERROR: { ! log.error("Initialising failed: " + result.toString()); ! break; ! } ! } ! } ! ! }); break; } |
|
From: Peter P. <pr...@us...> - 2006-11-28 18:49:39
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26619/src/edu/harvard/syrah/pyxida/api Modified Files: APIManager.java Added Files: APIIF.java XMLRPC_API.java Removed Files: ExternalAPIIF.java Log Message: Implemented APIManager with XMLRPC API Implemented measurement call in PingManager (I didn't test either, so sent me bug reports.) --- ExternalAPIIF.java DELETED --- --- NEW FILE: APIIF.java --- package edu.harvard.syrah.pyxida.api; import edu.harvard.syrah.pyxida.nc.lib.Coordinate; import edu.harvard.syrah.sbon.async.CallbacksIF.CB0; import edu.harvard.syrah.sbon.async.CallbacksIF.CB1; import edu.harvard.syrah.sbon.comm.AddressIF; public interface APIIF { /** * Initialise this external api * @param cbDone */ public void init(CB0 cbDone); /** * Returns a coordinate * of either a substrate node or a local proxy node */ public Coordinate getCoord(String node); // Estimate the RTT public void estimateRTT(String nodeA, AddressIF nodeB, CB1<Double> cbLatency); // Create a new proxy coord with a lease // lease is given in ms // lease of 0 will expire in one hour public void createProxyCoord(String remoteNode, long lease, CB1<Object> cbResult); // Renew proxy coord lease public void renewProxyCoord(String remoteNode, long lease, CB1<Object> cbResult); public void destroyProxyCoord(String remoteNode, CB1<Object> cbResult); // TODO Add routing methods // TODO add startup and shutdown either here or to pyxida main } Index: APIManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/api/APIManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** APIManager.java 21 Nov 2006 21:14:59 -0000 1.2 --- APIManager.java 28 Nov 2006 18:49:34 -0000 1.3 *************** *** 1,17 **** package edu.harvard.syrah.pyxida.api; import edu.harvard.syrah.prp.Log; import edu.harvard.syrah.pyxida.nc.NCManager; public class APIManager { private static final Log log = new Log(APIManager.class); ! private NCManager ncManager; public APIManager(NCManager ncManager) { this.ncManager = ncManager; } ! public void init() { /* empty */ } } --- 1,39 ---- package edu.harvard.syrah.pyxida.api; + import java.util.LinkedList; + import java.util.List; + import edu.harvard.syrah.prp.Log; import edu.harvard.syrah.pyxida.nc.NCManager; + import edu.harvard.syrah.sbon.async.CBResult; + import edu.harvard.syrah.sbon.async.LoopIt; + import edu.harvard.syrah.sbon.async.CallbacksIF.CB0; + import edu.harvard.syrah.sbon.async.CallbacksIF.CB2; public class APIManager { private static final Log log = new Log(APIManager.class); ! private NCManager ncManager; + private List<APIIF> externalAPIs = new LinkedList<APIIF>(); + public APIManager(NCManager ncManager) { this.ncManager = ncManager; + + /* + * Initialise the different APIs + * One day this could be done dynamically + */ + externalAPIs.add(new XMLRPC_API()); } ! public void init(CB0 cbDone) { ! new LoopIt<APIIF>(externalAPIs, new CB2<APIIF, CB0>() { ! protected void cb(CBResult result, APIIF externalAPI, CB0 cbNextIter) { ! log.debug("Initialising externalAPI=" + externalAPI.getClass()); ! externalAPI.init(cbNextIter); ! } ! }).execute(cbDone); ! } } --- NEW FILE: XMLRPC_API.java --- package edu.harvard.syrah.pyxida.api; import edu.harvard.syrah.pyxida.nc.lib.Coordinate; import edu.harvard.syrah.sbon.async.Config; import edu.harvard.syrah.sbon.async.CallbacksIF.CB0; import edu.harvard.syrah.sbon.async.CallbacksIF.CB1; import edu.harvard.syrah.sbon.comm.AddressFactory; import edu.harvard.syrah.sbon.comm.AddressIF; import edu.harvard.syrah.sbon.comm.xmlrpc.XMLRPCComm; import edu.harvard.syrah.sbon.comm.xmlrpc.XMLRPCCommIF; public class XMLRPC_API implements APIIF { private static final String XMLRPC_OBJECT_NAME = "pyxida"; // App comm interface private XMLRPCCommIF apiComm; public void init(CB0 cbDone) { apiComm = new XMLRPCComm(); int port = Integer.parseInt(Config.getProperty("pyxida.api.port", "55501")); AddressIF apiAddress = AddressFactory.createServer(port); apiComm.registerHandler(XMLRPC_OBJECT_NAME, this); apiComm.initServer(apiAddress, cbDone); } public void createProxyCoord(String remoteNode, long lease, CB1<Object> cbResult) { // TODO Auto-generated method stub } public void destroyProxyCoord(String remoteNode, CB1<Object> cbResult) { // TODO Auto-generated method stub } public void estimateRTT(String nodeA, AddressIF nodeB, CB1<Double> cbLatency) { // TODO Auto-generated method stub } public Coordinate getCoord(String node) { // TODO Auto-generated method stub return null; } public void renewProxyCoord(String remoteNode, long lease, CB1<Object> cbResult) { // TODO Auto-generated method stub } } |
|
From: Peter P. <pr...@us...> - 2006-11-28 18:49:39
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26619/src/edu/harvard/syrah/pyxida/nc Modified Files: NCManager.java Log Message: Implemented APIManager with XMLRPC API Implemented measurement call in PingManager (I didn't test either, so sent me bug reports.) Index: NCManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/NCManager.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** NCManager.java 27 Nov 2006 20:31:40 -0000 1.10 --- NCManager.java 28 Nov 2006 18:49:34 -0000 1.11 *************** *** 329,334 **** // and ping him ! pingManager.addPingRequest(comm.getLocalAddress(), neighbor, new CB1<Float>() { ! protected void cb(CBResult pingResult, Float latency) { switch (pingResult.state) { case OK: { --- 329,334 ---- // and ping him ! pingManager.addPingRequest(neighbor, new CB1<Double>() { ! protected void cb(CBResult pingResult, Double latency) { switch (pingResult.state) { case OK: { |
|
From: Peter P. <pr...@us...> - 2006-11-27 20:31:49
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16925/src/edu/harvard/syrah/pyxida/ping Modified Files: PingManager.java Log Message: Tried to fix the null cb bug with request/response msgs. Index: PingManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/ping/PingManager.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PingManager.java 27 Nov 2006 16:24:59 -0000 1.7 --- PingManager.java 27 Nov 2006 20:31:40 -0000 1.8 *************** *** 28,34 **** // TODO This needs to be made more generic ! PingerIF pinger = new ICMPPinger(); ! pingerSet.add(pinger); ! pinger.init(defaultPingAddr, cbDone); } --- 28,36 ---- // TODO This needs to be made more generic ! //PingerIF pinger = new ICMPPinger(); ! //pingerSet.add(pinger); ! //pinger.init(defaultPingAddr, cbDone); ! ! cbDone.callOK(); } |
|
From: Peter P. <pr...@us...> - 2006-11-27 20:31:48
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16925/src/edu/harvard/syrah/pyxida/nc Modified Files: NCManager.java Log Message: Tried to fix the null cb bug with request/response msgs. Index: NCManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/NCManager.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NCManager.java 27 Nov 2006 19:03:57 -0000 1.9 --- NCManager.java 27 Nov 2006 20:31:40 -0000 1.10 *************** *** 16,23 **** import edu.harvard.syrah.sbon.comm.AddressFactory; import edu.harvard.syrah.sbon.comm.AddressIF; ! import edu.harvard.syrah.sbon.comm.obj.ObjCommCB; ! import edu.harvard.syrah.sbon.comm.obj.ObjCommIF; ! import edu.harvard.syrah.sbon.comm.obj.ObjMessage; ! import edu.harvard.syrah.sbon.comm.obj.ObjMessageIF; //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 *************** *** 30,168 **** */ 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" ! // of the coordinates array. ! // Thus, setting this to 5 is 4d+height if height is in use. ! // This allows the size on the wire to remain constant ! // which is important for Azureus integration. ! // 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]"); ! /** ! * Time between gossip messages to coordinate neighbors. ! * Default is 10 seconds. ! */ ! public static final long UPDATE_DELAY = 10 * 1000; ! /** ! * Default lifetime that proxy coordinates are managed for. ! * Set to one hour. ! */ ! public static final long DEFAULT_PROXY_LEASE = 3600 * 1000; ! private PingManager pingManager = null; ! private Set<ProxyClient> proxyClients = new HashSet<ProxyClient>(); ! final ObjCommIF comm; ! final CoordClient localNC; ! Set<AddressIF> upNeighbors; ! Set<AddressIF> downNeighbors; ! Set<AddressIF> pendingNeighbors; ! /** ! * Create a coordinate manager. ! * Does not block. ! */ ! public NCManager(ObjCommIF _comm, PingManager pingManager) { ! comm = _comm; ! this.pingManager = pingManager; ! // Initialise the local coord first ! localNC = new CoordClient(); ! } ! /** ! * Asynchronous initialization of coordinate manager. ! * Resolves bootstrap neighbors and starts gossip for local coordinate. ! * Starts listening for gossip messages. ! */ ! public void init(final CB0 cbDone) { ! comm.registerMessageCB(GossipRequestMsg.class, new GossipHandler()); ! upNeighbors = new HashSet<AddressIF>(); ! downNeighbors = new HashSet<AddressIF>(); ! pendingNeighbors = new HashSet<AddressIF>(); ! log.debug("Resolving bootstrap list"); ! AddressFactory.createResolved(Arrays.asList(bootstrapList), Pyxida.COMM_PORT, new CB1<Map<String, AddressIF>>() { ! protected void cb(CBResult result, Map<String, AddressIF> addrMap) { ! switch (result.state) { ! case OK: { ! for (String remoteNode : addrMap.keySet()) { ! log.debug("remoteNode='" + remoteNode + "'"); ! AddressIF remoteAddr = addrMap.get(remoteNode); ! addPendingNeighbor(remoteAddr); ! } ! // Starts local coordinate timer ! localNC.init(); ! // MEDTODO Start periodic cleaner ! //neighborClean(); ! cbDone.callOK(); ! break; ! } ! case TIMEOUT: ! case ERROR: { ! log.error("Could not resolve bootstrap list: " + result.what); ! break; ! } ! } ! } ! }); ! } ! /** ! * Not implemented yet. ! */ ! public void createProxyCoord(AddressIF remoteNode, long lease) { ! // LOWTODO ! } ! /** ! * Not implemented yet. ! */ ! public void destroyProxyCoord(AddressIF remoteNode) { ! // LOWTODO ! } ! /** ! * @return local coordinate ! */ ! public Coordinate getLocalCoord() { ! return localNC.nc.getSystemCoords(); ! } ! /** ! * @return local error ! */ ! public double getLocalError() { ! return localNC.nc.getSystemError(); ! } ! /** ! * Not implemented yet. ! */ ! public Coordinate getProxyCoord(AddressIF remoteNode) { ! // LOWTODO ! return null; ! } ! /** ! * ! */ ! public double estimateRTT(AddressIF nodeA, AddressIF nodeB) { ! // TODO ! return 0; ! } ! /* // LOWTODO PRP public void startUp(DataInputStream is) throws IOException { --- 27,165 ---- */ 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" ! // of the coordinates array. ! // Thus, setting this to 5 is 4d+height if height is in use. ! // This allows the size on the wire to remain constant ! // which is important for Azureus integration. ! // 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]"); ! /** ! * Time between gossip messages to coordinate neighbors. ! * Default is 10 seconds. ! */ ! public static final long UPDATE_DELAY = 10 * 1000; ! /** ! * Default lifetime that proxy coordinates are managed for. ! * Set to one hour. ! */ ! public static final long DEFAULT_PROXY_LEASE = 3600 * 1000; ! private PingManager pingManager = null; ! private Set<ProxyClient> proxyClients = new HashSet<ProxyClient>(); ! final ObjCommIF comm; ! final CoordClient localNC; ! Set<AddressIF> upNeighbors; ! Set<AddressIF> downNeighbors; ! Set<AddressIF> pendingNeighbors; ! /** ! * Create a coordinate manager. ! * Does not block. ! */ ! public NCManager(ObjCommIF _comm, PingManager pingManager) { ! comm = _comm; ! this.pingManager = pingManager; ! // Initialise the local coord first ! localNC = new CoordClient(); ! } ! /** ! * Asynchronous initialization of coordinate manager. ! * Resolves bootstrap neighbors and starts gossip for local coordinate. ! * Starts listening for gossip messages. ! */ ! public void init(final CB0 cbDone) { ! comm.registerMessageCB(GossipRequestMsg.class, new GossipHandler()); ! upNeighbors = new HashSet<AddressIF>(); ! downNeighbors = new HashSet<AddressIF>(); ! pendingNeighbors = new HashSet<AddressIF>(); ! log.debug("Resolving bootstrap list"); ! AddressFactory.createResolved(Arrays.asList(bootstrapList), Pyxida.COMM_PORT, new CB1<Map<String, AddressIF>>() { ! protected void cb(CBResult result, Map<String, AddressIF> addrMap) { ! switch (result.state) { ! case OK: { ! for (String remoteNode : addrMap.keySet()) { ! log.debug("remoteNode='" + remoteNode + "'"); ! AddressIF remoteAddr = addrMap.get(remoteNode); ! addPendingNeighbor(remoteAddr); ! } ! // Starts local coordinate timer ! localNC.init(); ! // MEDTODO Start periodic cleaner ! //neighborClean(); ! cbDone.callOK(); ! break; ! } ! case TIMEOUT: ! case ERROR: { ! log.error("Could not resolve bootstrap list: " + result.what); ! break; ! } ! } ! } ! }); ! } ! /** ! * Not implemented yet. ! */ ! public void createProxyCoord(AddressIF remoteNode, long lease) { ! // LOWTODO ! } ! /** ! * Not implemented yet. ! */ ! public void destroyProxyCoord(AddressIF remoteNode) { ! // LOWTODO ! } ! /** ! * @return local coordinate ! */ ! public Coordinate getLocalCoord() { ! return localNC.nc.getSystemCoords(); ! } ! /** ! * @return local error ! */ ! public double getLocalError() { ! return localNC.nc.getSystemError(); ! } ! /** ! * Not implemented yet. ! */ ! public Coordinate getProxyCoord(AddressIF remoteNode) { ! // LOWTODO ! return null; ! } ! /** ! * ! */ ! public double estimateRTT(AddressIF nodeA, AddressIF nodeB) { ! // TODO ! return 0; ! } ! /* // LOWTODO PRP public void startUp(DataInputStream is) throws IOException { *************** *** 171,438 **** public void shutDown(DataOutputStream os) throws IOException { } ! */ ! abstract class ResponseObjCommCB<T extends ObjMessageIF> extends ObjCommCB<T> { ! void sendResponseMessage(final String handler, final AddressIF remoteAddr, ! final ObjMessage response, long requestMsgId, final String errorMessage, ! final CB1<Boolean> cbHandled) { ! CBResult result = null; ! if (errorMessage != null) { ! log.debug(handler + " :" + errorMessage); ! result = CBResult.ERROR(errorMessage); ! } else { ! result = CBResult.OK(); } ! ! comm.sendResponseMessage(response, remoteAddr, requestMsgId, new CB0() { ! protected void cb(CBResult sendResult) { ! switch (sendResult.state) { ! case TIMEOUT: ! case ERROR: { ! log.warn(handler + ": " + sendResult.what); ! return; ! } ! } ! } ! }); ! //cbHandled.call(CBResult.OK(), true); ! cbHandled.call(result, true); } } ! class GossipHandler extends ResponseObjCommCB<GossipRequestMsg> { ! public void cb(CBResult result, GossipRequestMsg msg, AddressIF remoteAddr, Long ts, ! final CB1<Boolean> cbHandled) { ! log.debug("in GossipHandler cb: " + msg); ! // we just heard from him so we know he is up ! addUpNeighbor(remoteAddr); ! long curr_time = System.currentTimeMillis(); ! sendResponseMessage("Gossip", remoteAddr, ! new GossipResponseMsg(localNC.nc.getSystemCoords(), localNC.nc.getSystemError(), ! localNC.nc.getAge(curr_time), getUpNeighbors(msg.coordinate)), msg.getMsgId(), null, ! cbHandled); - } } ! AddressIF getUpNeighbor() { ! if (upNeighbors.size() == 0 && pendingNeighbors.size() == 0) { ! log.warn("we are lonely and have no one to gossip with"); ! return null; ! } ! final double pctUsePendingNeighbor = 0.1; ! AddressIF upNeighbor; ! if (upNeighbors.size() == 0 || ! Pyxida.random.nextDouble() < pctUsePendingNeighbor) { ! upNeighbor = PUtil.getRandomObject(pendingNeighbors); ! } else { ! upNeighbor = PUtil.getRandomObject(upNeighbors); ! } ! ! return upNeighbor; } ! Set<AddressIF> getUpNeighbors(Coordinate remoteCoord) { ! Set<AddressIF> nodes = new HashSet<AddressIF>(); ! // LOWTODO add option of loop here ! AddressIF node = getUpNeighbor(); ! if (node != null) { ! nodes.add(node); ! } ! return nodes; ! } ! void addPendingNeighbors(Set<AddressIF> nodes) { ! for (AddressIF node : nodes) { ! addPendingNeighbor(node); ! } } ! // If this guy is in an unknown state ! // add him to pending. ! void addPendingNeighbor(AddressIF node) { ! if (node.equals(comm.getLocalAddress())) return; ! if (!pendingNeighbors.contains(node) && ! !upNeighbors.contains(node) && ! !downNeighbors.contains(node)) { ! pendingNeighbors.add(node); ! } } ! void addUpNeighbor(AddressIF node) { ! if (node.equals(comm.getLocalAddress())) return; ! downNeighbors.remove(node); ! pendingNeighbors.remove(node); ! upNeighbors.add(node); } ! void addDownNeighbor(AddressIF node) { ! pendingNeighbors.remove(node); ! upNeighbors.remove(node); ! downNeighbors.add(node); ! } ! class CoordClient { ! final NCClient<AddressIF> nc; ! final CB0 updateCB; ! public CoordClient() { ! nc = new NCClient<AddressIF>(NCManager.NC_NUM_DIMS); ! updateCB = new CB0() { ! protected void cb(CBResult result) { ! update(); ! } ! }; } ! void registerTimer () { ! // LOWTODO adaptive delay ! double rnd = Pyxida.random.nextGaussian(); ! long delay = UPDATE_DELAY + (long)(1000 * rnd); ! ! log.debug ("setting timer to "+delay); ! EventLoop.get().registerTimerCB(delay, updateCB); ! } ! public void init() { ! registerTimer(); ! } ! void update() { ! registerTimer(); ! final AddressIF neighbor = pickGossipNode(); ! // send him a gossip msg ! // LOWTODO could bias which nodes are sent based on his coord ! GossipRequestMsg msg = new GossipRequestMsg(localNC.nc.getSystemCoords(), ! getUpNeighbors(null)); ! comm.sendRequestMessage(msg, neighbor, new ObjCommCB<GossipResponseMsg>() { ! protected void cb(CBResult result, final GossipResponseMsg responseMsg, ! AddressIF remoteAddr, Long ts, CB1<Boolean> cbHandled) { ! // 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...? ! assert (cbHandled != null); ! switch (result.state) { ! case OK: { ! // keep track of new guys he's told us about ! addPendingNeighbors(responseMsg.nodes); ! // and ping him ! pingManager.addPingRequest(comm.getLocalAddress(), neighbor, new CB1<Float>() { ! protected void cb(CBResult pingResult, Float latency) { ! switch (pingResult.state) { ! case OK: { ! // both calls worked ! 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); ! break; ! } ! case TIMEOUT: ! case ERROR: { ! log.warn("Ping to " + neighbor + " failed"); ! addDownNeighbor(neighbor); ! break; ! } ! } ! } ! }); ! break; ! } ! case ERROR: ! case TIMEOUT: { ! log.warn("Did not receive gossip response from " + neighbor); ! addDownNeighbor(neighbor); ! break; ! } ! } ! assert (cbHandled != null); ! cbHandled.call(CBResult.OK(), true); - } - }); } ! AddressIF pickGossipNode() { ! // LOWTODO ask our ncClient if it has a preferred gossip node ! ! // if not, use somebody from our neighbor set ! return getUpNeighbor(); ! } } ! class ProxyClient extends CoordClient { ! final AddressIF addr; ! long lease; ! void update() { ! registerTimer(); ! final AddressIF neighbor = pickGossipNode(); ! // ask him to ping our address ! // and tell us about him ! // update our coordinate ! } ! public ProxyClient(AddressIF _addr, long _lease) { ! super(); ! renewLease(_lease); ! // MEDTODO Does this need to be cloned? ! // prp: Don't know but if you want to clone it, use the copy constructor ! addr = AddressFactory.create(_addr); ! } ! public void renewLease(long _lease) { ! if (_lease <= 0) { ! log.warn("Changing given lease " + _lease + " to default lease " + DEFAULT_PROXY_LEASE); ! _lease = DEFAULT_PROXY_LEASE; ! } ! lease = System.currentTimeMillis() + _lease; ! if (lease < 0) ! lease = Long.MAX_VALUE; ! } ! public boolean hasExpired() { ! if (System.currentTimeMillis() > lease) { ! return true; ! } ! return false; ! } } } --- 168,429 ---- public void shutDown(DataOutputStream os) throws IOException { } ! */ ! abstract class ResponseObjCommCB<T extends ObjMessageIF> extends ObjCommCB<T> { ! void sendResponseMessage(final String handler, final AddressIF remoteAddr, ! final ObjMessage response, long requestMsgId, final String errorMessage, ! final CB1<Boolean> cbHandled) { ! ! CBResult result = null; ! if (errorMessage != null) { ! log.debug(handler + " :" + errorMessage); ! result = CBResult.ERROR(errorMessage); ! } else { ! result = CBResult.OK(); ! } ! comm.sendResponseMessage(response, remoteAddr, requestMsgId, new CB0() { ! protected void cb(CBResult sendResult) { ! switch (sendResult.state) { ! case TIMEOUT: ! case ERROR: { ! log.warn(handler + ": " + sendResult.what); ! return; } ! } } + }); + cbHandled.call(result, true); } + } ! class GossipHandler extends ResponseObjCommCB<GossipRequestMsg> { ! public void cb(CBResult result, GossipRequestMsg msg, AddressIF remoteAddr, Long ts, ! final CB1<Boolean> cbHandled) { ! log.debug("in GossipHandler cb: " + msg); ! // we just heard from him so we know he is up ! addUpNeighbor(remoteAddr); ! long curr_time = System.currentTimeMillis(); ! sendResponseMessage("Gossip", remoteAddr, ! new GossipResponseMsg(localNC.nc.getSystemCoords(), localNC.nc.getSystemError(), ! localNC.nc.getAge(curr_time), getUpNeighbors(msg.coordinate)), msg.getMsgId(), null, ! cbHandled); } + } ! AddressIF getUpNeighbor() { ! if (upNeighbors.size() == 0 && pendingNeighbors.size() == 0) { ! log.warn("we are lonely and have no one to gossip with"); ! return null; ! } ! final double pctUsePendingNeighbor = 0.1; ! AddressIF upNeighbor; ! if (upNeighbors.size() == 0 || ! Pyxida.random.nextDouble() < pctUsePendingNeighbor) { ! upNeighbor = PUtil.getRandomObject(pendingNeighbors); ! } else { ! upNeighbor = PUtil.getRandomObject(upNeighbors); } ! return upNeighbor; ! } ! Set<AddressIF> getUpNeighbors(Coordinate remoteCoord) { ! Set<AddressIF> nodes = new HashSet<AddressIF>(); ! // LOWTODO add option of loop here ! AddressIF node = getUpNeighbor(); ! if (node != null) { ! nodes.add(node); } + return nodes; + } ! void addPendingNeighbors(Set<AddressIF> nodes) { ! for (AddressIF node : nodes) { ! addPendingNeighbor(node); } + } ! // If this guy is in an unknown state ! // add him to pending. ! void addPendingNeighbor(AddressIF node) { ! if (node.equals(comm.getLocalAddress())) return; ! if (!pendingNeighbors.contains(node) && ! !upNeighbors.contains(node) && ! !downNeighbors.contains(node)) { ! pendingNeighbors.add(node); } + } ! void addUpNeighbor(AddressIF node) { ! if (node.equals(comm.getLocalAddress())) return; ! downNeighbors.remove(node); ! pendingNeighbors.remove(node); ! upNeighbors.add(node); ! } ! void addDownNeighbor(AddressIF node) { ! pendingNeighbors.remove(node); ! upNeighbors.remove(node); ! downNeighbors.add(node); ! } ! class CoordClient { ! final NCClient<AddressIF> nc; ! final CB0 updateCB; ! public CoordClient() { ! nc = new NCClient<AddressIF>(NCManager.NC_NUM_DIMS); + updateCB = new CB0() { + protected void cb(CBResult result) { + update(); } + }; ! } ! void registerTimer () { ! // LOWTODO adaptive delay ! double rnd = Pyxida.random.nextGaussian(); ! long delay = UPDATE_DELAY + (long)(1000 * rnd); ! log.debug ("setting timer to "+delay); ! EventLoop.get().registerTimerCB(delay, updateCB); ! } ! public void init() { ! registerTimer(); ! } ! void update() { ! registerTimer(); ! final AddressIF neighbor = pickGossipNode(); ! // send him a gossip msg ! // LOWTODO could bias which nodes are sent based on his coord ! GossipRequestMsg msg = new GossipRequestMsg(localNC.nc.getSystemCoords(), ! getUpNeighbors(null)); ! comm.sendRequestMessage(msg, neighbor, new ObjCommRRCB<GossipResponseMsg>() { ! protected void cb(CBResult result, final GossipResponseMsg responseMsg, ! 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...? ! switch (result.state) { ! case OK: { ! // keep track of new guys he's told us about ! addPendingNeighbors(responseMsg.nodes); ! // and ping him ! pingManager.addPingRequest(comm.getLocalAddress(), neighbor, new CB1<Float>() { ! protected void cb(CBResult pingResult, Float latency) { ! switch (pingResult.state) { ! case OK: { ! // both calls worked ! 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); ! break; ! } ! case TIMEOUT: ! case ERROR: { ! log.warn("Ping to " + neighbor + " failed"); ! addDownNeighbor(neighbor); ! break; ! } ! } ! } ! }); ! break; ! } ! case ERROR: ! case TIMEOUT: { ! log.warn("Did not receive gossip response from " + neighbor); ! addDownNeighbor(neighbor); ! break; ! } ! } } + }); + } ! AddressIF pickGossipNode() { ! // LOWTODO ask our ncClient if it has a preferred gossip node ! // if not, use somebody from our neighbor set ! return getUpNeighbor(); } ! } ! class ProxyClient extends CoordClient { ! final AddressIF addr; ! long lease; ! void update() { ! registerTimer(); ! final AddressIF neighbor = pickGossipNode(); ! // ask him to ping our address ! // and tell us about him ! // update our coordinate ! } ! public ProxyClient(AddressIF _addr, long _lease) { ! super(); ! renewLease(_lease); ! // MEDTODO Does this need to be cloned? ! // prp: Don't know but if you want to clone it, use the copy constructor ! addr = AddressFactory.create(_addr); ! } ! public void renewLease(long _lease) { ! if (_lease <= 0) { ! log.warn("Changing given lease " + _lease + " to default lease " + DEFAULT_PROXY_LEASE); ! _lease = DEFAULT_PROXY_LEASE; ! } ! lease = System.currentTimeMillis() + _lease; ! if (lease < 0) ! lease = Long.MAX_VALUE; } + public boolean hasExpired() { + if (System.currentTimeMillis() > lease) { + return true; + } + return false; + } + } + } |
|
From: Peter P. <pr...@us...> - 2006-11-27 20:31:45
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16925/src/edu/harvard/syrah/pyxida/nc/lib Modified Files: Coordinate.java Log Message: Tried to fix the null cb bug with request/response msgs. Index: Coordinate.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/Coordinate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Coordinate.java 27 Nov 2006 19:03:57 -0000 1.3 --- Coordinate.java 27 Nov 2006 20:31:40 -0000 1.4 *************** *** 6,9 **** --- 6,11 ---- import java.io.Serializable; + import edu.harvard.syrah.prp.Log; + /* * Pyxida - a network coordinate library *************** *** 29,32 **** --- 31,37 ---- */ public class Coordinate implements Serializable { + private static final Log log = new Log(Coordinate.class); + + private static final long serialVersionUID = 1L; final static protected int CLASS_HASH = Coordinate.class.hashCode(); |
|
From: Peter P. <pr...@us...> - 2006-11-27 20:31:43
|
Update of /cvsroot/pyxida/Pyxida/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16925/config Modified Files: log.config Log Message: Tried to fix the null cb bug with request/response msgs. Index: log.config =================================================================== RCS file: /cvsroot/pyxida/Pyxida/config/log.config,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** log.config 27 Nov 2006 19:16:55 -0000 1.1 --- log.config 27 Nov 2006 20:31:40 -0000 1.2 *************** *** 37,41 **** ############################################################################################### ! edu.harvard.syrah.level = SEVERE ############################################################################################### --- 37,41 ---- ############################################################################################### ! edu.harvard.syrah.level = CONFIG ############################################################################################### *************** *** 43,47 **** ############################################################################################### ! edu.harvard.syrah.sbon.async.level = WARN ############################################################################################### --- 43,47 ---- ############################################################################################### ! edu.harvard.syrah.sbon.async.level = CONFIG ############################################################################################### |
|
From: Peter P. <pr...@us...> - 2006-11-27 20:31:43
|
Update of /cvsroot/pyxida/Pyxida/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16925/lib Modified Files: sbon-async.jar util-prp.jar Log Message: Tried to fix the null cb bug with request/response msgs. Index: sbon-async.jar =================================================================== RCS file: /cvsroot/pyxida/Pyxida/lib/sbon-async.jar,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 Binary files /tmp/cvsVLKhVo and /tmp/cvsLaWuUC differ Index: util-prp.jar =================================================================== RCS file: /cvsroot/pyxida/Pyxida/lib/util-prp.jar,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 Binary files /tmp/cvsplku5s and /tmp/cvs8ASeaH differ |
|
From: Jonathan L. <le...@us...> - 2006-11-27 19:16:58
|
Update of /cvsroot/pyxida/Pyxida/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21258 Added Files: log.config Log Message: cbHandled weirdness --- NEW FILE: log.config --- ############################################################ # Default Logging Configuration File # # You can use a different file by specifying a filename # with the java.util.logging.config.file system property. # For example java -Djava.util.logging.config.file=myfile ############################################################ # "handlers" specifies a comma separated list of log Handler # classes. These handlers will be installed during VM startup. handlers= java.util.logging.ConsoleHandler # Default global logging level. .level= CONFIG ############################################################ # Handler specific properties. ############################################################ # Limit the messages that are printed on the console: java.util.logging.ConsoleHandler.level = FINEST # use this format instead of the default java.util.logging.SimpleFormatter java.util.logging.ConsoleHandler.formatter = edu.harvard.syrah.prp.LogFormatter ############################################################ # Provides extra control for each logger. ############################################################ # For example, set the com.xyz.foo logger to only log SEVERE # messages: #com.xyz.foo.level = SEVERE #sun.rmi.level = CONFIG ############################################################################################### main ############################################################################################### edu.harvard.syrah.level = SEVERE ############################################################################################### async ############################################################################################### edu.harvard.syrah.sbon.async.level = WARN ############################################################################################### pyxida ############################################################################################### edu.harvard.syrah.pyxida.nc.level = DEBUG |
|
From: Jonathan L. <le...@us...> - 2006-11-27 19:04:30
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16278/src/edu/harvard/syrah/pyxida/nc Modified Files: NCManager.java Log Message: cbHandled weirdness Index: NCManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/NCManager.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NCManager.java 27 Nov 2006 16:24:59 -0000 1.8 --- NCManager.java 27 Nov 2006 19:03:57 -0000 1.9 *************** *** 4,7 **** --- 4,8 ---- import edu.harvard.syrah.prp.Log; + import edu.harvard.syrah.prp.PUtil; import edu.harvard.syrah.pyxida.Pyxida; import edu.harvard.syrah.pyxida.nc.lib.Coordinate; *************** *** 29,411 **** */ 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" ! // of the coordinates array. ! // Thus, setting this to 5 is 4d+height if height is in use. ! // This allows the size on the wire to remain constant ! // which is important for Azureus integration. ! // 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]"); ! /** ! * Time between gossip messages to coordinate neighbors. ! * Default is 10 seconds. ! */ ! public static final long UPDATE_DELAY = 10 * 1000; ! /** ! * Default lifetime that proxy coordinates are managed for. ! * Set to one hour. ! */ ! public static final long DEFAULT_PROXY_LEASE = 3600 * 1000; ! private PingManager pingManager = null; ! private Set<ProxyClient> proxyClients = new HashSet<ProxyClient>(); ! final ObjCommIF comm; ! final CoordClient localNC; ! Map<AddressIF,Long> neighbor2age; ! ArrayList<AddressIF> neighbors; ! /** ! * Create a coordinate manager. ! * Does not block. ! */ ! public NCManager(ObjCommIF _comm, PingManager pingManager) { ! comm = _comm; ! this.pingManager = pingManager; ! // Initialise the local coord first ! localNC = new CoordClient(); ! } ! /** ! * Asynchronous initialization of coordinate manager. ! * Resolves bootstrap neighbors and starts gossip for local coordinate. ! * Starts listening for gossip messages. ! */ ! public void init(final CB0 cbDone) { ! comm.registerMessageCB(GossipRequestMsg.class, new GossipHandler()); ! neighbor2age = new HashMap<AddressIF,Long>(); ! neighbors = new ArrayList<AddressIF>(); ! log.debug("Resolving bootstrap list"); ! AddressFactory.createResolved(Arrays.asList(bootstrapList), Pyxida.COMM_PORT, new CB1<Map<String, AddressIF>>() { ! protected void cb(CBResult result, Map<String, AddressIF> addrMap) { ! switch (result.state) { ! case OK: { ! for (String remoteNode : addrMap.keySet()) { ! log.debug("remoteNode='" + remoteNode + "'"); ! AddressIF remoteAddr = addrMap.get(remoteNode); ! addGossipNode(remoteAddr); ! } ! // Starts local coordinate timer ! localNC.init(); ! // MEDTODO Start periodic cleaner ! //neighborClean(); ! cbDone.callOK(); ! break; ! } ! case TIMEOUT: ! case ERROR: { ! log.error("Could not resolve bootstrap list: " + result.what); ! break; ! } ! } ! } ! }); ! } ! /** ! * Not implemented yet. ! */ ! public void createProxyCoord(AddressIF remoteNode, long lease) { ! // LOWTODO ! } ! /** ! * Not implemented yet. ! */ ! public void destroyProxyCoord(AddressIF remoteNode) { ! // LOWTODO ! } ! /** ! * @return local coordinate ! */ ! public Coordinate getLocalCoord() { ! return localNC.nc.getSystemCoords(); ! } ! /** ! * @return local error ! */ ! public double getLocalError() { ! return localNC.nc.getSystemError(); ! } ! /** ! * Not implemented yet. ! */ ! public Coordinate getProxyCoord(AddressIF remoteNode) { ! // LOWTODO ! return null; ! } ! /** ! * ! */ ! public double estimateRTT(AddressIF nodeA, AddressIF nodeB) { ! // TODO ! return 0; ! } ! /* ! // LOWTODO PRP ! public void startUp(DataInputStream is) throws IOException { ! } ! public void shutDown(DataOutputStream os) throws IOException { ! } ! */ ! abstract class ResponseObjCommCB<T extends ObjMessageIF> extends ObjCommCB<T> { ! void sendResponseMessage(final String handler, final AddressIF remoteAddr, ! final ObjMessage response, long requestMsgId, final String errorMessage, ! final CB1<Boolean> cbHandled) { ! CBResult result = null; ! if (errorMessage != null) { ! log.debug(handler + " :" + errorMessage); ! result = CBResult.ERROR(errorMessage); ! } else { ! result = CBResult.OK(); ! } ! comm.sendResponseMessage(response, remoteAddr, requestMsgId, new CB0() { ! protected void cb(CBResult sendResult) { ! switch (sendResult.state) { ! case TIMEOUT: ! case ERROR: { ! log.warn(handler + ": " + sendResult.what); ! return; } ! } } - }); - cbHandled.call(CBResult.OK(), true); } - } ! class GossipHandler extends ResponseObjCommCB<GossipRequestMsg> { ! public void cb(CBResult result, GossipRequestMsg msg, AddressIF remoteAddr, Long ts, ! final CB1<Boolean> cbHandled) { ! log.debug("in GossipHandler cb: " + msg); ! long curr_time = System.currentTimeMillis(); - sendResponseMessage("Gossip", remoteAddr, - new GossipResponseMsg(localNC.nc.getSystemCoords(), localNC.nc.getSystemError(), - localNC.nc.getAge(curr_time), getGossipNodes(msg.coordinate)), msg.getMsgId(), null, - cbHandled); ! } ! } ! AddressIF getGossipNode() { ! if (neighbors.size() == 0) { ! log.warn("we are lonely and have no one to gossip with"); ! return null; } ! int index = Pyxida.random.nextInt(neighbors.size()); ! AddressIF node = neighbors.get(index); ! return node; ! } ! Set<AddressIF> getGossipNodes(Coordinate remoteCoord) { ! Set<AddressIF> nodes = new HashSet<AddressIF>(); ! // LOWTODO add option of loop here ! AddressIF node = getGossipNode(); ! if (node != null) { ! nodes.add(node); } - return nodes; - } ! void addGossipNodes(Set<AddressIF> nodes) { ! for (AddressIF node : nodes) { ! addGossipNode (node); } - } ! void addGossipNode(AddressIF node) { ! long curr_time = System.currentTimeMillis(); ! Long expiry = neighbor2age.get(node); ! if (expiry != null) { ! log.debug ("gossip already knew node "+node); ! long old_time = expiry.longValue(); ! expiry = new Long (curr_time); ! expiry = neighbor2age.get(node); ! long new_time = expiry.longValue(); ! log.debug ("old_time "+old_time+" new "+new_time); ! return; ! } ! neighbors.add(node); ! neighbor2age.put(node,curr_time); ! log.debug ("gossip added new neighbor "+node); ! } ! class CoordClient { ! final NCClient<AddressIF> nc; ! final CB0 updateCB; ! public CoordClient() { ! nc = new NCClient<AddressIF>(NCManager.NC_NUM_DIMS); ! updateCB = new CB0() { ! protected void cb(CBResult result) { ! update(); } - }; ! } ! void registerTimer () { ! // LOWTODO adaptive delay ! double rnd = Pyxida.random.nextGaussian(); ! long delay = UPDATE_DELAY + (long)(1000 * rnd); log.debug("Initialising the ping manager..."); ! log.debug ("setting timer to "+delay); ! EventLoop.get().registerTimerCB(delay, updateCB); ! } ! public void init() { ! registerTimer(); ! } ! void update() { ! registerTimer(); ! final AddressIF neighbor = pickGossipNode(); ! // send him a gossip msg ! // LOWTODO could bias which nodes are sent based on his coord ! GossipRequestMsg msg = new GossipRequestMsg(localNC.nc.getSystemCoords(), ! getGossipNodes(null)); ! comm.sendRequestMessage(msg, neighbor, new ObjCommCB<GossipResponseMsg>() { ! protected void cb(CBResult result, final GossipResponseMsg responseMsg, ! AddressIF remoteAddr, Long ts, CB1<Boolean> cbHandled) { ! // 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...? ! switch (result.state) { ! case OK: { ! // keep track of new guys he's told us about ! addGossipNodes(responseMsg.nodes); ! // and ping him ! pingManager.addPingRequest(comm.getLocalAddress(), neighbor, new CB1<Float>() { ! protected void cb(CBResult pingResult, Float latency) { ! switch (pingResult.state) { ! case OK: { ! // 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); ! break; ! } ! case TIMEOUT: ! case ERROR: { ! log.warn("Ping to " + neighbor + " failed"); ! break; ! } ! } ! } ! }); ! break; ! } ! case ERROR: ! case TIMEOUT: { ! log.warn("Did not receive gossip response from " + neighbor); ! break; ! } ! } } - }); - } ! AddressIF pickGossipNode() { ! // LOWTODO ask our ncClient if it has a preferred gossip node ! // if not, use somebody from our neighbor set ! return getGossipNode(); ! } ! } ! class ProxyClient extends CoordClient { ! final AddressIF addr; ! long lease; ! void update() { ! registerTimer(); ! final AddressIF neighbor = pickGossipNode(); ! // ask him to ping our address ! // and tell us about him ! // update our coordinate ! } ! public ProxyClient(AddressIF _addr, long _lease) { ! super(); ! renewLease(_lease); ! // MEDTODO Does this need to be cloned? ! // prp: Don't know but if you want to clone it, use the copy constructor ! addr = AddressFactory.create(_addr); ! } ! public void renewLease(long _lease) { ! if (_lease <= 0) { ! log.warn("Changing given lease " + _lease + " to default lease " + DEFAULT_PROXY_LEASE); ! _lease = DEFAULT_PROXY_LEASE; ! } ! lease = System.currentTimeMillis() + _lease; ! if (lease < 0) ! lease = Long.MAX_VALUE; ! } ! public boolean hasExpired() { ! if (System.currentTimeMillis() > lease) { ! return true; ! } ! return false; } - } } --- 30,438 ---- */ 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" ! // of the coordinates array. ! // Thus, setting this to 5 is 4d+height if height is in use. ! // This allows the size on the wire to remain constant ! // which is important for Azureus integration. ! // 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]"); ! /** ! * Time between gossip messages to coordinate neighbors. ! * Default is 10 seconds. ! */ ! public static final long UPDATE_DELAY = 10 * 1000; ! /** ! * Default lifetime that proxy coordinates are managed for. ! * Set to one hour. ! */ ! public static final long DEFAULT_PROXY_LEASE = 3600 * 1000; ! private PingManager pingManager = null; ! private Set<ProxyClient> proxyClients = new HashSet<ProxyClient>(); ! final ObjCommIF comm; ! final CoordClient localNC; ! Set<AddressIF> upNeighbors; ! Set<AddressIF> downNeighbors; ! Set<AddressIF> pendingNeighbors; ! /** ! * Create a coordinate manager. ! * Does not block. ! */ ! public NCManager(ObjCommIF _comm, PingManager pingManager) { ! comm = _comm; ! this.pingManager = pingManager; ! // Initialise the local coord first ! localNC = new CoordClient(); ! } ! /** ! * Asynchronous initialization of coordinate manager. ! * Resolves bootstrap neighbors and starts gossip for local coordinate. ! * Starts listening for gossip messages. ! */ ! public void init(final CB0 cbDone) { ! comm.registerMessageCB(GossipRequestMsg.class, new GossipHandler()); ! upNeighbors = new HashSet<AddressIF>(); ! downNeighbors = new HashSet<AddressIF>(); ! pendingNeighbors = new HashSet<AddressIF>(); ! log.debug("Resolving bootstrap list"); ! AddressFactory.createResolved(Arrays.asList(bootstrapList), Pyxida.COMM_PORT, new CB1<Map<String, AddressIF>>() { ! protected void cb(CBResult result, Map<String, AddressIF> addrMap) { ! switch (result.state) { ! case OK: { ! for (String remoteNode : addrMap.keySet()) { ! log.debug("remoteNode='" + remoteNode + "'"); ! AddressIF remoteAddr = addrMap.get(remoteNode); ! addPendingNeighbor(remoteAddr); ! } ! // Starts local coordinate timer ! localNC.init(); ! // MEDTODO Start periodic cleaner ! //neighborClean(); ! cbDone.callOK(); ! break; ! } ! case TIMEOUT: ! case ERROR: { ! log.error("Could not resolve bootstrap list: " + result.what); ! break; ! } ! } ! } ! }); ! } ! /** ! * Not implemented yet. ! */ ! public void createProxyCoord(AddressIF remoteNode, long lease) { ! // LOWTODO ! } ! /** ! * Not implemented yet. ! */ ! public void destroyProxyCoord(AddressIF remoteNode) { ! // LOWTODO ! } ! /** ! * @return local coordinate ! */ ! public Coordinate getLocalCoord() { ! return localNC.nc.getSystemCoords(); ! } ! /** ! * @return local error ! */ ! public double getLocalError() { ! return localNC.nc.getSystemError(); ! } ! /** ! * Not implemented yet. ! */ ! public Coordinate getProxyCoord(AddressIF remoteNode) { ! // LOWTODO ! return null; ! } ! /** ! * ! */ ! public double estimateRTT(AddressIF nodeA, AddressIF nodeB) { ! // TODO ! return 0; ! } ! /* ! // LOWTODO PRP ! public void startUp(DataInputStream is) throws IOException { ! } ! public void shutDown(DataOutputStream os) throws IOException { ! } ! */ ! abstract class ResponseObjCommCB<T extends ObjMessageIF> extends ObjCommCB<T> { ! void sendResponseMessage(final String handler, final AddressIF remoteAddr, ! final ObjMessage response, long requestMsgId, final String errorMessage, ! final CB1<Boolean> cbHandled) { ! CBResult result = null; ! if (errorMessage != null) { ! log.debug(handler + " :" + errorMessage); ! result = CBResult.ERROR(errorMessage); ! } else { ! result = CBResult.OK(); } ! ! comm.sendResponseMessage(response, remoteAddr, requestMsgId, new CB0() { ! protected void cb(CBResult sendResult) { ! switch (sendResult.state) { ! case TIMEOUT: ! case ERROR: { ! log.warn(handler + ": " + sendResult.what); ! return; ! } ! } ! } ! }); ! //cbHandled.call(CBResult.OK(), true); ! cbHandled.call(result, true); } } ! class GossipHandler extends ResponseObjCommCB<GossipRequestMsg> { ! public void cb(CBResult result, GossipRequestMsg msg, AddressIF remoteAddr, Long ts, ! final CB1<Boolean> cbHandled) { ! log.debug("in GossipHandler cb: " + msg); ! // we just heard from him so we know he is up ! addUpNeighbor(remoteAddr); ! long curr_time = System.currentTimeMillis(); ! sendResponseMessage("Gossip", remoteAddr, ! new GossipResponseMsg(localNC.nc.getSystemCoords(), localNC.nc.getSystemError(), ! localNC.nc.getAge(curr_time), getUpNeighbors(msg.coordinate)), msg.getMsgId(), null, ! cbHandled); ! } ! } ! AddressIF getUpNeighbor() { ! if (upNeighbors.size() == 0 && pendingNeighbors.size() == 0) { ! log.warn("we are lonely and have no one to gossip with"); ! return null; ! } + final double pctUsePendingNeighbor = 0.1; ! AddressIF upNeighbor; ! if (upNeighbors.size() == 0 || ! Pyxida.random.nextDouble() < pctUsePendingNeighbor) { ! upNeighbor = PUtil.getRandomObject(pendingNeighbors); ! } else { ! upNeighbor = PUtil.getRandomObject(upNeighbors); ! } ! ! return upNeighbor; } ! Set<AddressIF> getUpNeighbors(Coordinate remoteCoord) { ! Set<AddressIF> nodes = new HashSet<AddressIF>(); ! // LOWTODO add option of loop here ! AddressIF node = getUpNeighbor(); ! if (node != null) { ! nodes.add(node); ! } ! return nodes; ! } ! void addPendingNeighbors(Set<AddressIF> nodes) { ! for (AddressIF node : nodes) { ! addPendingNeighbor(node); ! } ! } ! // If this guy is in an unknown state ! // add him to pending. ! void addPendingNeighbor(AddressIF node) { ! if (node.equals(comm.getLocalAddress())) return; ! if (!pendingNeighbors.contains(node) && ! !upNeighbors.contains(node) && ! !downNeighbors.contains(node)) { ! pendingNeighbors.add(node); ! } } ! void addUpNeighbor(AddressIF node) { ! if (node.equals(comm.getLocalAddress())) return; ! downNeighbors.remove(node); ! pendingNeighbors.remove(node); ! upNeighbors.add(node); } ! void addDownNeighbor(AddressIF node) { ! pendingNeighbors.remove(node); ! upNeighbors.remove(node); ! downNeighbors.add(node); ! } ! class CoordClient { ! final NCClient<AddressIF> nc; ! final CB0 updateCB; ! public CoordClient() { ! nc = new NCClient<AddressIF>(NCManager.NC_NUM_DIMS); ! updateCB = new CB0() { ! protected void cb(CBResult result) { ! update(); ! } ! }; ! } ! void registerTimer () { ! // LOWTODO adaptive delay ! double rnd = Pyxida.random.nextGaussian(); ! long delay = UPDATE_DELAY + (long)(1000 * rnd); ! ! log.debug ("setting timer to "+delay); ! EventLoop.get().registerTimerCB(delay, updateCB); } ! public void init() { ! registerTimer(); ! } ! void update() { ! registerTimer(); ! final AddressIF neighbor = pickGossipNode(); ! // send him a gossip msg ! // LOWTODO could bias which nodes are sent based on his coord ! GossipRequestMsg msg = new GossipRequestMsg(localNC.nc.getSystemCoords(), ! getUpNeighbors(null)); ! comm.sendRequestMessage(msg, neighbor, new ObjCommCB<GossipResponseMsg>() { ! protected void cb(CBResult result, final GossipResponseMsg responseMsg, ! AddressIF remoteAddr, Long ts, CB1<Boolean> cbHandled) { ! // 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...? ! assert (cbHandled != null); ! switch (result.state) { ! case OK: { ! // keep track of new guys he's told us about ! addPendingNeighbors(responseMsg.nodes); ! // and ping him ! pingManager.addPingRequest(comm.getLocalAddress(), neighbor, new CB1<Float>() { ! protected void cb(CBResult pingResult, Float latency) { ! switch (pingResult.state) { ! case OK: { ! // both calls worked ! 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); ! break; ! } ! case TIMEOUT: ! case ERROR: { ! log.warn("Ping to " + neighbor + " failed"); ! addDownNeighbor(neighbor); ! break; ! } ! } ! } ! }); ! break; ! } ! case ERROR: ! case TIMEOUT: { ! log.warn("Did not receive gossip response from " + neighbor); ! addDownNeighbor(neighbor); ! break; ! } ! } ! assert (cbHandled != null); ! cbHandled.call(CBResult.OK(), true); ! } ! }); } ! AddressIF pickGossipNode() { ! // LOWTODO ask our ncClient if it has a preferred gossip node ! // if not, use somebody from our neighbor set ! return getUpNeighbor(); ! } ! } ! class ProxyClient extends CoordClient { ! final AddressIF addr; ! long lease; ! void update() { ! registerTimer(); ! final AddressIF neighbor = pickGossipNode(); ! // ask him to ping our address ! // and tell us about him ! // update our coordinate ! } ! public ProxyClient(AddressIF _addr, long _lease) { ! super(); ! renewLease(_lease); ! // MEDTODO Does this need to be cloned? ! // prp: Don't know but if you want to clone it, use the copy constructor ! addr = AddressFactory.create(_addr); ! } ! public void renewLease(long _lease) { ! if (_lease <= 0) { ! log.warn("Changing given lease " + _lease + " to default lease " + DEFAULT_PROXY_LEASE); ! _lease = DEFAULT_PROXY_LEASE; ! } ! lease = System.currentTimeMillis() + _lease; ! if (lease < 0) ! lease = Long.MAX_VALUE; ! } ! public boolean hasExpired() { ! if (System.currentTimeMillis() > lease) { ! return true; ! } ! return false; ! } } } |
|
From: Jonathan L. <le...@us...> - 2006-11-27 19:04:02
|
Update of /cvsroot/pyxida/Pyxida In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16278 Modified Files: runPyxida.sh Log Message: cbHandled weirdness Index: runPyxida.sh =================================================================== RCS file: /cvsroot/pyxida/Pyxida/runPyxida.sh,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** runPyxida.sh 27 Nov 2006 16:26:20 -0000 1.1 --- runPyxida.sh 27 Nov 2006 19:03:56 -0000 1.2 *************** *** 11,15 **** PYXIDA_CONFIG="-Dpyxida.config=config/pyxida.cfg\ ! -Djava.util.logging.config.file=config/log.config" CMD="$ANT $PYXIDA_CONFIG run-pyxida-jar" --- 11,16 ---- PYXIDA_CONFIG="-Dpyxida.config=config/pyxida.cfg\ ! -Djava.util.logging.config.file=config/log.config\ ! -Djava.library.path=lib" CMD="$ANT $PYXIDA_CONFIG run-pyxida-jar" |
|
From: Jonathan L. <le...@us...> - 2006-11-27 19:03:59
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16278/src/edu/harvard/syrah/pyxida/nc/lib Modified Files: Coordinate.java Log Message: cbHandled weirdness Index: Coordinate.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/lib/Coordinate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Coordinate.java 25 Nov 2006 21:39:59 -0000 1.2 --- Coordinate.java 27 Nov 2006 19:03:57 -0000 1.3 *************** *** 1,7 **** ! package edu.harvard.syrah.pyxida.nc.lib; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; /* --- 1,8 ---- ! package edu.harvard.syrah.pyxida.nc.lib; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import java.io.Serializable; /* *************** *** 27,31 **** * @author Michael Parker, Jonathan Ledlie */ ! public class Coordinate { final static protected int CLASS_HASH = Coordinate.class.hashCode(); --- 28,32 ---- * @author Michael Parker, Jonathan Ledlie */ ! public class Coordinate implements Serializable { final static protected int CLASS_HASH = Coordinate.class.hashCode(); |
|
From: Peter P. <pr...@us...> - 2006-11-27 18:14:30
|
Update of /cvsroot/pyxida/Pyxida/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30366/lib Modified Files: sbon-async.jar Log Message: Added more objcomm timeout instrumentation code Index: sbon-async.jar =================================================================== RCS file: /cvsroot/pyxida/Pyxida/lib/sbon-async.jar,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 Binary files /tmp/cvsrBamx8 and /tmp/cvsFQJEaI differ |
|
From: Jonathan L. <le...@us...> - 2006-11-27 16:26:25
|
Update of /cvsroot/pyxida/Pyxida In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23038 Added Files: build.xml runPyxida.sh Log Message: ant file --- NEW FILE: build.xml --- <!-- Main build file for Pyxida --> <project name="Pyxida" default="compile" basedir="."> <property name="src" location="src" /> <property name="build" location="classes" /> <property name="dist" location="dist" /> <property name="bin" location="bin" /> <property name="lib" location="lib" /> <property name="config" location="config" /> <property name="log" location="log" /> <property name="log-nodes" location="log/nodes" /> <property name="version" value="0.1" /> <property name="Pyxida-jar" value="pyxida.jar" /> <property name="Pyxida-tar" value="${dist}/pyxida-${version}.tar.gz" /> <property name="Pyxida-src-tar" value="${dist}/pyxida-src-${version}.tar.gz" /> <property name="pyxida.config" value="config/pyxida.cfg" /> <property name="java.util.logging.config.file" value="config/log.config" /> <path id="classpath"> <pathelement location="${lib}/util-prp.jar" /> <pathelement location="${lib}/jpcap.jar" /> <pathelement location="${lib}/sbon-async.jar" /> <!-- <pathelement location="${lib}/jb2refscan-2.58.jar"/> --> <pathelement path="${java.class.path}/" /> </path> <!-- Build targets --> <target name="init"> <!-- Create the time stamp --> <tstamp /> <!-- Create the build directory structure used by compile --> <mkdir dir="${build}" /> <mkdir dir="${log-nodes}" /> </target> <target name="compile" depends="init" description="Compile the source."> <!-- Compile the java code from ${src} into ${build} --> <javac debug="on" srcdir="${src}" destdir="${build}" classpathref="classpath"/> </target> <target name="jar" depends="compile" description="Create the distribution jar file."> <mkdir dir="${dist}" /> <jar destfile="${dist}/${Pyxida-jar}"> <zipfileset dir="${build}"/> <zipfileset src="${lib}/util-prp.jar" /> <zipfileset src="${lib}/jpcap.jar"/> <zipfileset src="${lib}/sbon-async.jar"/> </jar> </target> <target name="tarball" depends="jar" description="Create a tarball with all the files to run an Pyxida node."> <tar destfile="${Pyxida-tar}" compression="gzip" excludes="*"> <tarfileset dir="." mode="755"> <include name="runPyxida.sh" /> </tarfileset> <tarfileset dir="."> <include name="build.xml" /> <include name="dist/*.jar" /> <include name="config/**" /> </tarfileset> </tar> </target> <target name="tarball-src" description="Create a tarball with all the files and source code."> <tar destfile="${Pyxida-src-tar}" compression="gzip" excludes="*"> <tarfileset dir="." mode="755"> <include name="runPyxida.sh" /> </tarfileset> <tarfileset dir="."> <include name="build.xml" /> <include name="lib/**" /> <include name="config/**" /> <include name="src/**/" /> </tarfileset> </tar> </target> <!-- Run targets --> <target name="run-pyxida" depends="compile" description="Execute Pyxida from classes."> <java classname="edu.harvard.syrah.pyxida.Pyxida" fork="true" maxmemory="256m"> <classpath refid="classpath"/> <classpath> <pathelement location="${build}"/> </classpath> <jvmarg value="-ea"/> <sysproperty key="pyxida.config" value="${pyxida.config}" /> <sysproperty key="java.util.logging.config.file" value="${java.util.logging.config.file}" /> <syspropertyset> <propertyref builtin="commandline"/> </syspropertyset> </java> </target> <target name="run-pyxida-jar" description="Execute Pyxida from the jar file."> <java classname="edu.harvard.syrah.pyxida.Pyxida" fork="true" maxmemory="256m"> <classpath> <pathelement location="${dist}/${Pyxida-jar}"/> </classpath> <jvmarg value="-ea"/> <!-- Turn on assertions --> <!-- <jvmarg value="-Xloggc:"/> --> <sysproperty key="pyxida.config" value="${pyxida.config}" /> <sysproperty key="java.util.logging.config.file" value="${java.util.logging.config.file}" /> <syspropertyset> <propertyref builtin="commandline"/> </syspropertyset> </java> </target> <target name="run-pyxida-jar-profile" description="Execute Pyxida from the jar file with profiling support."> <java classname="edu.harvard.syrah.pyxida.Pyxida" fork="true" maxmemory="256m"> <classpath> <pathelement location="${dist}/${Pyxida-jar}"/> </classpath> <jvmarg value="-ea"/> <!-- Turn on assertions --> <!-- <jvmarg value="-Xloggc:"/> --> <jvmarg value="-Xbootclasspath/a:/home/prp/local/jprofiler/bin/agent.jar"/> <jvmarg value="-agentlib:jprofilerti"/> <!-- <jvmarg value="-Xrunjprofiler"/> --> <sysproperty key="pyxida.config" value="${pyxida.config}" /> <sysproperty key="java.util.logging.config.file" value="${java.util.logging.config.file}" /> <syspropertyset> <propertyref builtin="commandline"/> </syspropertyset> </java> </target> <target name="run-pyxida-jar-debug" description="Execute Pyxida from the jar file with heap debugging."> <java classname="edu.harvard.syrah.pyxida.Pyxida" fork="true" maxmemory="128m"> <classpath> <pathelement location="${dist}/${Pyxida-jar}"/> <pathelement location="${lib}/util-prp.jar"/> <pathelement location="${lib}/jb2refscan-2.58.jar"/> </classpath> <classpath refid="classpath"/> <jvmarg value="-ea"/> <!-- Turn on assertions --> <!-- <jvmarg value="-Xloggc:"/> --> <jvmarg value="-verbose:gc" /> <jvmarg value="-Xrunhprof:heap=all,file=java-hprof=${env.HOSTNAME}.txt" /> <sysproperty key="pyxida.config" value="${pyxida.config}" /> <sysproperty key="java.util.logging.config.file" value="${java.util.logging.config.file}" /> <syspropertyset> <propertyref builtin="commandline"/> </syspropertyset> </java> </target> <!-- Clean targets --> <target name="clean" description="Clean build and dist directory."> <!-- Delete the ${build} directory trees --> <delete dir="${build}" /> </target> </project> --- NEW FILE: runPyxida.sh --- #!/bin/bash echo Starting Pyxida on node $HOSTNAME... [ -e "pyxida-$HOSTNAME.log" ] && mv -f pyxida-$HOSTNAME.log pyxida-$HOSTNAME.log.prev ANT="ant -e" ANT_LOG="-l pyxida-$HOSTNAME.log" PYXIDA_CONFIG="-Dpyxida.config=config/pyxida.cfg\ -Djava.util.logging.config.file=config/log.config" CMD="$ANT $PYXIDA_CONFIG run-pyxida-jar" if [ "$1" == "--log" ]; then CMD="$ANT $ANT_LOG $PYXIDA_CONFIG run-pyxida-jar" fi if [ "$1" == "--profile" ]; then CMD="$ANT $PYXIDA_CONFIG run-pyxida-jar-profile" fi echo Launching... $CMD |
|
From: Peter P. <pr...@us...> - 2006-11-27 16:25:12
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22326/src/edu/harvard/syrah/pyxida/nc Modified Files: NCManager.java Log Message: Fixed problem with missing port numbers Index: NCManager.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/NCManager.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** NCManager.java 27 Nov 2006 15:57:22 -0000 1.7 --- NCManager.java 27 Nov 2006 16:24:59 -0000 1.8 *************** *** 1,14 **** ! package edu.harvard.syrah.pyxida.nc; ! import java.util.Arrays; ! import java.util.HashSet; ! import java.util.ArrayList; ! import java.util.Map; ! import java.util.HashMap; ! import java.util.Set; import edu.harvard.syrah.prp.Log; import edu.harvard.syrah.pyxida.nc.lib.Coordinate; - import edu.harvard.syrah.pyxida.*; import edu.harvard.syrah.pyxida.nc.lib.NCClient; import edu.harvard.syrah.pyxida.ping.PingManager; --- 1,9 ---- ! package edu.harvard.syrah.pyxida.nc; ! import java.util.*; import edu.harvard.syrah.prp.Log; + import edu.harvard.syrah.pyxida.Pyxida; import edu.harvard.syrah.pyxida.nc.lib.Coordinate; import edu.harvard.syrah.pyxida.nc.lib.NCClient; import edu.harvard.syrah.pyxida.ping.PingManager; *************** *** 25,29 **** import edu.harvard.syrah.sbon.comm.obj.ObjMessageIF; ! // MEDTODO add proxy coordinates /** --- 20,24 ---- import edu.harvard.syrah.sbon.comm.obj.ObjMessageIF; ! //MEDTODO add proxy coordinates /** *************** *** 38,42 **** // 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" // of the coordinates array. --- 33,37 ---- // 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" // of the coordinates array. *************** *** 46,61 **** // 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]"); ! /** ! * Time between gossip messages to coordinate neighbors. ! * Default is 10 seconds. ! */ public static final long UPDATE_DELAY = 10 * 1000; ! /** ! * Default lifetime that proxy coordinates are managed for. ! * Set to one hour. ! */ public static final long DEFAULT_PROXY_LEASE = 3600 * 1000; --- 41,56 ---- // 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]"); ! /** ! * Time between gossip messages to coordinate neighbors. ! * Default is 10 seconds. ! */ public static final long UPDATE_DELAY = 10 * 1000; ! /** ! * Default lifetime that proxy coordinates are managed for. ! * Set to one hour. ! */ public static final long DEFAULT_PROXY_LEASE = 3600 * 1000; *************** *** 67,77 **** final CoordClient localNC; ! Map<AddressIF,Long> neighbor2age; ! ArrayList<AddressIF> neighbors; ! /** ! * Create a coordinate manager. ! * Does not block. ! */ public NCManager(ObjCommIF _comm, PingManager pingManager) { comm = _comm; --- 62,72 ---- final CoordClient localNC; ! Map<AddressIF,Long> neighbor2age; ! ArrayList<AddressIF> neighbors; ! /** ! * Create a coordinate manager. ! * Does not block. ! */ public NCManager(ObjCommIF _comm, PingManager pingManager) { comm = _comm; *************** *** 81,89 **** } ! /** ! * Asynchronous initialization of coordinate manager. ! * Resolves bootstrap neighbors and starts gossip for local coordinate. ! * Starts listening for gossip messages. ! */ public void init(final CB0 cbDone) { comm.registerMessageCB(GossipRequestMsg.class, new GossipHandler()); --- 76,84 ---- } ! /** ! * Asynchronous initialization of coordinate manager. ! * Resolves bootstrap neighbors and starts gossip for local coordinate. ! * Starts listening for gossip messages. ! */ public void init(final CB0 cbDone) { comm.registerMessageCB(GossipRequestMsg.class, new GossipHandler()); *************** *** 92,100 **** neighbors = new ArrayList<AddressIF>(); ! AddressFactory.createResolved(Arrays.asList(bootstrapList), new CB1<Map<String, AddressIF>>() { protected void cb(CBResult result, Map<String, AddressIF> addrMap) { switch (result.state) { case OK: { for (String remoteNode : addrMap.keySet()) { AddressIF remoteAddr = addrMap.get(remoteNode); addGossipNode(remoteAddr); --- 87,97 ---- neighbors = new ArrayList<AddressIF>(); ! log.debug("Resolving bootstrap list"); ! AddressFactory.createResolved(Arrays.asList(bootstrapList), Pyxida.COMM_PORT, new CB1<Map<String, AddressIF>>() { protected void cb(CBResult result, Map<String, AddressIF> addrMap) { switch (result.state) { case OK: { for (String remoteNode : addrMap.keySet()) { + log.debug("remoteNode='" + remoteNode + "'"); AddressIF remoteAddr = addrMap.get(remoteNode); addGossipNode(remoteAddr); *************** *** 120,154 **** } ! /** ! * Not implemented yet. ! */ public void createProxyCoord(AddressIF remoteNode, long lease) { // LOWTODO } ! /** ! * Not implemented yet. ! */ public void destroyProxyCoord(AddressIF remoteNode) { // LOWTODO } ! /** ! * @return local coordinate ! */ public Coordinate getLocalCoord() { return localNC.nc.getSystemCoords(); } ! /** ! * @return local error ! */ public double getLocalError() { return localNC.nc.getSystemError(); } ! /** ! * Not implemented yet. ! */ public Coordinate getProxyCoord(AddressIF remoteNode) { // LOWTODO --- 117,151 ---- } ! /** ! * Not implemented yet. ! */ public void createProxyCoord(AddressIF remoteNode, long lease) { // LOWTODO } ! /** ! * Not implemented yet. ! */ public void destroyProxyCoord(AddressIF remoteNode) { // LOWTODO } ! /** ! * @return local coordinate ! */ public Coordinate getLocalCoord() { return localNC.nc.getSystemCoords(); } ! /** ! * @return local error ! */ public double getLocalError() { return localNC.nc.getSystemError(); } ! /** ! * Not implemented yet. ! */ public Coordinate getProxyCoord(AddressIF remoteNode) { // LOWTODO *************** *** 156,162 **** } ! /** ! * ! */ public double estimateRTT(AddressIF nodeA, AddressIF nodeB) { // TODO --- 153,159 ---- } ! /** ! * ! */ public double estimateRTT(AddressIF nodeA, AddressIF nodeB) { // TODO *************** *** 171,175 **** public void shutDown(DataOutputStream os) throws IOException { } ! */ abstract class ResponseObjCommCB<T extends ObjMessageIF> extends ObjCommCB<T> { --- 168,172 ---- public void shutDown(DataOutputStream os) throws IOException { } ! */ abstract class ResponseObjCommCB<T extends ObjMessageIF> extends ObjCommCB<T> { *************** *** 213,217 **** new GossipResponseMsg(localNC.nc.getSystemCoords(), localNC.nc.getSystemError(), localNC.nc.getAge(curr_time), getGossipNodes(msg.coordinate)), msg.getMsgId(), null, ! cbHandled); } --- 210,214 ---- new GossipResponseMsg(localNC.nc.getSystemCoords(), localNC.nc.getSystemError(), localNC.nc.getAge(curr_time), getGossipNodes(msg.coordinate)), msg.getMsgId(), null, ! cbHandled); } *************** *** 219,272 **** ! AddressIF getGossipNode() { ! if (neighbors.size() == 0) { ! log.warn("we are lonely and have no one to gossip with"); ! return null; ! } ! int index = Pyxida.random.nextInt(neighbors.size()); ! AddressIF node = neighbors.get(index); ! return node; ! } Set<AddressIF> getGossipNodes(Coordinate remoteCoord) { ! Set<AddressIF> nodes = new HashSet<AddressIF>(); ! // LOWTODO add option of loop here ! AddressIF node = getGossipNode(); ! if (node != null) { ! nodes.add(node); ! } ! return nodes; } void addGossipNodes(Set<AddressIF> nodes) { ! for (AddressIF node : nodes) { ! addGossipNode (node); ! } } void addGossipNode(AddressIF node) { ! long curr_time = System.currentTimeMillis(); ! Long expiry = neighbor2age.get(node); ! if (expiry != null) { ! log.debug ("gossip already knew node "+node); ! long old_time = expiry.longValue(); ! expiry = new Long (curr_time); ! ! expiry = neighbor2age.get(node); ! long new_time = expiry.longValue(); ! log.debug ("old_time "+old_time+" new "+new_time); ! return; ! } ! neighbors.add(node); ! neighbor2age.put(node,curr_time); ! log.debug ("gossip added new neighbor "+node); } class CoordClient { final NCClient<AddressIF> nc; ! final CB0 updateCB; public CoordClient() { --- 216,269 ---- ! AddressIF getGossipNode() { ! if (neighbors.size() == 0) { ! log.warn("we are lonely and have no one to gossip with"); ! return null; ! } ! int index = Pyxida.random.nextInt(neighbors.size()); ! AddressIF node = neighbors.get(index); ! return node; ! } Set<AddressIF> getGossipNodes(Coordinate remoteCoord) { ! Set<AddressIF> nodes = new HashSet<AddressIF>(); ! // LOWTODO add option of loop here ! AddressIF node = getGossipNode(); ! if (node != null) { ! nodes.add(node); ! } ! return nodes; } void addGossipNodes(Set<AddressIF> nodes) { ! for (AddressIF node : nodes) { ! addGossipNode (node); ! } } void addGossipNode(AddressIF node) { ! long curr_time = System.currentTimeMillis(); ! Long expiry = neighbor2age.get(node); ! if (expiry != null) { ! log.debug ("gossip already knew node "+node); ! long old_time = expiry.longValue(); ! expiry = new Long (curr_time); ! expiry = neighbor2age.get(node); ! long new_time = expiry.longValue(); ! log.debug ("old_time "+old_time+" new "+new_time); ! ! return; ! } ! neighbors.add(node); ! neighbor2age.put(node,curr_time); ! log.debug ("gossip added new neighbor "+node); } class CoordClient { final NCClient<AddressIF> nc; ! final CB0 updateCB; public CoordClient() { *************** *** 274,298 **** updateCB = new CB0() { ! protected void cb(CBResult result) { ! update(); ! } ! }; } ! void registerTimer () { ! // LOWTODO adaptive delay ! double rnd = Pyxida.random.nextGaussian(); ! long delay = UPDATE_DELAY + (long)(1000 * rnd); ! log.debug ("setting timer to "+delay); ! EventLoop.get().registerTimerCB(delay, updateCB); ! } public void init() { ! registerTimer(); } void update() { ! registerTimer(); final AddressIF neighbor = pickGossipNode(); --- 271,296 ---- updateCB = new CB0() { ! protected void cb(CBResult result) { ! update(); ! } ! }; } ! void registerTimer () { ! // LOWTODO adaptive delay ! double rnd = Pyxida.random.nextGaussian(); ! long delay = UPDATE_DELAY + (long)(1000 * rnd); log.debug("Initialising the ping manager..."); ! ! log.debug ("setting timer to "+delay); ! EventLoop.get().registerTimerCB(delay, updateCB); ! } public void init() { ! registerTimer(); } void update() { ! registerTimer(); final AddressIF neighbor = pickGossipNode(); *************** *** 374,379 **** void update() { ! registerTimer(); ! final AddressIF neighbor = pickGossipNode(); // ask him to ping our address --- 372,377 ---- void update() { ! registerTimer(); ! final AddressIF neighbor = pickGossipNode(); // ask him to ping our address |
|
From: Peter P. <pr...@us...> - 2006-11-27 16:25:08
|
Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22326/src/edu/harvard/syrah/pyxida Modified Files: Pyxida.java Log Message: Fixed problem with missing port numbers Index: Pyxida.java =================================================================== RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/Pyxida.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Pyxida.java 27 Nov 2006 15:34:40 -0000 1.10 --- Pyxida.java 27 Nov 2006 16:24:59 -0000 1.11 *************** *** 1,3 **** ! package edu.harvard.syrah.pyxida; import java.util.Random; --- 1,3 ---- ! package edu.harvard.syrah.pyxida; import java.util.Random; *************** *** 19,27 **** private static final Log log = new Log(Pyxida.class); ! private static final String PYXIDA_VERSION = "0.1"; ! public static final String PYXIDA_CONFIG_FILE = System ! .getProperty("pyxida.config", "config/pyxida.cfg"); private static Pyxida pyxida = null; --- 19,29 ---- private static final Log log = new Log(Pyxida.class); ! private static final String VERSION = "0.1"; ! private static final String CONFIG_FILE = System.getProperty("pyxida.config", ! "config/pyxida.cfg"); + public static final int COMM_PORT = Integer.parseInt(Config.getConfigProps().getProperty("pyxida.port", "55500")); + private static Pyxida pyxida = null; *************** *** 31,45 **** private ObjCommIF comm; ! public static Random random; ! private Pyxida() { /* empty */} private void init() { ! random = new Random(System.currentTimeMillis()); // Initiliase the ObjComm communication module comm = new ObjComm(); ! int port = Integer.parseInt(Config.getConfigProps().getProperty("pyxida.port", "55500")); ! AddressIF objCommAddr = AddressFactory.createServer(port); comm.initServer(objCommAddr, new CB0() { protected void cb(CBResult result) { --- 33,47 ---- private ObjCommIF comm; ! public static Random random; ! private Pyxida() { /* empty */ } private void init() { ! random = new Random(System.currentTimeMillis()); // Initiliase the ObjComm communication module comm = new ObjComm(); ! AddressIF objCommAddr = AddressFactory.createServer(COMM_PORT); ! log.debug("Starting objcomm server..."); comm.initServer(objCommAddr, new CB0() { protected void cb(CBResult result) { *************** *** 48,55 **** --- 50,59 ---- // Initialise the measurement modules pingManager = new PingManager(); + log.debug("Initialising the PingManager..."); pingManager.init(new CB0() { protected void cb(CBResult result) { // Initialise the NCs that we're responsible for ncManager = new NCManager(comm, pingManager); + log.debug("Initialising the NCManger..."); ncManager.init(new CB0() { protected void cb(CBResult result) { *************** *** 67,71 **** } } ! } }); } --- 71,75 ---- } } ! } }); } *************** *** 79,84 **** } } ! } ! }); } --- 83,88 ---- } } ! } ! }); } *************** *** 87,91 **** */ public static void main(String[] args) { ! log.main("Pyxida Version " + PYXIDA_VERSION + " starting..."); // TODO JTL: do you GetOpt magic here --- 91,95 ---- */ public static void main(String[] args) { ! log.main("Pyxida Version " + VERSION + " starting..."); // TODO JTL: do you GetOpt magic here *************** *** 99,105 **** args = newArgs; } ! // Read the config file ! String configFileName = PYXIDA_CONFIG_FILE; if (args.length == 1) { configFileName = args[0]; --- 103,109 ---- args = newArgs; } ! // Read the config file ! String configFileName = CONFIG_FILE; if (args.length == 1) { configFileName = args[0]; |
|
From: Peter P. <pr...@us...> - 2006-11-27 16:25:04
|
Update of /cvsroot/pyxida/Pyxida/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22326/lib Modified Files: sbon-async.jar Log Message: Fixed problem with missing port numbers Index: sbon-async.jar =================================================================== RCS file: /cvsroot/pyxida/Pyxida/lib/sbon-async.jar,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 Binary files /tmp/cvskusVWb and /tmp/cvswdEdUe differ |