* OCMOSJ, ElG, Streaming: log tweaks

This commit is contained in:
zzz
2012-06-21 19:10:14 +00:00
parent 39d9a25e19
commit baa89c5bbf
8 changed files with 45 additions and 48 deletions

View File

@ -157,8 +157,8 @@ class MessageInputStream extends InputStream {
*/ */
public int getReadTimeout() { return _readTimeout; } public int getReadTimeout() { return _readTimeout; }
public void setReadTimeout(int timeout) { public void setReadTimeout(int timeout) {
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.DEBUG))
_log.info("Changing read timeout from " + _readTimeout + " to " + timeout); _log.debug("Changing read timeout from " + _readTimeout + " to " + timeout);
_readTimeout = timeout; _readTimeout = timeout;
} }
@ -373,7 +373,7 @@ class MessageInputStream extends InputStream {
} }
} }
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("available(): " + numBytes + " " + toString()); _log.debug("available(): " + numBytes);
return numBytes; return numBytes;
} }

View File

@ -81,8 +81,8 @@ class MessageOutputStream extends OutputStream {
} }
public void setWriteTimeout(int ms) { public void setWriteTimeout(int ms) {
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.DEBUG))
_log.info("Changing write timeout from " + _writeTimeout + " to " + ms); _log.debug("Changing write timeout from " + _writeTimeout + " to " + ms);
_writeTimeout = ms; _writeTimeout = ms;
} }

View File

