forked from I2P_Developers/i2p.i2p
more clock log tweaks
This commit is contained in:
@ -71,21 +71,27 @@ public class Clock implements Timestamper.UpdateListener {
|
|||||||
long delta = offsetMs - _offset;
|
long delta = offsetMs - _offset;
|
||||||
if (!force) {
|
if (!force) {
|
||||||
if ((offsetMs > MAX_OFFSET) || (offsetMs < 0 - MAX_OFFSET)) {
|
if ((offsetMs > MAX_OFFSET) || (offsetMs < 0 - MAX_OFFSET)) {
|
||||||
getLog().error("Maximum offset shift exceeded [" + offsetMs + "], NOT HONORING IT");
|
Log log = getLog();
|
||||||
|
if (log.shouldLog(Log.WARN))
|
||||||
|
log.warn("Maximum offset shift exceeded [" + offsetMs + "], NOT HONORING IT");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// only allow substantial modifications before the first 10 minutes
|
// only allow substantial modifications before the first 10 minutes
|
||||||
if (_alreadyChanged && (System.currentTimeMillis() - _startedOn > 10 * 60 * 1000)) {
|
if (_alreadyChanged && (System.currentTimeMillis() - _startedOn > 10 * 60 * 1000)) {
|
||||||
if ( (delta > MAX_LIVE_OFFSET) || (delta < 0 - MAX_LIVE_OFFSET) ) {
|
if ( (delta > MAX_LIVE_OFFSET) || (delta < 0 - MAX_LIVE_OFFSET) ) {
|
||||||
getLog().log(Log.CRIT, "The clock has already been updated, but you want to change it by "
|
Log log = getLog();
|
||||||
|
if (log.shouldLog(Log.WARN))
|
||||||
|
log.warn("The clock has already been updated, but you want to change it by "
|
||||||
+ delta + " to " + offsetMs + "? Did something break?");
|
+ delta + " to " + offsetMs + "? Did something break?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((delta < MIN_OFFSET_CHANGE) && (delta > 0 - MIN_OFFSET_CHANGE)) {
|
if ((delta < MIN_OFFSET_CHANGE) && (delta > 0 - MIN_OFFSET_CHANGE)) {
|
||||||
getLog().debug("Not changing offset since it is only " + delta + "ms");
|
Log log = getLog();
|
||||||
|
if (log.shouldLog(Log.DEBUG))
|
||||||
|
log.debug("Not changing offset since it is only " + delta + "ms");
|
||||||
_alreadyChanged = true;
|
_alreadyChanged = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -102,7 +108,9 @@ public class Clock implements Timestamper.UpdateListener {
|
|||||||
}
|
}
|
||||||
_context.statManager().addRateData("clock.skew", delta, 0);
|
_context.statManager().addRateData("clock.skew", delta, 0);
|
||||||
} else {
|
} else {
|
||||||
getLog().log(Log.INFO, "Initializing clock offset to " + offsetMs + "ms from " + _offset + "ms");
|
Log log = getLog();
|
||||||
|
if (log.shouldLog(Log.INFO))
|
||||||
|
log.info("Initializing clock offset to " + offsetMs + "ms from " + _offset + "ms");
|
||||||
}
|
}
|
||||||
_alreadyChanged = true;
|
_alreadyChanged = true;
|
||||||
_offset = offsetMs;
|
_offset = offsetMs;
|
||||||
|
@ -95,14 +95,18 @@ public class RouterClock extends Clock {
|
|||||||
long delta = offsetMs - _offset;
|
long delta = offsetMs - _offset;
|
||||||
if (!force) {
|
if (!force) {
|
||||||
if ((offsetMs > MAX_OFFSET) || (offsetMs < 0 - MAX_OFFSET)) {
|
if ((offsetMs > MAX_OFFSET) || (offsetMs < 0 - MAX_OFFSET)) {
|
||||||
getLog().error("Maximum offset shift exceeded [" + offsetMs + "], NOT HONORING IT");
|
Log log = getLog();
|
||||||
|
if (log.shouldLog(Log.WARN))
|
||||||
|
log.warn("Maximum offset shift exceeded [" + offsetMs + "], NOT HONORING IT");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// only allow substantial modifications before the first 10 minutes
|
// only allow substantial modifications before the first 10 minutes
|
||||||
if (_alreadyChanged && (System.currentTimeMillis() - _startedOn > 10 * 60 * 1000)) {
|
if (_alreadyChanged && (System.currentTimeMillis() - _startedOn > 10 * 60 * 1000)) {
|
||||||
if ( (delta > MAX_LIVE_OFFSET) || (delta < 0 - MAX_LIVE_OFFSET) ) {
|
if ( (delta > MAX_LIVE_OFFSET) || (delta < 0 - MAX_LIVE_OFFSET) ) {
|
||||||
getLog().log(Log.WARN, "The clock has already been updated, ignoring request to change it by "
|
Log log = getLog();
|
||||||
|
if (log.shouldLog(Log.WARN))
|
||||||
|
log.warn("The clock has already been updated, ignoring request to change it by "
|
||||||
+ delta + " to " + offsetMs, new Exception());
|
+ delta + " to " + offsetMs, new Exception());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -118,7 +122,9 @@ public class RouterClock extends Clock {
|
|||||||
// only listen to a worse stratum if it's been a while
|
// only listen to a worse stratum if it's been a while
|
||||||
if (_alreadyChanged && stratum > _lastStratum &&
|
if (_alreadyChanged && stratum > _lastStratum &&
|
||||||
System.currentTimeMillis() - _lastChanged < MIN_DELAY_FOR_WORSE_STRATUM) {
|
System.currentTimeMillis() - _lastChanged < MIN_DELAY_FOR_WORSE_STRATUM) {
|
||||||
getLog().debug("Ignoring update from a stratum " + stratum +
|
Log log = getLog();
|
||||||
|
if (log.shouldLog(Log.DEBUG))
|
||||||
|
log.debug("Ignoring update from a stratum " + stratum +
|
||||||
" clock, we recently had an update from a stratum " + _lastStratum + " clock");
|
" clock, we recently had an update from a stratum " + _lastStratum + " clock");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -142,7 +148,9 @@ public class RouterClock extends Clock {
|
|||||||
"ms to " + predictedPeerClockSkew + "ms. Bad time server?");
|
"ms to " + predictedPeerClockSkew + "ms. Bad time server?");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
getLog().debug("Approving clock offset " + offsetMs + "ms (current " + _offset +
|
Log log = getLog();
|
||||||
|
if (log.shouldLog(Log.DEBUG))
|
||||||
|
log.debug("Approving clock offset " + offsetMs + "ms (current " + _offset +
|
||||||
"ms) since it would decrease peer clock skew from " + currentPeerClockSkew +
|
"ms) since it would decrease peer clock skew from " + currentPeerClockSkew +
|
||||||
"ms to " + predictedPeerClockSkew + "ms.");
|
"ms to " + predictedPeerClockSkew + "ms.");
|
||||||
}
|
}
|
||||||
@ -167,7 +175,9 @@ public class RouterClock extends Clock {
|
|||||||
_context.statManager().addRateData("clock.skew", delta);
|
_context.statManager().addRateData("clock.skew", delta);
|
||||||
_desiredOffset = offsetMs;
|
_desiredOffset = offsetMs;
|
||||||
} else {
|
} else {
|
||||||
getLog().log(Log.INFO, "Initializing clock offset to " + offsetMs + "ms, Stratum " + stratum);
|
Log log = getLog();
|
||||||
|
if (log.shouldLog(Log.INFO))
|
||||||
|
log.info("Initializing clock offset to " + offsetMs + "ms, Stratum " + stratum);
|
||||||
_alreadyChanged = true;
|
_alreadyChanged = true;
|
||||||
_offset = offsetMs;
|
_offset = offsetMs;
|
||||||
_desiredOffset = offsetMs;
|
_desiredOffset = offsetMs;
|
||||||
|
Reference in New Issue
Block a user