2004-10-05 jrandom

* Display how much time is left before the graceful shutdown is complete.
    * Debug some improperly failed messages on timeout or disconnection.
This commit is contained in:
jrandom
2004-10-05 19:21:47 +00:00
committed by zzz
parent 756af9c699
commit 98c780415b
8 changed files with 76 additions and 4 deletions

View File

@ -0,0 +1,34 @@
package net.i2p.router.web;
import net.i2p.data.DataHelper;
import net.i2p.router.RouterContext;
/**
* Simple helper to query the appropriate router for data necessary to render
* any emergency notices
*/
public class NoticeHelper {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public String getSystemNotice() {
if (_context.router().gracefulShutdownInProgress()) {
return "Graceful shutdown in "
+ DataHelper.formatDuration(_context.router().getShutdownTimeRemaining());
} else {
return "";
}
}
}

View File

@ -25,3 +25,7 @@
<jsp:setProperty name="navhelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<jsp:getProperty name="navhelper" property="clientAppLinks" />
</h4>
<jsp:useBean class="net.i2p.router.web.NoticeHelper" id="noticehelper" scope="request" />
<jsp:setProperty name="noticehelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<b><jsp:getProperty name="noticehelper" property="systemNotice" /></b>

View File

@ -1,4 +1,8 @@
$Id: history.txt,v 1.32 2004/10/04 12:30:23 jrandom Exp $
$Id: history.txt,v 1.33 2004/10/05 10:38:37 jrandom Exp $
2004-10-05 jrandom
* Display how much time is left before the graceful shutdown is complete.
* Debug some improperly failed messages on timeout or disconnection.
2004-10-05 jrandom
* Don't go into a fast busy if an I2PTunnel 'server' is explicitly killed

View File

@ -660,6 +660,14 @@ public class Router {
public boolean gracefulShutdownInProgress() {
return (null != _config.getProperty(PROP_SHUTDOWN_IN_PROGRESS));
}
/** How long until the graceful shutdown will kill us? */
public long getShutdownTimeRemaining() {
long exp = _context.tunnelManager().getLastParticipatingExpiration();
if (exp < 0)
return -1;
else
return exp - _context.clock().now();
}
/**
* Simple thread that sits and waits forever, managing the

View File

@ -67,4 +67,7 @@ public interface TunnelManagerFacade extends Service {
public int getFreeTunnelCount();
/** how many outbound tunnels do we have available? */
public int getOutboundTunnelCount();
/** When does the last tunnel we are participating in expire? */
public long getLastParticipatingExpiration();
}

View File

@ -110,7 +110,8 @@ public class TCPConnection {
if (_socket != null) try { _socket.close(); } catch (IOException ioe) {}
List msgs = clearPendingMessages();
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage msg = (OutNetMessage)msgs.get(0);
OutNetMessage msg = (OutNetMessage)msgs.get(i);
msg.timestamp("closeConnection");
_transport.afterSend(msg, false, true, -1);
}
_context.profileManager().commErrorOccurred(_ident.getHash());

View File

@ -274,7 +274,9 @@ public class TCPTransport extends TransportImpl {
_context.shitlist().shitlistRouter(con.getAttemptedPeer(), "Changed identities");
if (changedMsgs != null) {
for (int i = 0; i < changedMsgs.size(); i++) {
afterSend((OutNetMessage)changedMsgs.get(i), false, false, 0);
OutNetMessage cur = (OutNetMessage)changedMsgs.get(i);
cur.timestamp("changedIdents");
afterSend(cur, false, false, 0);
}
}
}
@ -587,6 +589,7 @@ public class TCPTransport extends TransportImpl {
_context.netDb().fail(peer);
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage cur = (OutNetMessage)msgs.get(i);
cur.timestamp("no TCP addresses");
afterSend(cur, false, false, 0);
}
continue;
@ -600,6 +603,7 @@ public class TCPTransport extends TransportImpl {
_context.netDb().fail(peer);
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage cur = (OutNetMessage)msgs.get(i);
cur.timestamp("invalid addresses");
afterSend(cur, false, false, 0);
}
continue; // invalid
@ -613,6 +617,7 @@ public class TCPTransport extends TransportImpl {
_context.netDb().fail(peer);
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage cur = (OutNetMessage)msgs.get(i);
cur.timestamp("points at us");
afterSend(cur, false, false, 0);
}
continue;
@ -624,6 +629,7 @@ public class TCPTransport extends TransportImpl {
_context.netDb().fail(peer);
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage cur = (OutNetMessage)msgs.get(i);
cur.timestamp("points at our ip");
afterSend(cur, false, false, 0);
}
continue;
@ -637,6 +643,7 @@ public class TCPTransport extends TransportImpl {
_context.netDb().fail(peer);
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage cur = (OutNetMessage)msgs.get(i);
cur.timestamp("points at an illegal address");
afterSend(cur, false, false, 0);
}
continue;
@ -675,6 +682,7 @@ public class TCPTransport extends TransportImpl {
// connectionEstablished clears them otherwise)
for (int i = 0; i < msgs.size(); i++) {
OutNetMessage msg = (OutNetMessage)msgs.get(i);
msg.timestamp("establishmentComplete(failed)");
afterSend(msg, false);
}
}

View File

@ -234,5 +234,15 @@ public class PoolingTunnelManagerFacade implements TunnelManagerFacade {
if (_pool != null)
_pool.renderStatusHTML(out);
}
public long getLastParticipatingExpiration() {
long last = -1;
for (Iterator iter = _pool.getParticipatingTunnels().iterator(); iter.hasNext(); ) {
TunnelId id = (TunnelId)iter.next();
TunnelInfo info = _pool.getParticipatingTunnel(id);
if ( (info != null) && (info.getSettings().getExpiration() > last) )
last = info.getSettings().getExpiration();
}
return last;
}
}