Lowered the shared resource explosion detection threshold and changed the log level from warn to debug just in case it's false positive

This commit is contained in:
Trustin Lee 2009-02-13 13:28:35 +00:00
parent 3d355eb48a
commit 6370d06fb3
2 changed files with 12 additions and 9 deletions

View File

@ -89,7 +89,8 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(MemoryAwareThreadPoolExecutor.class);
private static final int MISUSE_WARNING_THRESHOLD = 1024;
// I'd say 64 active event thread pools are obvious misuse.
private static final int MISUSE_WARNING_THRESHOLD = 64;
private static final AtomicInteger activeInstances = new AtomicInteger();
private static final AtomicBoolean loggedMisuseWarning = new AtomicBoolean();
@ -205,8 +206,9 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor {
int activeInstances = MemoryAwareThreadPoolExecutor.activeInstances.incrementAndGet();
if (activeInstances >= MISUSE_WARNING_THRESHOLD &&
loggedMisuseWarning.compareAndSet(false, true)) {
logger.warn(
"There are too many active " + getClass().getSimpleName() +
logger.debug(
"There are too many active " +
MemoryAwareThreadPoolExecutor.class.getSimpleName() +
" instances (" + activeInstances + ") - you should share " +
"the small number of instances to avoid excessive resource " +
"consumption.");

View File

@ -53,7 +53,8 @@ public class HashedWheelTimer implements Timer {
InternalLoggerFactory.getInstance(HashedWheelTimer.class);
private static final AtomicInteger id = new AtomicInteger();
private static final int MISUSE_WARNING_THRESHOLD = 1024;
// I'd say 64 active timer threads are obvious misuse.
private static final int MISUSE_WARNING_THRESHOLD = 64;
private static final AtomicInteger activeInstances = new AtomicInteger();
private static final AtomicBoolean loggedMisuseWarning = new AtomicBoolean();
@ -134,11 +135,11 @@ public class HashedWheelTimer implements Timer {
int activeInstances = HashedWheelTimer.activeInstances.incrementAndGet();
if (activeInstances >= MISUSE_WARNING_THRESHOLD &&
loggedMisuseWarning.compareAndSet(false, true)) {
logger.warn(
"There are too many active " + getClass().getSimpleName() +
" instances (" + activeInstances + ") - you should share " +
"the small number of instances to avoid excessive resource " +
"consumption.");
logger.debug(
"There are too many active " +
HashedWheelTimer.class.getSimpleName() + " instances (" +
activeInstances + ") - you should share the small number " +
"of instances to avoid excessive resource consumption.");
}
}