Skip to content

Commit

Permalink
[SMX4-791]Make allowCoreThreadTimeOut name consistent across mbeans a…
Browse files Browse the repository at this point in the history
…nd properties

git-svn-id: https://svn.apache.org/repos/asf/servicemix/utils/trunk@1086857 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
ffang committed Mar 30, 2011
1 parent 0237782 commit 1fd0400
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
Expand Up @@ -31,7 +31,7 @@ public interface ExecutorFactory {
* Configuration properties than can be passed along when creating an executor.
* Every ExecutorFactory implementation can support one or more of these options, ignoring the unsupported ones.
*/
String ALLOW_CORE_THREADS_TIMEOUT = ExecutorFactory.class.getName() + ".AllowCoreThreadsTimeout";
String ALLOW_CORE_THREADS_TIMEOUT = ExecutorFactory.class.getName() + ".AllowCoreThreadTimeOut";
String BYPASS_IF_SYNCHRONOUS = ExecutorFactory.class.getName() + ".BypassIfSynchronous";
String CORE_POOL_SIZE = ExecutorFactory.class.getName() + ".CorePoolSize";
String KEEP_ALIVE_TIME = ExecutorFactory.class.getName() + ".KeepAliveTime";
Expand Down
Expand Up @@ -56,7 +56,7 @@ public class ExecutorConfig {

private Long shutdownDelay;

private Boolean allowCoreThreadsTimeout;
private Boolean allowCoreThreadTimeOut;

private Boolean bypassIfSynchronous;

Expand All @@ -80,7 +80,7 @@ public ExecutorConfig(boolean isDefaultConfig, ExecutorConfig parent) {
setShutdownDelay(DEFAULT_SHUTDOWN_DELAY);
setThreadDaemon(DEFAULT_THREAD_DAEMON);
setThreadPriority(DEFAULT_THREAD_PRIORITY);
setAllowCoreThreadsTimeout(DEFAULT_ALLOW_CORE_THREAD_TIMEOUT);
setAllowCoreThreadTimeOut(DEFAULT_ALLOW_CORE_THREAD_TIMEOUT);
setBypassIfSynchronous(DEFAULT_BYPASS_IF_SYNCHRONOUS);
setCorePoolSize(DEFAULT_CORE_POOL_SIZE);
setKeepAliveTime(DEFAULT_KEEP_ALIVE_TIME);
Expand Down Expand Up @@ -194,18 +194,18 @@ public void setShutdownDelay(Long shutdownDelay) {
}

/**
* @return the allowCoreThreadsTimeout
* @return the allowCoreThreadTimeOut
*/
public Boolean isAllowCoreThreadsTimeout() {
return getParent() != null && allowCoreThreadsTimeout == null ? getParent().isAllowCoreThreadsTimeout() : allowCoreThreadsTimeout;
public Boolean isAllowCoreThreadTimeOut() {
return getParent() != null && allowCoreThreadTimeOut == null ? getParent().isAllowCoreThreadTimeOut() : allowCoreThreadTimeOut;
}

/**
* @param allowCoreThreadsTimeout
* the allowCoreThreadsTimeout to set
* @param allowCoreThreadTimeOut
* the allowCoreThreadTimeOut to set
*/
public void setAllowCoreThreadsTimeout(Boolean allowCoreThreadsTimeout) {
this.allowCoreThreadsTimeout = allowCoreThreadsTimeout;
public void setAllowCoreThreadTimeOut(Boolean allowCoreThreadTimeOut) {
this.allowCoreThreadTimeOut = allowCoreThreadTimeOut;
}

/**
Expand Down Expand Up @@ -249,7 +249,7 @@ public static ExecutorConfig create(Map<String, Object> options, ExecutorConfig
result.setKeepAliveTime(converter.as(options.get(KEEP_ALIVE_TIME), Long.class));
result.setShutdownDelay(converter.as(options.get(SHUTDOWN_DELAY), Long.class));

result.setAllowCoreThreadsTimeout(converter.as(options.get(ALLOW_CORE_THREADS_TIMEOUT), Boolean.class));
result.setAllowCoreThreadTimeOut(converter.as(options.get(ALLOW_CORE_THREADS_TIMEOUT), Boolean.class));
result.setBypassIfSynchronous(converter.as(options.get(BYPASS_IF_SYNCHRONOUS), Boolean.class));
result.setThreadDaemon(converter.as(options.get(THREAD_DAEMON), Boolean.class));

Expand Down
Expand Up @@ -120,7 +120,7 @@ protected ThreadPoolExecutor createService(String id, ExecutorConfig config) {
ThreadPoolExecutor service = new ThreadPoolExecutor(config.getCorePoolSize(),
config.getMaximumPoolSize() < 0 ? Integer.MAX_VALUE : config.getMaximumPoolSize(), config
.getKeepAliveTime(), TimeUnit.MILLISECONDS, queue, factory, handler);
if (config.isAllowCoreThreadsTimeout()) {
if (config.isAllowCoreThreadTimeOut()) {
try {
Method mth = service.getClass().getMethod("allowCoreThreadTimeOut", new Class[]{boolean.class});
mth.invoke(service, new Object[]{Boolean.TRUE});
Expand Down
Expand Up @@ -102,7 +102,7 @@ public int getQueueSize() {
return this.internalExecutor != null ? this.internalExecutor.size() : 0;
}

public boolean isAllowCoreThreadTimeout() {
public boolean isAllowCoreThreadTimeOut() {
if (this.internalExecutor != null) {
ThreadPoolExecutor executor = this.internalExecutor.getThreadPoolExecutor();
try {
Expand Down
Expand Up @@ -44,7 +44,7 @@ public interface ManagedExecutorMBean {

int getQueueSize();

boolean isAllowCoreThreadTimeout();
boolean isAllowCoreThreadTimeOut();

long getNumberOfRejectedExecutions();

Expand Down
Expand Up @@ -49,7 +49,7 @@ public void testCreateMethod() {
assertEquals(new Long(3000), config.getKeepAliveTime());
assertEquals(new Long(9000), config.getShutdownDelay());
assertEquals(new Integer(9), config.getThreadPriority());
assertEquals(true, config.isAllowCoreThreadsTimeout());
assertEquals(true, config.isAllowCoreThreadTimeOut());
assertEquals(false, config.isBypassIfSynchronous());
assertEquals(true, config.isThreadDaemon());
}
Expand All @@ -74,7 +74,7 @@ public void testCreateMethodWithStringValues() {
assertEquals(new Long(3000), config.getKeepAliveTime());
assertEquals(new Long(9000), config.getShutdownDelay());
assertEquals(new Integer(9), config.getThreadPriority());
assertEquals(true, config.isAllowCoreThreadsTimeout());
assertEquals(true, config.isAllowCoreThreadTimeOut());
assertEquals(false, config.isBypassIfSynchronous());
assertEquals(true, config.isThreadDaemon());
}
Expand All @@ -99,7 +99,7 @@ public void testCreateMethodIllegalValuesIgnored() {
assertEquals(new Long(3000), config.getKeepAliveTime());
assertEquals(new Long(9000), config.getShutdownDelay());
assertEquals(new Integer(9), config.getThreadPriority());
assertEquals(true, config.isAllowCoreThreadsTimeout());
assertEquals(true, config.isAllowCoreThreadTimeOut());
assertEquals(false, config.isBypassIfSynchronous());
assertEquals(true, config.isThreadDaemon());
}
Expand Down
Expand Up @@ -41,7 +41,7 @@ public void setupExecutorFactory() {
defaultConfig.setCorePoolSize(1);
defaultConfig.setMaximumPoolSize(2);
defaultConfig.setQueueSize(3);
defaultConfig.setAllowCoreThreadsTimeout(true);
defaultConfig.setAllowCoreThreadTimeOut(true);
factory.setDefaultConfig(defaultConfig);
}

Expand Down

0 comments on commit 1fd0400

Please sign in to comment.