forked from I2P_Developers/i2p.i2p
JobQueue: Listen to clock shifts as well as clock changes (ticket #1014).
Restarter: Don't restart the JobQueue or PeerManager (ticket #1014)/undo previous commit. More to do.
This commit is contained in:
@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.message.HandleGarlicMessageJob;
|
||||
import net.i2p.router.networkdb.kademlia.HandleFloodfillDatabaseLookupMessageJob;
|
||||
import net.i2p.router.RouterClock;
|
||||
import net.i2p.util.Clock;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.Log;
|
||||
@ -516,9 +517,10 @@ public class JobQueue {
|
||||
* max number of runners.
|
||||
*
|
||||
*/
|
||||
private final class QueuePumper implements Runnable, Clock.ClockUpdateListener {
|
||||
private final class QueuePumper implements Runnable, Clock.ClockUpdateListener, RouterClock.ClockShiftListener {
|
||||
public QueuePumper() {
|
||||
_context.clock().addUpdateListener(this);
|
||||
((RouterClock) _context.clock()).addShiftListener(this);
|
||||
}
|
||||
public void run() {
|
||||
try {
|
||||
@ -590,6 +592,7 @@ public class JobQueue {
|
||||
} // while (_alive)
|
||||
} catch (Throwable t) {
|
||||
_context.clock().removeUpdateListener(this);
|
||||
((RouterClock) _context.clock()).removeShiftListener(this);
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("pumper killed?!", t);
|
||||
}
|
||||
@ -602,6 +605,10 @@ public class JobQueue {
|
||||
}
|
||||
}
|
||||
|
||||
public void clockShift(long delta) {
|
||||
offsetChanged(delta);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,6 +8,7 @@ package net.i2p.router;
|
||||
*
|
||||
*/
|
||||
|
||||
import net.i2p.router.RouterClock;
|
||||
import net.i2p.util.Clock;
|
||||
|
||||
/**
|
||||
@ -15,7 +16,7 @@ import net.i2p.util.Clock;
|
||||
*
|
||||
* For use by the router only. Not to be used by applications or plugins.
|
||||
*/
|
||||
public class JobTiming implements Clock.ClockUpdateListener {
|
||||
public class JobTiming implements Clock.ClockUpdateListener, RouterClock.ClockShiftListener {
|
||||
private volatile long _start;
|
||||
private volatile long _actualStart;
|
||||
private volatile long _actualEnd;
|
||||
@ -81,4 +82,8 @@ public class JobTiming implements Clock.ClockUpdateListener {
|
||||
if (_actualEnd != 0)
|
||||
_actualEnd += delta;
|
||||
}
|
||||
|
||||
public void clockShift(long delta) {
|
||||
offsetChanged(delta);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 13;
|
||||
public final static long BUILD = 14;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
@ -30,9 +30,9 @@ public class Restarter implements Runnable {
|
||||
log.logAlways(Log.WARN, "Stopping the tunnel manager");
|
||||
try { _context.tunnelManager().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the tunnel manager", t); }
|
||||
|
||||
try { _context.peerManager().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the peer manager", t); }
|
||||
//try { _context.peerManager().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the peer manager", t); }
|
||||
//try { _context.netDb().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the networkDb", t); }
|
||||
try { _context.jobQueue().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the job queue", t); }
|
||||
//try { _context.jobQueue().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the job queue", t); }
|
||||
|
||||
log.logAlways(Log.WARN, "Router teardown complete, restarting the router...");
|
||||
try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
|
||||
|
Reference in New Issue
Block a user