Update of /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10781/src/edu/harvard/syrah/pyxida/nc
Modified Files:
GossipResponseMsg.java NCManager.java
Log Message:
bit more code
Index: NCManager.java
===================================================================
RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/NCManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** NCManager.java 26 Nov 2006 23:41:37 -0000 1.3
--- NCManager.java 27 Nov 2006 04:06:37 -0000 1.4
***************
*** 52,64 ****
// TODO PRP
/*
! foreach (String remoteNode : bootstrapList) {
! // resolve and add him
! }
*/
- // TODO create timer to ping neighbors
localNC.init();
-
- // and/or ask local client who it would like to ping
// Also ping for any proxy coordinates.
--- 52,61 ----
// TODO PRP
/*
! foreach (String remoteNode : bootstrapList) {
! // resolve and add him
! }
*/
localNC.init();
// Also ping for any proxy coordinates.
***************
*** 93,103 ****
/*
! // TODO PRP low priority
public void startUp(DataInputStream is) throws IOException {
! // TODO
}
public void shutDown(DataOutputStream os) throws IOException {
! // TODO
}
*/
--- 90,100 ----
/*
! // TODO PRP low priority
public void startUp(DataInputStream is) throws IOException {
! // TODO
}
public void shutDown(DataOutputStream os) throws IOException {
! // TODO
}
*/
***************
*** 152,155 ****
--- 149,157 ----
}
+ void addGossipNodes (Set<AddressIF> nodes) {
+ // TODO add nodes to the set that we know about
+ }
+
+
AddressIF getGossipNode () {
// TODO return a guy to gossip with
***************
*** 171,174 ****
--- 173,177 ----
protected void cb(CBResult result) {
update();
+ // TODO PRP result.call(CBResult.OK()); ??
}
});
***************
*** 176,180 ****
void update () {
! AddressIF neighbor = pickGossipNode ();
// send him a gossip msg
--- 179,183 ----
void update () {
! final AddressIF neighbor = pickGossipNode ();
// send him a gossip msg
***************
*** 182,192 ****
GossipRequestMsg msg =
new GossipRequestMsg(localNC.nc.getSystemCoords(),getGossipNodes(null));
! // TODO JTL leaving off here
! //comm.sendTheMsg();
!
! // and ping him
! // and update our coordinate
}
--- 185,236 ----
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) {
!
! // TODO can use time of this instead of ping time
! // if we want to not use jpcap pings
! // (running not at root)
!
! 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:{
! // and update our coordinate
+ // TODO convert nclib to use floats
+ long lat_ms = (long) Math.round(latency);
+ long curr_time = System.currentTimeMillis();
+
+ 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;
+ }
+ }
+ }
+ });
}
Index: GossipResponseMsg.java
===================================================================
RCS file: /cvsroot/pyxida/Pyxida/src/edu/harvard/syrah/pyxida/nc/GossipResponseMsg.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** GossipResponseMsg.java 25 Nov 2006 21:39:59 -0000 1.1
--- GossipResponseMsg.java 27 Nov 2006 04:06:37 -0000 1.2
***************
*** 1,3 ****
! package edu.harvard.syrah.pyxida.nc;
import java.util.Set;
--- 1,3 ----
! package edu.harvard.syrah.pyxida.nc;
import java.util.Set;
|