@ -100,7 +100,7 @@ public class ElGamalAESEngine {
//if (_log.shouldLog(Log.DEBUG)) _log.debug("Key is known for tag " + st); //if (_log.shouldLog(Log.DEBUG)) _log.debug("Key is known for tag " + st);
long id = _context.random().nextLong(); long id = _context.random().nextLong();
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug(id + ": Decrypting existing session encrypted with tag: " + st.toString() + ": key: " + key.toBase64() + ": " + data.length + " bytes: " + Base64.encode(data, 0, 64)); _log.debug(id + ": Decrypting existing session encrypted with tag: " + st.toString() + ": key: " + key.toBase64() + ": " + data.length + " bytes " /* + Base64.encode(data, 0, 64) */ );
decrypted = decryptExistingSession(data, key, targetPrivateKey, foundTags, usedKey, foundKey); decrypted = decryptExistingSession(data, key, targetPrivateKey, foundTags, usedKey, foundKey);
if (decrypted != null) { if (decrypted != null) {
@ -410,7 +410,7 @@ public class ElGamalAESEngine {
_context.statManager().updateFrequency("crypto.elGamalAES.encryptExistingSession"); _context.statManager().updateFrequency("crypto.elGamalAES.encryptExistingSession");
byte rv[] = encryptExistingSession(data, target, key, tagsForDelivery, currentTag, newKey, paddedSize); byte rv[] = encryptExistingSession(data, target, key, tagsForDelivery, currentTag, newKey, paddedSize);
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Existing session encrypted with tag: " + currentTag.toString() + ": " + rv.length + " bytes and key: " + key.toBase64() + ": " + Base64.encode(rv, 0, 64)); _log.debug("Existing session encrypted with tag: " + currentTag.toString() + ": " + rv.length + " bytes and key: " + key.toBase64() /* + ": " + Base64.encode(rv, 0, 64) */);
return rv; return rv;
} }

View File

@ -83,7 +83,7 @@ public class GarlicMessage extends FastI2NPMessageImpl {
public String toString() { public String toString() {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append("[GarlicMessage: "); buf.append("[GarlicMessage: ");
buf.append("\n\tData length: ").append(getData().length).append(" bytes"); buf.append("Data length: ").append(getData().length).append(" bytes");
buf.append("]"); buf.append("]");
return buf.toString(); return buf.toString();
} }

View File

@ -233,8 +233,8 @@ public class GarlicMessageBuilder {
} }
if (log.shouldLog(Log.DEBUG)) if (log.shouldLog(Log.DEBUG))
log.debug("CloveSet size for message " + msg.getUniqueId() + " is " + cloveSet.length log.debug("CloveSet (" + config.getCloveCount() + " cloves) for message " + msg.getUniqueId() + " is " + cloveSet.length
+ " and encrypted message data is " + encData.length); + " bytes and encrypted message data is " + encData.length + " bytes");
return msg; return msg;
} }
@ -268,7 +268,7 @@ public class GarlicMessageBuilder {
for (int i = 0; i < config.getCloveCount(); i++) { for (int i = 0; i < config.getCloveCount(); i++) {
GarlicConfig c = config.getClove(i); GarlicConfig c = config.getClove(i);
if (c instanceof PayloadGarlicConfig) { if (c instanceof PayloadGarlicConfig) {
log.debug("Subclove IS a payload garlic clove"); //log.debug("Subclove IS a payload garlic clove");
cloves[i] = buildClove(ctx, (PayloadGarlicConfig)c); cloves[i] = buildClove(ctx, (PayloadGarlicConfig)c);
} else { } else {
log.debug("Subclove IS NOT a payload garlic clove"); log.debug("Subclove IS NOT a payload garlic clove");

View File

@ -71,13 +71,13 @@ class GarlicMessageParser {
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("# cloves to read: " + numCloves); _log.debug("# cloves to read: " + numCloves);
for (int i = 0; i < numCloves; i++) { for (int i = 0; i < numCloves; i++) {
if (_log.shouldLog(Log.DEBUG)) //if (_log.shouldLog(Log.DEBUG))
_log.debug("Reading clove " + i); // _log.debug("Reading clove " + i);
GarlicClove clove = new GarlicClove(_context); GarlicClove clove = new GarlicClove(_context);
offset += clove.readBytes(data, offset); offset += clove.readBytes(data, offset);
set.addClove(clove); set.addClove(clove);
if (_log.shouldLog(Log.DEBUG)) //if (_log.shouldLog(Log.DEBUG))
_log.debug("After reading clove " + i); // _log.debug("After reading clove " + i);
} }
//Certificate cert = new Certificate(); //Certificate cert = new Certificate();
//offset += cert.readBytes(data, offset); //offset += cert.readBytes(data, offset);

View File

@ -88,7 +88,7 @@ class OutboundClientMessageJobHelper {
PayloadGarlicConfig dataClove, Hash from, Destination dest, TunnelInfo replyTunnel, boolean requireAck, PayloadGarlicConfig dataClove, Hash from, Destination dest, TunnelInfo replyTunnel, boolean requireAck,
LeaseSet bundledReplyLeaseSet) { LeaseSet bundledReplyLeaseSet) {
Log log = ctx.logManager().getLog(OutboundClientMessageJobHelper.class); Log log = ctx.logManager().getLog(OutboundClientMessageJobHelper.class);
if (log.shouldLog(Log.DEBUG)) if (replyToken >= 0 && log.shouldLog(Log.DEBUG))
log.debug("Reply token: " + replyToken); log.debug("Reply token: " + replyToken);
GarlicConfig config = new GarlicConfig(); GarlicConfig config = new GarlicConfig();
@ -136,20 +136,17 @@ class OutboundClientMessageJobHelper {
Log log = ctx.logManager().getLog(OutboundClientMessageJobHelper.class); Log log = ctx.logManager().getLog(OutboundClientMessageJobHelper.class);
PayloadGarlicConfig ackClove = new PayloadGarlicConfig(); PayloadGarlicConfig ackClove = new PayloadGarlicConfig();
Hash replyToTunnelRouter = null; // inbound tunnel gateway
TunnelId replyToTunnelId = null; // tunnel id on that gateway
if (replyToTunnel == null) { if (replyToTunnel == null) {
if (log.shouldLog(Log.WARN)) if (log.shouldLog(Log.WARN))
log.warn("Unable to send client message from " + from.toBase64() log.warn("Unable to send client message from " + from.toBase64()
+ ", as there are no inbound tunnels available"); + ", as there are no inbound tunnels available");
return null; return null;
} }
replyToTunnelId = replyToTunnel.getReceiveTunnelId(0); TunnelId replyToTunnelId = replyToTunnel.getReceiveTunnelId(0); // tunnel id on that gateway
replyToTunnelRouter = replyToTunnel.getPeer(0); Hash replyToTunnelRouter = replyToTunnel.getPeer(0); // inbound tunnel gateway
if (log.shouldLog(Log.DEBUG)) if (log.shouldLog(Log.DEBUG))
log.debug("Ack for the data message will come back along tunnel " + replyToTunnelId log.debug("Ack for the data message will come back along tunnel " + replyToTunnelId
+ ":\n" + replyToTunnel); + ": " + replyToTunnel);
DeliveryInstructions ackInstructions = new DeliveryInstructions(); DeliveryInstructions ackInstructions = new DeliveryInstructions();
ackInstructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_TUNNEL); ackInstructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_TUNNEL);
@ -163,8 +160,8 @@ class OutboundClientMessageJobHelper {
DeliveryStatusMessage msg = new DeliveryStatusMessage(ctx); DeliveryStatusMessage msg = new DeliveryStatusMessage(ctx);
msg.setArrival(ctx.clock().now()); msg.setArrival(ctx.clock().now());
msg.setMessageId(replyToken); msg.setMessageId(replyToken);
if (log.shouldLog(Log.DEBUG)) //if (log.shouldLog(Log.DEBUG))
log.debug("Delivery status message key: " + replyToken + " arrival: " + msg.getArrival()); // log.debug("Delivery status message key: " + replyToken + " arrival: " + msg.getArrival());
ackClove.setCertificate(Certificate.NULL_CERT); ackClove.setCertificate(Certificate.NULL_CERT);
ackClove.setDeliveryInstructions(ackInstructions); ackClove.setDeliveryInstructions(ackInstructions);
@ -175,11 +172,11 @@ class OutboundClientMessageJobHelper {
// defaults // defaults
//ackClove.setRequestAck(false); //ackClove.setRequestAck(false);
if (log.shouldLog(Log.DEBUG)) //if (log.shouldLog(Log.DEBUG))
log.debug("Delivery status message is targetting us [" // log.debug("Delivery status message is targetting us ["
+ ackClove.getRecipient().getIdentity().getHash().toBase64() // + ackClove.getRecipient().getIdentity().getHash().toBase64()
+ "] via tunnel " + replyToTunnelId.getTunnelId() + " on " // + "] via tunnel " + replyToTunnelId.getTunnelId() + " on "
+ replyToTunnelRouter.toBase64()); // + replyToTunnelRouter.toBase64());
return ackClove; return ackClove;
} }

View File

@ -150,8 +150,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
} }
} }
overallExpiration = timeoutMs + _start; overallExpiration = timeoutMs + _start;
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.DEBUG))
_log.info(getJobId() + " Default Expiration (ms): " + timeoutMs); _log.debug(getJobId() + " Default Expiration (ms): " + timeoutMs);
} }
_overallExpiration = overallExpiration; _overallExpiration = overallExpiration;
} }
@ -182,9 +182,9 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
dieFatal(); dieFatal();
return; return;
} }
if (_log.shouldLog(Log.DEBUG)) //if (_log.shouldLog(Log.DEBUG))
_log.debug(getJobId() + ": Send outbound client message job beginning" + // _log.debug(getJobId() + ": Send outbound client message job beginning" +
": preparing to search for the leaseSet for " + _toString); // ": preparing to search for the leaseSet for " + _toString);
long timeoutMs = _overallExpiration - now; long timeoutMs = _overallExpiration - now;
Hash key = _to.calculateHash(); Hash key = _to.calculateHash();
SendJob success = new SendJob(getContext()); SendJob success = new SendJob(getContext());
@ -474,8 +474,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
dieFatal(); dieFatal();
return; return;
} }
if (_log.shouldLog(Log.DEBUG)) //if (_log.shouldLog(Log.DEBUG))
_log.debug(getJobId() + ": Clove built to " + _toString); // _log.debug(getJobId() + ": Clove built to " + _toString);
long msgExpiration = _overallExpiration; // getContext().clock().now() + OVERALL_TIMEOUT_MS_DEFAULT; long msgExpiration = _overallExpiration; // getContext().clock().now() + OVERALL_TIMEOUT_MS_DEFAULT;
GarlicMessage msg = OutboundClientMessageJobHelper.createGarlicMessage(getContext(), token, GarlicMessage msg = OutboundClientMessageJobHelper.createGarlicMessage(getContext(), token,
msgExpiration, key, msgExpiration, key,
@ -494,8 +494,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
return; return;
} }
if (_log.shouldLog(Log.DEBUG)) //if (_log.shouldLog(Log.DEBUG))
_log.debug(getJobId() + ": send() - token expected " + token + " to " + _toString); // _log.debug(getJobId() + ": send() - token expected " + token + " to " + _toString);
SendSuccessJob onReply = null; SendSuccessJob onReply = null;
SendTimeoutJob onFail = null; SendTimeoutJob onFail = null;
@ -515,14 +515,14 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
} }
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug(getJobId() + ": Placing GarlicMessage into the new tunnel message bound for " _log.debug(getJobId() + ": GarlicMessage in new tunnel msg for "
+ _toString + " at " + _toString + " at "
+ _lease.getTunnelId() + " on " + _lease.getTunnelId() + " on "
+ _lease.getGateway()); + _lease.getGateway());
if (_outTunnel != null) { if (_outTunnel != null) {
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug(getJobId() + ": Sending tunnel message out " + _outTunnel.getSendTunnelId(0) + " to " _log.debug(getJobId() + ": Sending msg out " + _outTunnel.getSendTunnelId(0) + " to "
+ _toString + " at " + _toString + " at "
+ _lease.getTunnelId() + " on " + _lease.getTunnelId() + " on "
+ _lease.getGateway()); + _lease.getGateway());
@ -571,9 +571,9 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
long before = getContext().clock().now(); long before = getContext().clock().now();
getContext().tunnelDispatcher().dispatchOutbound(_msg, _outTunnel.getSendTunnelId(0), _lease.getTunnelId(), _lease.getGateway()); getContext().tunnelDispatcher().dispatchOutbound(_msg, _outTunnel.getSendTunnelId(0), _lease.getTunnelId(), _lease.getGateway());
long dispatchSendTime = getContext().clock().now() - before; long dispatchSendTime = getContext().clock().now() - before;
if (_log.shouldLog(Log.INFO)) //if (_log.shouldLog(Log.INFO))
_log.info(OutboundClientMessageOneShotJob.this.getJobId() + // _log.info(OutboundClientMessageOneShotJob.this.getJobId() +
": Dispatching message to " + _toString + " complete"); // ": Dispatching message to " + _toString + " complete");
getContext().statManager().addRateData("client.dispatchTime", getContext().clock().now() - _start, 0); getContext().statManager().addRateData("client.dispatchTime", getContext().clock().now() - _start, 0);
getContext().statManager().addRateData("client.dispatchSendTime", dispatchSendTime, 0); getContext().statManager().addRateData("client.dispatchSendTime", dispatchSendTime, 0);
} }
@ -728,8 +728,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
_clove = clove; _clove = clove;
_cloveId = _clove.getId(); _cloveId = _clove.getId();
if (_log.shouldLog(Log.DEBUG)) //if (_log.shouldLog(Log.DEBUG))
_log.debug(getJobId() + ": Built payload clove with id " + clove.getId()); // _log.debug(getJobId() + ": Built payload clove with id " + clove.getId());
return true; return true;
} }
@ -858,9 +858,9 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
public String getName() { return "Outbound client message send timeout"; } public String getName() { return "Outbound client message send timeout"; }
public void runJob() { public void runJob() {
if (_log.shouldLog(Log.INFO)) //if (_log.shouldLog(Log.INFO))
_log.info(OutboundClientMessageOneShotJob.this.getJobId() // _log.info(OutboundClientMessageOneShotJob.this.getJobId()
+ ": Soft timeout through the lease " + _lease); // + ": Soft timeout through the lease " + _lease);
// unused // unused
//_lease.setNumFailure(_lease.getNumFailure()+1); //_lease.setNumFailure(_lease.getNumFailure()+1);