* in the multirouter (sim), give each router a randomly distributed clock skew (within the acceptable period)
* in the multirouter (sim), disable the timestamper (so the clock skew 'sticks') * logging
This commit is contained in:
@ -51,9 +51,12 @@ public class MultiRouter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_defaultContext = new I2PAppContext(getEnv(args[0]));
|
_defaultContext = new I2PAppContext(getEnv(args[0]));
|
||||||
|
|
||||||
_log = _defaultContext.logManager().getLog(MultiRouter.class);
|
_log = _defaultContext.logManager().getLog(MultiRouter.class);
|
||||||
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
|
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
|
||||||
|
|
||||||
|
_defaultContext.clock().setOffset(0);
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Thread.currentThread().setName("Router* Shutdown");
|
Thread.currentThread().setName("Router* Shutdown");
|
||||||
@ -71,8 +74,13 @@ public class MultiRouter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < _routers.size(); i++) {
|
for (int i = 0; i < _routers.size(); i++) {
|
||||||
((Router)_routers.get(i)).runRouter();
|
Router r = (Router)_routers.get(i);
|
||||||
_log.info("Router " + i + " started");
|
long offset = r.getContext().random().nextLong(Router.CLOCK_FUDGE_FACTOR/2);
|
||||||
|
if (r.getContext().random().nextBoolean())
|
||||||
|
offset = 0 - offset;
|
||||||
|
r.getContext().clock().setOffset(offset, true);
|
||||||
|
r.runRouter();
|
||||||
|
_log.info("Router " + i + " started with clock offset " + offset);
|
||||||
try { Thread.sleep(2*1000 + new java.util.Random().nextInt(2)*1000); } catch (InterruptedException ie) {}
|
try { Thread.sleep(2*1000 + new java.util.Random().nextInt(2)*1000); } catch (InterruptedException ie) {}
|
||||||
}
|
}
|
||||||
_log.info("All " + _routers.size() + " routers started up");
|
_log.info("All " + _routers.size() + " routers started up");
|
||||||
@ -83,6 +91,7 @@ public class MultiRouter {
|
|||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
try {
|
try {
|
||||||
props.load(new FileInputStream(filename));
|
props.load(new FileInputStream(filename));
|
||||||
|
props.setProperty("time.disabled", "true");
|
||||||
return props;
|
return props;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ioe.printStackTrace();
|
ioe.printStackTrace();
|
||||||
|
@ -152,6 +152,8 @@ public class Router {
|
|||||||
/** wall clock uptime */
|
/** wall clock uptime */
|
||||||
public long getUptime() { return _context.clock().now() - _context.clock().getOffset() - _started; }
|
public long getUptime() { return _context.clock().now() - _context.clock().getOffset() - _started; }
|
||||||
|
|
||||||
|
public RouterContext getContext() { return _context; }
|
||||||
|
|
||||||
void runRouter() {
|
void runRouter() {
|
||||||
_isAlive = true;
|
_isAlive = true;
|
||||||
_started = _context.clock().now();
|
_started = _context.clock().now();
|
||||||
|
@ -187,7 +187,7 @@ public class ClientManager {
|
|||||||
public void requestLeaseSet(Destination dest, LeaseSet set, long timeout, Job onCreateJob, Job onFailedJob) {
|
public void requestLeaseSet(Destination dest, LeaseSet set, long timeout, Job onCreateJob, Job onFailedJob) {
|
||||||
ClientConnectionRunner runner = getRunner(dest);
|
ClientConnectionRunner runner = getRunner(dest);
|
||||||
if (runner == null) {
|
if (runner == null) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.ERROR))
|
||||||
_log.warn("Cannot request the lease set, as we can't find a client runner for "
|
_log.warn("Cannot request the lease set, as we can't find a client runner for "
|
||||||
+ dest.calculateHash().toBase64() + ". disconnected?");
|
+ dest.calculateHash().toBase64() + ". disconnected?");
|
||||||
_context.jobQueue().addJob(onFailedJob);
|
_context.jobQueue().addJob(onFailedJob);
|
||||||
|
@ -462,7 +462,12 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
|||||||
public void publish(LeaseSet localLeaseSet) {
|
public void publish(LeaseSet localLeaseSet) {
|
||||||
if (!_initialized) return;
|
if (!_initialized) return;
|
||||||
Hash h = localLeaseSet.getDestination().calculateHash();
|
Hash h = localLeaseSet.getDestination().calculateHash();
|
||||||
|
try {
|
||||||
store(h, localLeaseSet);
|
store(h, localLeaseSet);
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
_log.error("wtf, locally published leaseSet is not valid?", iae);
|
||||||
|
return;
|
||||||
|
}
|
||||||
synchronized (_explicitSendKeys) {
|
synchronized (_explicitSendKeys) {
|
||||||
_explicitSendKeys.add(h);
|
_explicitSendKeys.add(h);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,10 @@ class RestrictiveTCPConnection extends TCPConnection {
|
|||||||
long diff = now.getTime() - theirNow.getTime();
|
long diff = now.getTime() - theirNow.getTime();
|
||||||
if ( (diff > Router.CLOCK_FUDGE_FACTOR) || (diff < (0-Router.CLOCK_FUDGE_FACTOR)) ) {
|
if ( (diff > Router.CLOCK_FUDGE_FACTOR) || (diff < (0-Router.CLOCK_FUDGE_FACTOR)) ) {
|
||||||
if (_log.shouldLog(Log.ERROR))
|
if (_log.shouldLog(Log.ERROR))
|
||||||
_log.error("Peer is out of time sync! They think it is " + theirNow + ": " + _remoteIdentity.getHash(), new Exception("Time sync error - please make sure your clock is correct!"));
|
_log.error("Peer is out of time sync by " + DataHelper.formatDuration(diff)
|
||||||
|
+ "! They think it is " + theirNow + ", we think it is "
|
||||||
|
+ new Date(_context.clock().now()) + ": " + _remoteIdentity.getHash(),
|
||||||
|
new Exception("Time sync error - please make sure your clock is correct!"));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
@ -216,7 +216,8 @@ class ClientLeaseSetManagerJob extends JobImpl {
|
|||||||
_lastCreated = ctx.clock().now();
|
_lastCreated = ctx.clock().now();
|
||||||
_currentLeaseSet = ls;
|
_currentLeaseSet = ls;
|
||||||
} else {
|
} else {
|
||||||
_log.error("New lease set created, but not found locally? wtf?!");
|
_log.error("New lease set created, but not found locally? wtf?! client="
|
||||||
|
+ _pool.getDestination().calculateHash().toBase64());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user