* PersistentDataStore: Write out 300 records every 10 min

rather than 1 every 10 sec;
      Don't store leasesets to disk or read them in
    * Combine rates for pools with the same length setting
      in the new tunnel build algorithm
    * Clarify a log message in the UpdateHandler
This commit is contained in:
zzz
2008-02-13 21:42:09 +00:00
parent d2f3a262db
commit 69cc0afd1b
5 changed files with 52 additions and 15 deletions

View File

@ -162,7 +162,8 @@ public class UpdateHandler {
_status = "<b>Update verified</b><br />Restarting<br />"; _status = "<b>Update verified</b><br />Restarting<br />";
restart(); restart();
} else { } else {
_log.log(Log.CRIT, "Update was INVALID - have you changed your keys?"); _log.log(Log.CRIT, "Update was INVALID - signing key is not trusted!");
_status = "<b>Update signing key invalid</b><br />";
System.setProperty("net.i2p.router.web.UpdateHandler.updateInProgress", "false"); System.setProperty("net.i2p.router.web.UpdateHandler.updateInProgress", "false");
} }
} }

View File

@ -1,3 +1,11 @@
2008-02-17 zzz
* PersistentDataStore: Write out 300 records every 10 min
rather than 1 every 10 sec;
Don't store leasesets to disk or read them in
* Combine rates for pools with the same length setting
in the new tunnel build algorithm
* Clarify a log message in the UpdateHandler
2008-02-13 zzz 2008-02-13 zzz
* Make graphs clickable to get larger graphs * Make graphs clickable to get larger graphs
* Change SimpleTimer CRIT to a WARN, increase threshold * Change SimpleTimer CRIT to a WARN, increase threshold

View File

