forked from I2P_Developers/i2p.i2p
cleanups
This commit is contained in:
@ -49,7 +49,7 @@ public class OutNetMessage {
|
|||||||
private Set<String> _failedTransports;
|
private Set<String> _failedTransports;
|
||||||
private long _sendBegin;
|
private long _sendBegin;
|
||||||
private long _transmitBegin;
|
private long _transmitBegin;
|
||||||
private Exception _createdBy;
|
//private Exception _createdBy;
|
||||||
private final long _created;
|
private final long _created;
|
||||||
/** for debugging, contains a mapping of even name to Long (e.g. "begin sending", "handleOutbound", etc) */
|
/** for debugging, contains a mapping of even name to Long (e.g. "begin sending", "handleOutbound", etc) */
|
||||||
private HashMap<String, Long> _timestamps;
|
private HashMap<String, Long> _timestamps;
|
||||||
@ -66,10 +66,11 @@ public class OutNetMessage {
|
|||||||
public OutNetMessage(RouterContext context) {
|
public OutNetMessage(RouterContext context) {
|
||||||
_context = context;
|
_context = context;
|
||||||
_log = context.logManager().getLog(OutNetMessage.class);
|
_log = context.logManager().getLog(OutNetMessage.class);
|
||||||
setPriority(-1);
|
_priority = -1;
|
||||||
setExpiration(-1);
|
_expiration = -1;
|
||||||
//_createdBy = new Exception("Created by");
|
//_createdBy = new Exception("Created by");
|
||||||
_created = context.clock().now();
|
_created = context.clock().now();
|
||||||
|
if (_log.shouldLog(Log.INFO))
|
||||||
timestamp("Created");
|
timestamp("Created");
|
||||||
//_context.messageStateMonitor().outboundMessageAdded();
|
//_context.messageStateMonitor().outboundMessageAdded();
|
||||||
//_context.statManager().createRateStat("outNetMessage.timeToDiscard",
|
//_context.statManager().createRateStat("outNetMessage.timeToDiscard",
|
||||||
@ -78,7 +79,8 @@ public class OutNetMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stamp the message's progress
|
* Stamp the message's progress.
|
||||||
|
* Only useful if log level is INFO or DEBUG
|
||||||
*
|
*
|
||||||
* @param eventName what occurred
|
* @param eventName what occurred
|
||||||
* @return how long this message has been 'in flight'
|
* @return how long this message has been 'in flight'
|
||||||
@ -119,9 +121,9 @@ public class OutNetMessage {
|
|||||||
return _timestamps.get(eventName);
|
return _timestamps.get(eventName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ZERO;
|
return Long.valueOf(0);
|
||||||
}
|
}
|
||||||
private static final Long ZERO = Long.valueOf(0);
|
|
||||||
private void locked_initTimestamps() {
|
private void locked_initTimestamps() {
|
||||||
if (_timestamps == null) {
|
if (_timestamps == null) {
|
||||||
_timestamps = new HashMap(8);
|
_timestamps = new HashMap(8);
|
||||||
@ -129,7 +131,11 @@ public class OutNetMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Exception getCreatedBy() { return _createdBy; }
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @return null always
|
||||||
|
*/
|
||||||
|
public Exception getCreatedBy() { return null; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the router to which the message should be delivered.
|
* Specifies the router to which the message should be delivered.
|
||||||
@ -297,10 +303,11 @@ public class OutNetMessage {
|
|||||||
super.finalize();
|
super.finalize();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder buf = new StringBuilder(128);
|
StringBuilder buf = new StringBuilder(256);
|
||||||
buf.append("[OutNetMessage contains ");
|
buf.append("[OutNetMessage containing ");
|
||||||
if (_message == null) {
|
if (_message == null) {
|
||||||
buf.append("*no message*");
|
buf.append("*no message*");
|
||||||
} else {
|
} else {
|
||||||
@ -322,15 +329,19 @@ public class OutNetMessage {
|
|||||||
buf.append(" with onFailedReply job: ").append(_onFailedReply);
|
buf.append(" with onFailedReply job: ").append(_onFailedReply);
|
||||||
if (_onFailedSend != null)
|
if (_onFailedSend != null)
|
||||||
buf.append(" with onFailedSend job: ").append(_onFailedSend);
|
buf.append(" with onFailedSend job: ").append(_onFailedSend);
|
||||||
|
if (_log.shouldLog(Log.INFO)) {
|
||||||
buf.append(" {timestamps: \n");
|
buf.append(" {timestamps: \n");
|
||||||
renderTimestamps(buf);
|
renderTimestamps(buf);
|
||||||
buf.append("}");
|
buf.append("}");
|
||||||
|
}
|
||||||
buf.append("]");
|
buf.append("]");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only useful if log level is INFO or DEBUG
|
||||||
|
*/
|
||||||
private void renderTimestamps(StringBuilder buf) {
|
private void renderTimestamps(StringBuilder buf) {
|
||||||
if (_log.shouldLog(Log.INFO)) {
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
long lastWhen = -1;
|
long lastWhen = -1;
|
||||||
for (int i = 0; i < _timestampOrder.size(); i++) {
|
for (int i = 0; i < _timestampOrder.size(); i++) {
|
||||||
@ -351,7 +362,6 @@ public class OutNetMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private final static SimpleDateFormat _fmt = new SimpleDateFormat("HH:mm:ss.SSS");
|
private final static SimpleDateFormat _fmt = new SimpleDateFormat("HH:mm:ss.SSS");
|
||||||
private final static String formatDate(long when) {
|
private final static String formatDate(long when) {
|
||||||
@ -361,19 +371,21 @@ public class OutNetMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int rv = 0;
|
int rv = DataHelper.hashCode(_message);
|
||||||
rv += DataHelper.hashCode(_message);
|
rv ^= DataHelper.hashCode(_target);
|
||||||
rv += DataHelper.hashCode(_target);
|
|
||||||
// the others are pretty much inconsequential
|
// the others are pretty much inconsequential
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if(obj == null) return false;
|
//if(obj == null) return false;
|
||||||
if(!(obj instanceof OutNetMessage)) return false;
|
//if(!(obj instanceof OutNetMessage)) return false;
|
||||||
return obj == this; // two OutNetMessages are different even if they contain the same message
|
return obj == this; // two OutNetMessages are different even if they contain the same message
|
||||||
}
|
}
|
||||||
|
****/
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user