Skip to content
Permalink
Browse files

0003865: Improve logging readability and appropriate levels

  • Loading branch information...
erilong committed Jan 29, 2019
1 parent 61611d4 commit 1e7fa7407efb8cbeb44de40f2b1a2c9ff8c4c638
@@ -81,7 +81,7 @@ public BatchAckResult ack(final BatchAck batch) {
outgoingBatch.getStatus() != Status.IG) {
outgoingBatch.setStatus(status);
outgoingBatch.setErrorFlag(!batch.isOk());
} else if (outgoingBatch.isErrorFlag()) {
} else if (outgoingBatch.getStatus() != Status.OK) {
// clearing the error flag in case the user set the batch
// status to OK
oldStatus = outgoingBatch.getStatus();
@@ -47,6 +47,8 @@

protected Set<String> whiteList = new HashSet<String>();

protected Map<String, Long> transportErrorTimeByNode = new HashMap<String, Long>();

public ConcurrentConnectionManager(IParameterService parameterService,
IStatisticManager statisticManager) {
this.parameterService = parameterService;
@@ -138,11 +140,15 @@ synchronized public boolean reserveConnection(String nodeId, String channelId, S
reservations.put(reservationId, new Reservation(reservationId,
reservationRequest == ReservationType.SOFT ? System.currentTimeMillis()
+ timeout : Long.MAX_VALUE, reservationRequest));
transportErrorTimeByNode.remove(nodeId);
return true;
} else {
log.warn(
"Node '{}' Channel '{}' requested a {} connection, but was rejected because it already has one",
nodeId, channelId, poolId);
String message = "Node '{}' Channel '{}' requested a {} connection, but was rejected because it already has one";
if (shouldLogTransportError(nodeId)) {
log.warn(message, nodeId, channelId, poolId);
} else {
log.info(message, nodeId, channelId, poolId);
}
return false;
}
} else {
@@ -271,6 +277,16 @@ public static String getReservationIdentifier(String nodeId, String channelId) {
return this.nodeConnectionStatistics;
}

protected boolean shouldLogTransportError(String nodeId) {
long maxErrorMillis = parameterService.getLong(ParameterConstants.TRANSPORT_MAX_ERROR_MILLIS, 300000);
Long errorTime = transportErrorTimeByNode.get(nodeId);
if (errorTime == null) {
errorTime = System.currentTimeMillis();
transportErrorTimeByNode.put(nodeId, errorTime);
}
return System.currentTimeMillis() - errorTime >= maxErrorMillis;
}

public class NodeConnectionStatistics {

int numOfRejections;

0 comments on commit 1e7fa74

Please sign in to comment.
You can’t perform that action at this time.