AMQ-4067: Prefix thread names with ActiveMQ

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1387989 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Claus Ibsen 2012-09-20 12:02:04 +00:00
parent 6f2ac637cd
commit c6595066e9
2 changed files with 33 additions and 5 deletions

View File

@ -1181,7 +1181,7 @@ public class BrokerService implements Service {
public TaskRunnerFactory getTaskRunnerFactory() {
if (this.taskRunnerFactory == null) {
this.taskRunnerFactory = new TaskRunnerFactory("BrokerService["+getBrokerName()+"] Task", getTaskRunnerPriority(), true, 1000,
this.taskRunnerFactory = new TaskRunnerFactory("ActiveMQ BrokerService["+getBrokerName()+"] Task", getTaskRunnerPriority(), true, 1000,
isDedicatedTaskRunner());
}
return this.taskRunnerFactory;
@ -2550,7 +2550,7 @@ public class BrokerService implements Service {
@Override
public Thread newThread(Runnable runnable) {
this.i++;
Thread thread = new Thread(runnable, "BrokerService.worker." + this.i);
Thread thread = new Thread(runnable, "ActiveMQ BrokerService.worker." + this.i);
thread.setDaemon(true);
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override

View File

@ -94,6 +94,11 @@ public abstract class AbstractInactivityMonitor extends TransportFilter {
lastRunTime = now;
readCheck();
}
@Override
public String toString() {
return "ReadChecker";
}
};
private boolean allowReadCheck(long elapsed) {
@ -111,6 +116,11 @@ public abstract class AbstractInactivityMonitor extends TransportFilter {
lastRunTime = now;
writeCheck();
}
@Override
public String toString() {
return "WriteChecker";
}
};
public AbstractInactivityMonitor(Transport next, WireFormat wireFormat) {
@ -142,6 +152,9 @@ public abstract class AbstractInactivityMonitor extends TransportFilter {
}
ASYNC_TASKS.execute(new Runnable() {
public void run() {
if (LOG.isDebugEnabled()) {
LOG.debug("Running {}", this);
}
if (monitorStarted.get()) {
try {
// If we can't get the lock it means another write beat us into the
@ -159,6 +172,11 @@ public abstract class AbstractInactivityMonitor extends TransportFilter {
}
}
}
}
@Override
public String toString() {
return "WriteCheck[" + getRemoteAddress() + "]";
};
});
} else {
@ -185,7 +203,15 @@ public abstract class AbstractInactivityMonitor extends TransportFilter {
}
ASYNC_TASKS.execute(new Runnable() {
public void run() {
if (LOG.isDebugEnabled()) {
LOG.debug("Running {}", this);
}
onException(new InactivityIOException("Channel was inactive for too (>" + readCheckTime + ") long: "+next.getRemoteAddress()));
}
@Override
public String toString() {
return "ReadCheck[" + getRemoteAddress() + "]";
};
});
} else {
@ -332,8 +358,8 @@ public abstract class AbstractInactivityMonitor extends TransportFilter {
synchronized(AbstractInactivityMonitor.class) {
if( CHECKER_COUNTER == 0 ) {
ASYNC_TASKS = createExecutor();
READ_CHECK_TIMER = new Timer("InactivityMonitor ReadCheck",true);
WRITE_CHECK_TIMER = new Timer("InactivityMonitor WriteCheck",true);
READ_CHECK_TIMER = new Timer("ActiveMQ InactivityMonitor ReadCheckTimer",true);
WRITE_CHECK_TIMER = new Timer("ActiveMQ InactivityMonitor WriteCheckTimer",true);
}
CHECKER_COUNTER++;
if (readCheckTime > 0) {
@ -374,13 +400,15 @@ public abstract class AbstractInactivityMonitor extends TransportFilter {
private ThreadFactory factory = new ThreadFactory() {
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable, "InactivityMonitor Async Task: "+runnable);
Thread thread = new Thread(runnable, "ActiveMQ InactivityMonitor Worker");
thread.setDaemon(true);
return thread;
}
};
private ThreadPoolExecutor createExecutor() {
// TODO: This value of 10 seconds seems to low, see discussion at
// http://activemq.2283324.n4.nabble.com/InactivityMonitor-Creating-too-frequent-threads-tp4656752.html;cid=1348142445209-351
ThreadPoolExecutor exec = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 10, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), factory);
exec.allowCoreThreadTimeOut(true);
return exec;