Skip to content
Permalink
Browse files

0004085: Logging of data gaps in router service can use too much memory

  • Loading branch information...
erilong committed Aug 29, 2019
1 parent 567dcb2 commit ee4c03c9ad083588e2ccba73da094733a65de68b
@@ -1003,7 +1003,7 @@ protected long selectDataAndRoute(ProcessInfo processInfo, ChannelRouterContext
+ "totalDataRoutedCount={}, totalDataEventCount={}, startDataId={}, endDataId={}, dataReadCount={}, peekAheadFillCount={}, dataGaps={}",
new Object[] { context.getChannel().getChannelId(), ((System.currentTimeMillis()-startTime) / 1000), totalDataCount, totalDataEventCount, context.getStartDataId(),
context.getEndDataId(), context.getDataReadCount(), context.getPeekAheadFillCount(),
StringUtils.abbreviate(context.getDataGaps().toString(), MAX_LOGGING_LENGTH)
FormatUtils.abbreviateForLogging(context.getDataGaps(), MAX_LOGGING_LENGTH)
});
ts = System.currentTimeMillis();
}
@@ -358,6 +358,30 @@ public static String abbreviateForLogging(String value) {
return StringUtils.abbreviate(value, MAX_CHARS_TO_LOG);
}

/**
* Convert list of objects to abbreviated string for logging, making efficient use of memory for large lists
*/
@SuppressWarnings("rawtypes")
public static String abbreviateForLogging(List list, int maxCharsToLog) {
StringBuilder sb = new StringBuilder(maxCharsToLog);
sb.append("[");
boolean isFirst = true;
for (Object obj : list) {
if (isFirst) {
isFirst = false;
} else {
sb.append(", ");
}
sb.append(obj.toString());
if (sb.length() >= maxCharsToLog) {
sb.append("...");
break;
}
}
sb.append("]");
return sb.toString();
}

public static Date parseDate(String str, String[] parsePatterns) {
return parseDate(str, parsePatterns, null);
}

0 comments on commit ee4c03c

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