- Logging tweaks inspired by Android

- Disable reusing Deflater on Android
This commit is contained in:
zzz
2011-06-02 18:29:06 +00:00
parent 761ad38bcc
commit fe15db51d8
9 changed files with 44 additions and 8 deletions

View File

@@ -150,12 +150,15 @@ public class DatabaseStoreMessage extends I2NPMessageImpl {
int len = Hash.HASH_LENGTH + 1 + 4; // key+type+replyToken
if (_replyToken > 0)
len += 4 + Hash.HASH_LENGTH; // replyTunnel+replyGateway
if (_dbEntry.getType() == DatabaseEntry.KEY_TYPE_LEASESET) {
int type = _dbEntry.getType();
if (type == DatabaseEntry.KEY_TYPE_LEASESET) {
_byteCache = _dbEntry.toByteArray();
} else if (_dbEntry.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
} else if (type == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
byte uncompressed[] = _dbEntry.toByteArray();
_byteCache = DataHelper.compress(uncompressed);
len += 2;
} else {
throw new IllegalStateException("Invalid key type " + type);
}
len += _byteCache.length;
return len;
@@ -166,7 +169,7 @@ public class DatabaseStoreMessage extends I2NPMessageImpl {
if (_dbEntry == null) throw new I2NPMessageException("Missing entry");
int type = _dbEntry.getType();
if (type != DatabaseEntry.KEY_TYPE_LEASESET && type != DatabaseEntry.KEY_TYPE_ROUTERINFO)
throw new I2NPMessageException("Invalid key type");
throw new I2NPMessageException("Invalid key type " + type);
// Use the hash of the DatabaseEntry
System.arraycopy(getKey().getData(), 0, out, curIndex, Hash.HASH_LENGTH);

View File

@@ -311,8 +311,11 @@ public class Router {
}
public RouterInfo getRouterInfo() { return _routerInfo; }
public void setRouterInfo(RouterInfo info) {
_routerInfo = info;
if (_log.shouldLog(Log.INFO))
_log.info("setRouterInfo() : " + info, new Exception("I did it"));
if (info != null)
_context.jobQueue().addJob(new PersistRouterInfoJob(_context));
}
@@ -614,6 +617,10 @@ public class Router {
}
}
// hard and ugly
if (System.getProperty("wrapper.version") != null)
_log.log(Log.CRIT, "Restarting with new router identity");
else
_log.log(Log.CRIT, "Shutting down because old router identity was invalid - restart I2P");
finalShutdown(EXIT_HARD_RESTART);
}

View File

@@ -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 = 15;
public final static long BUILD = 16;
/** for example "-test" */
public final static String EXTRA = "";

View File

@@ -65,7 +65,7 @@ public class PublishLocalRouterInfoJob extends JobImpl {
try {
getContext().netDb().publish(ri);
} catch (IllegalArgumentException iae) {
_log.log(Log.CRIT, "Error publishing our identity - corrupt?", iae);
_log.log(Log.CRIT, "Error publishing our identity - corrupt? Restart required", iae);
getContext().router().rebuildNewIdentity();
}
} catch (DataFormatException dfe) {