|
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)); } |