@ -17,7 +17,7 @@ import net.i2p.CoreVersion;
public class RouterVersion { public class RouterVersion {
public final static String ID = "$Revision: 1.548 $ $Date: 2008-02-10 15:00:00 $"; public final static String ID = "$Revision: 1.548 $ $Date: 2008-02-10 15:00:00 $";
public final static String VERSION = "0.6.1.31"; public final static String VERSION = "0.6.1.31";
public final static long BUILD = 2; public final static long BUILD = 3;
public static void main(String args[]) { public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID); System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -66,7 +66,9 @@ class PersistentDataStore extends TransientDataStore {
public void put(Hash key, DataStructure data) { public void put(Hash key, DataStructure data) {
if ( (data == null) || (key == null) ) return; if ( (data == null) || (key == null) ) return;
super.put(key, data); super.put(key, data);
_writer.queue(key, data); // Don't bother writing LeaseSets to disk
if (data instanceof RouterInfo)
_writer.queue(key, data);
} }
public int countLeaseSets() { public int countLeaseSets() {
@ -103,7 +105,7 @@ class PersistentDataStore extends TransientDataStore {
} }
public String getName() { return "Remove Key"; } public String getName() { return "Remove Key"; }
public void runJob() { public void runJob() {
_log.info("Removing key " + _key, getAddedBy()); _log.info("Removing key " + _key /* , getAddedBy() */);
try { try {
File dbDir = getDbDir(); File dbDir = getDbDir();
removeFile(_key, dbDir); removeFile(_key, dbDir);
@ -113,6 +115,9 @@ class PersistentDataStore extends TransientDataStore {
} }
} }
/*
* Queue up writes, write up to 300 files every 10 minutes
*/
private class Writer implements Runnable { private class Writer implements Runnable {
private Map _keys; private Map _keys;
private List _keyOrder; private List _keyOrder;
@ -137,12 +142,15 @@ class PersistentDataStore extends TransientDataStore {
public void run() { public void run() {
Hash key = null; Hash key = null;
DataStructure data = null; DataStructure data = null;
int count = 0;
while (true) { // hmm, probably want a shutdown handle... though this is a daemon thread while (true) { // hmm, probably want a shutdown handle... though this is a daemon thread
try { try {
synchronized (_keys) { synchronized (_keys) {
if (_keyOrder.size() <= 0) { if (_keyOrder.size() <= 0) {
count = 0;
_keys.wait(); _keys.wait();
} else { } else {
count++;
key = (Hash)_keyOrder.remove(0); key = (Hash)_keyOrder.remove(0);
data = (DataStructure)_keys.remove(key); data = (DataStructure)_keys.remove(key);
} }
@ -153,7 +161,10 @@ class PersistentDataStore extends TransientDataStore {
write(key, data); write(key, data);
key = null; key = null;
data = null; data = null;
try { Thread.sleep(10*1000); } catch (InterruptedException ie) {} if (count >= 300)
count = 0;
if (count == 0)
try { Thread.sleep(10*60*1000); } catch (InterruptedException ie) {}
} }
} }
} }
@ -227,6 +238,7 @@ class PersistentDataStore extends TransientDataStore {
int routerCount = 0; int routerCount = 0;
try { try {
File dbDir = getDbDir(); File dbDir = getDbDir();
/****
if (getContext().router().getUptime() < 10*60*1000) { if (getContext().router().getUptime() < 10*60*1000) {
File leaseSetFiles[] = dbDir.listFiles(LeaseSetFilter.getInstance()); File leaseSetFiles[] = dbDir.listFiles(LeaseSetFilter.getInstance());
if (leaseSetFiles != null) { if (leaseSetFiles != null) {
@ -237,6 +249,7 @@ class PersistentDataStore extends TransientDataStore {
} }
} }
} }
****/
File routerInfoFiles[] = dbDir.listFiles(RouterInfoFilter.getInstance()); File routerInfoFiles[] = dbDir.listFiles(RouterInfoFilter.getInstance());
if (routerInfoFiles != null) { if (routerInfoFiles != null) {
routerCount += routerInfoFiles.length; routerCount += routerInfoFiles.length;
@ -259,6 +272,7 @@ class PersistentDataStore extends TransientDataStore {
} }
} }
/****
private class ReadLeaseJob extends JobImpl { private class ReadLeaseJob extends JobImpl {
private File _leaseFile; private File _leaseFile;
private Hash _key; private Hash _key;
@ -313,6 +327,7 @@ class PersistentDataStore extends TransientDataStore {
} }
} }
} }
****/
private class ReadRouterJob extends JobImpl { private class ReadRouterJob extends JobImpl {
private File _routerFile; private File _routerFile;

View File

@ -40,7 +40,6 @@ public class TunnelPool {
private long _lastRateUpdate; private long _lastRateUpdate;
private long _lastLifetimeProcessed; private long _lastLifetimeProcessed;
private final String _rateName; private final String _rateName;
private final String _buildStatName;
private static final int TUNNEL_LIFETIME = 10*60*1000; private static final int TUNNEL_LIFETIME = 10*60*1000;
public TunnelPool(RouterContext ctx, TunnelPoolManager mgr, TunnelPoolSettings settings, TunnelPeerSelector sel) { public TunnelPool(RouterContext ctx, TunnelPoolManager mgr, TunnelPoolSettings settings, TunnelPeerSelector sel) {
@ -61,9 +60,6 @@ public class TunnelPool {
_rateName = "tunnel.Bps." + _rateName = "tunnel.Bps." +
(_settings.isExploratory() ? "exploratory" : _settings.getDestinationNickname()) + (_settings.isExploratory() ? "exploratory" : _settings.getDestinationNickname()) +
(_settings.isInbound() ? ".in" : ".out"); (_settings.isInbound() ? ".in" : ".out");
_buildStatName = "tunnel.build." +
(_settings.isExploratory() ? "exploratory" : _settings.getDestinationNickname()) +
(_settings.isInbound() ? ".in" : ".out");
refreshSettings(); refreshSettings();
} }
@ -87,9 +83,6 @@ public class TunnelPool {
_context.statManager().createRateStat(_rateName, _context.statManager().createRateStat(_rateName,
"Tunnel Bandwidth", "Tunnels", "Tunnel Bandwidth", "Tunnels",
new long[] { 5*60*1000l }); new long[] { 5*60*1000l });
_context.statManager().createRateStat(_buildStatName,
"Tunnel Build Frequency", "Tunnels",
new long[] { TUNNEL_LIFETIME });
} }
public void shutdown() { public void shutdown() {
@ -460,6 +453,17 @@ public class TunnelPool {
public long getLifetimeProcessed() { return _lifetimeProcessed; } public long getLifetimeProcessed() { return _lifetimeProcessed; }
/**
* Keep a separate stat for each type, direction, and length of tunnel.
*/
private final String buildRateName() {
if (_settings.isExploratory())
return "tunnel.buildRatio.exploratory." + (_settings.isInbound() ? "in" : "out");
else
return "tunnel.buildRatio.l" + _settings.getLength() + "v" + _settings.getLengthVariance() +
(_settings.isInbound() ? ".in" : ".out");
}
/** /**
* Gather the data to see how many tunnels to build, and then actually compute that value (delegated to * Gather the data to see how many tunnels to build, and then actually compute that value (delegated to
* the countHowManyToBuild function below) * the countHowManyToBuild function below)
@ -491,8 +495,17 @@ public class TunnelPool {
* *
**/ **/
// Compute the average time it takes us to build a single tunnel of this type.
int avg = 0; int avg = 0;
RateStat rs = _context.statManager().getRate(_buildStatName); RateStat rs = _context.statManager().getRate(buildRateName());
if (rs == null) {
// Create the RateStat here rather than at the top because
// the user could change the length settings while running
_context.statManager().createRateStat(buildRateName(),
"Tunnel Build Frequency", "Tunnels",
new long[] { TUNNEL_LIFETIME });
rs = _context.statManager().getRate(buildRateName());
}
if (rs != null) { if (rs != null) {
Rate r = rs.getRate(TUNNEL_LIFETIME); Rate r = rs.getRate(TUNNEL_LIFETIME);
if (r != null) if (r != null)
@ -568,7 +581,7 @@ public class TunnelPool {
+ " soon " + expireSoon + " later " + expireLater + " soon " + expireSoon + " later " + expireLater
+ " std " + wanted + " inProgress " + inProgress + " fallback " + fallback + " std " + wanted + " inProgress " + inProgress + " fallback " + fallback
+ " for " + toString()); + " for " + toString());
_context.statManager().addRateData(_buildStatName, rv + inProgress, 0); _context.statManager().addRateData(buildRateName(), rv + inProgress, 0);
return rv; return rv;
} }
@ -622,7 +635,7 @@ public class TunnelPool {
int rv = countHowManyToBuild(allowZeroHop, expire30s, expire90s, expire150s, expire210s, expire270s, int rv = countHowManyToBuild(allowZeroHop, expire30s, expire90s, expire150s, expire210s, expire270s,
expireLater, wanted, inProgress, fallback); expireLater, wanted, inProgress, fallback);
_context.statManager().addRateData(_buildStatName, (rv > 0 || inProgress > 0) ? 1 : 0, 0); _context.statManager().addRateData(buildRateName(), (rv > 0 || inProgress > 0) ? 1 : 0, 0);
return rv; return rv;
} }