Changeset b3fcdb8
- Timestamp:
- Nov 30, 2011 11:17:40 PM (9 years ago)
- Branches:
- master
- Children:
- 080cc96
- Parents:
- f6cff78
- Location:
- router/java/src/net/i2p/router
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
router/java/src/net/i2p/router/Router.java
rf6cff78 rb3fcdb8 1008 1008 return; 1009 1009 _shutdownInProgress = true; 1010 _context.throttle().setShutdownStatus(); 1010 1011 if (_shutdownHook != null) { 1011 1012 try { … … 1152 1153 _gracefulExitCode = exitCode; 1153 1154 _config.put(PROP_SHUTDOWN_IN_PROGRESS, "true"); 1155 _context.throttle().setShutdownStatus(); 1154 1156 synchronized (_gracefulShutdownDetector) { 1155 1157 _gracefulShutdownDetector.notifyAll(); … … 1164 1166 _gracefulExitCode = -1; 1165 1167 _config.remove(PROP_SHUTDOWN_IN_PROGRESS); 1168 _context.throttle().cancelShutdownStatus(); 1166 1169 synchronized (_gracefulShutdownDetector) { 1167 1170 _gracefulShutdownDetector.notifyAll(); -
router/java/src/net/i2p/router/RouterThrottle.java
rf6cff78 rb3fcdb8 48 48 public String getTunnelStatus(); 49 49 public void setTunnelStatus(String msg); 50 51 /** @since 0.8.12 */ 52 public void setShutdownStatus(); 53 54 /** @since 0.8.12 */ 55 public void cancelShutdownStatus(); 50 56 } -
router/java/src/net/i2p/router/RouterThrottleImpl.java
rf6cff78 rb3fcdb8 6 6 import net.i2p.stat.RateStat; 7 7 import net.i2p.util.Log; 8 import net.i2p.util.SimpleScheduler; 9 import net.i2p.util.SimpleTimer; 8 10 9 11 /** … … 47 49 private static final int PREPROCESSED_SIZE = 1024; 48 50 51 private static final long REJECT_STARTUP_TIME = 20*60*1000; 52 49 53 public RouterThrottleImpl(RouterContext context) { 50 54 _context = context; 51 55 _log = context.logManager().getLog(RouterThrottleImpl.class); 52 56 setTunnelStatus(); 57 SimpleScheduler.getInstance().addEvent(new ResetStatus(), REJECT_STARTUP_TIME + 120*1000); 53 58 _context.statManager().createRateStat("router.throttleNetworkCause", "How lagged the jobQueue was when an I2NP was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 }); 54 59 //_context.statManager().createRateStat("router.throttleNetDbCause", "How lagged the jobQueue was when a networkDb request was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 }); … … 67 72 } 68 73 74 /** 75 * Reset status from starting up to not-starting up, 76 * in case we don't get a tunnel request soon after the 20 minutes is up. 77 * 78 * @since 0.8.12 79 */ 80 private class ResetStatus implements SimpleTimer.TimedEvent { 81 public void timeReached() { 82 if (_tunnelStatus.equals(_x("Rejecting tunnels: Starting up"))) 83 cancelShutdownStatus(); 84 } 85 } 86 69 87 public boolean acceptNetworkMessage() { 70 88 //if (true) return true; … … 97 115 if (_log.shouldLog(Log.WARN)) 98 116 _log.warn("Refusing tunnel request since we are shutting down ASAP"); 99 set TunnelStatus(_x("Rejecting tunnels: Shutting down"));117 setShutdownStatus(); 100 118 // Don't use CRIT because this tells everybody we are shutting down 101 119 return TunnelHistory.TUNNEL_REJECT_BANDWIDTH; … … 103 121 104 122 // Don't use CRIT because we don't want peers to think we're failing 105 if (_context.router().getUptime() < 20*60*1000) 123 if (_context.router().getUptime() < REJECT_STARTUP_TIME) { 124 setTunnelStatus(_x("Rejecting tunnels: Starting up")); 106 125 return TunnelHistory.TUNNEL_REJECT_BANDWIDTH; 126 } 107 127 108 128 //long lag = _context.jobQueue().getMaxLag(); … … 502 522 // setTunnelStatus("Not expecting tunnel requests: Advertised bandwidth too low"); 503 523 // else 504 setTunnelStatus(_x("Rejecting tunnels")); 524 setTunnelStatus(_x("Rejecting tunnels: Starting up")); 525 } 526 527 /** @since 0.8.12 */ 528 public void setShutdownStatus() { 529 setTunnelStatus(_x("Rejecting tunnels: Shutting down")); 530 } 531 532 /** @since 0.8.12 */ 533 public void cancelShutdownStatus() { 534 setTunnelStatus(_x("Rejecting tunnels")); 505 535 } 506 536
Note: See TracChangeset
for help on using the changeset viewer.