2004-10-16 jrandom

* More aggressively fail peers if their tunnels are failing so that we
      move off them quicker.
    * Simplify some data structure serialization for reuse in the streaming
      lib, as well as add support for signing and verifying partial byte
      arrays.
    * Logging updates
This commit is contained in:
jrandom
2004-10-17 03:58:08 +00:00
committed by zzz
parent f904b012e9
commit 88693f8adc
11 changed files with 145 additions and 33 deletions

View File

@ -302,6 +302,19 @@ public class JobQueue {
}
return when;
}
/**
* When did the most recently begin job start?
*/
public long getLastJobEnd() {
long when = -1;
// not synchronized, so might b0rk if the runners are changed
for (Iterator iter = _queueRunners.values().iterator(); iter.hasNext(); ) {
long cur = ((JobQueueRunner)iter.next()).getLastEnd();
if (cur > when)
cur = when;
}
return when;
}
/**
* retrieve the most recently begin and still currently active job, or null if
* no jobs are running

View File

@ -12,6 +12,7 @@ class JobQueueRunner implements Runnable {
private Job _currentJob;
private Job _lastJob;
private long _lastBegin;
private long _lastEnd;
public JobQueueRunner(RouterContext context, int id) {
_context = context;
@ -33,6 +34,7 @@ class JobQueueRunner implements Runnable {
public void stopRunning() { _keepRunning = false; }
public void startRunning() { _keepRunning = true; }
public long getLastBegin() { return _lastBegin; }
public long getLastEnd() { return _lastEnd; }
public void run() {
long lastActive = _context.clock().now();
long jobNum = 0;
@ -88,6 +90,7 @@ class JobQueueRunner implements Runnable {
lastActive = _context.clock().now();
_lastJob = _currentJob;
_currentJob = null;
_lastEnd = lastActive;
jobNum++;
//if ( (jobNum % 10) == 0)

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.56 $ $Date: 2004/10/15 12:39:18 $";
public final static String ID = "$Revision: 1.57 $ $Date: 2004/10/16 13:00:47 $";
public final static String VERSION = "0.4.1.2";
public final static long BUILD = 6;
public final static long BUILD = 7;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION);
System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -55,6 +55,12 @@ class RouterWatchdog implements Runnable {
Job cur = _context.jobQueue().getLastJob();
if (cur != null)
_log.error("Most recent job: " + cur);
_log.error("Last job began: "
+ DataHelper.formatDuration(_context.clock().now()-_context.jobQueue().getLastJobBegin())
+ " ago");
_log.error("Last job ended: "
+ DataHelper.formatDuration(_context.clock().now()-_context.jobQueue().getLastJobEnd())
+ " ago");
_log.error("Ready and waiting jobs: " + _context.jobQueue().getReadyCount());
_log.error("Job lag: " + _context.jobQueue().getMaxLag());
_log.error("Participating tunnel count: " + _context.tunnelManager().getParticipatingCount());

View File

@ -328,12 +328,12 @@ public class TunnelInfo extends DataStructureImpl {
int i = 0;
while (cur != null) {
buf.append("\n*Hop ").append(i).append(": ").append(cur.getThisHop());
if (cur.getEncryptionKey() != null)
buf.append("\n Encryption key: ").append(cur.getEncryptionKey());
if (cur.getSigningKey() != null)
buf.append("\n Signing key: ").append(cur.getSigningKey());
if (cur.getVerificationKey() != null)
buf.append("\n Verification key: ").append(cur.getVerificationKey());
//if (cur.getEncryptionKey() != null)
// buf.append("\n Encryption key: ").append(cur.getEncryptionKey());
//if (cur.getSigningKey() != null)
// buf.append("\n Signing key: ").append(cur.getSigningKey());
//if (cur.getVerificationKey() != null)
// buf.append("\n Verification key: ").append(cur.getVerificationKey());
if (cur.getDestination() != null)
buf.append("\n Destination: ").append(cur.getDestination().calculateHash().toBase64());
if (cur.getNextHop() != null)
@ -344,7 +344,7 @@ public class TunnelInfo extends DataStructureImpl {
buf.append("\n Expiration: ").append("none");
else
buf.append("\n Expiration: ").append(new Date(cur.getSettings().getExpiration()));
buf.append("\n Ready: ").append(getIsReady());
//buf.append("\n Ready: ").append(getIsReady());
cur = cur.getNextHopInfo();
i++;
}

View File

@ -87,8 +87,12 @@ public class CapacityCalculator extends Calculator {
long failed = 0;
if (curFailed != null)
failed = curFailed.getCurrentEventCount() + curFailed.getLastEventCount();
if (failed > 0)
val -= failed * stretch;
if (failed > 0) {
if ( (period == 10*60*1000) && (curFailed.getCurrentEventCount() > 0) )
return 0.0d; // their tunnels have failed in the last 0-10 minutes
else
val -= failed * stretch;
}
if ( (period == 10*60*1000) && (curRejected.getCurrentEventCount() + curRejected.getLastEventCount() > 0) )
return 0.0d;