You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2020/10/29 23:22:01 UTC
[geode] branch develop updated: GEODE-8521: Cleanup
CoreLoggingExecutors constructors (#5687)
This is an automated email from the ASF dual-hosted git repository.
klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new a9d346f GEODE-8521: Cleanup CoreLoggingExecutors constructors (#5687)
a9d346f is described below
commit a9d346f6581cd2861a9f9870574a441c9c439d36
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Thu Oct 29 16:20:56 2020 -0700
GEODE-8521: Cleanup CoreLoggingExecutors constructors (#5687)
---
.../alerting/internal/ClusterAlertMessaging.java | 2 +-
.../geode/cache/client/internal/PoolImpl.java | 10 +-
.../cache/client/internal/QueueManagerImpl.java | 2 +-
.../internal/pooling/ConnectionManagerImpl.java | 2 +-
.../internal/ClusterOperationExecutors.java | 55 ++--
.../internal/FunctionExecutionPooledExecutor.java | 336 ++++++++-------------
.../distributed/internal/InternalLocator.java | 10 +-
.../distributed/internal/LocatorLoadSnapshot.java | 2 +-
.../internal/PooledExecutorWithDMStats.java | 214 ++++++-------
.../internal/SerialQueuedExecutorWithDMStats.java | 34 ++-
.../ScheduledThreadPoolExecutorWithKeepAlive.java | 127 ++++----
.../apache/geode/internal/cache/DiskStoreImpl.java | 6 +-
.../geode/internal/cache/DiskStoreMonitor.java | 2 +-
.../apache/geode/internal/cache/ExpiryTask.java | 5 +-
.../geode/internal/cache/GemFireCacheImpl.java | 13 +-
.../geode/internal/cache/PRQueryProcessor.java | 2 +-
.../geode/internal/cache/PartitionedRegion.java | 2 +-
.../internal/cache/control/HeapMemoryMonitor.java | 2 +-
.../cache/control/InternalResourceManager.java | 8 +-
.../geode/internal/cache/eviction/HeapEvictor.java | 5 +-
.../cache/eviction/LRUListWithAsyncSorting.java | 2 +-
.../cache/tier/InternalClientMembership.java | 5 +-
.../internal/cache/tier/sockets/AcceptorImpl.java | 26 +-
...currentParallelGatewaySenderEventProcessor.java | 4 +-
.../wan/parallel/ParallelGatewaySenderQueue.java | 2 +-
...oncurrentSerialGatewaySenderEventProcessor.java | 4 +-
.../serial/SerialGatewaySenderEventProcessor.java | 5 +-
.../internal/logging/CoreLoggingExecutors.java | 238 +++++++--------
.../apache/geode/internal/tcp/ConnectionTable.java | 7 +-
.../internal/SystemManagementService.java | 4 +-
.../internal/executors/LoggingExecutors.java | 110 +++----
.../internal/executors/LoggingThreadFactory.java | 15 +-
.../internal/membership/gms/GMSMembership.java | 2 +-
.../membership/gms/fd/GMSHealthMonitor.java | 2 +-
.../membership/gms/membership/GMSJoinLeave.java | 5 +-
35 files changed, 589 insertions(+), 681 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/alerting/internal/ClusterAlertMessaging.java b/geode-core/src/main/java/org/apache/geode/alerting/internal/ClusterAlertMessaging.java
index e0ddadf..f03f343 100644
--- a/geode-core/src/main/java/org/apache/geode/alerting/internal/ClusterAlertMessaging.java
+++ b/geode-core/src/main/java/org/apache/geode/alerting/internal/ClusterAlertMessaging.java
@@ -48,7 +48,7 @@ public class ClusterAlertMessaging implements AlertMessaging {
this(system,
system.getDistributionManager(),
new AlertListenerMessageFactory(),
- newFixedThreadPool("AlertingMessaging Processor", true, 1),
+ newFixedThreadPool(1, "AlertingMessaging Processor", true),
LOGGER::warn);
}
diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/PoolImpl.java b/geode-core/src/main/java/org/apache/geode/cache/client/internal/PoolImpl.java
index 5695f4e..2fe2365 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/PoolImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/PoolImpl.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.cache.client.internal;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import java.net.InetSocketAddress;
@@ -26,7 +27,6 @@ import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@@ -335,8 +335,8 @@ public class PoolImpl implements InternalPool {
}
final String timerName = "poolTimer-" + getName() + "-";
- backgroundProcessor = CoreLoggingExecutors.newScheduledThreadPool(timerName,
- BACKGROUND_TASK_POOL_SIZE, BACKGROUND_TASK_POOL_KEEP_ALIVE, threadMonitoring);
+ backgroundProcessor = CoreLoggingExecutors.newScheduledThreadPool(BACKGROUND_TASK_POOL_SIZE,
+ BACKGROUND_TASK_POOL_KEEP_ALIVE, MILLISECONDS, timerName, threadMonitoring);
source.start(this);
connectionFactory.start(backgroundProcessor);
endpointManager.addListener(new InstantiatorRecoveryListener(backgroundProcessor, this));
@@ -360,7 +360,7 @@ public class PoolImpl implements InternalPool {
if (statisticInterval > 0 && distributedSystem.getConfig().getStatisticSamplingEnabled()) {
backgroundProcessor.scheduleWithFixedDelay(new PublishClientStatsTask(), statisticInterval,
- statisticInterval, TimeUnit.MILLISECONDS);
+ statisticInterval, MILLISECONDS);
}
// LOG: changed from config to info
logger.info("Pool {} started with multiuser-authentication={}",
@@ -600,7 +600,7 @@ public class PoolImpl implements InternalPool {
try {
if (backgroundProcessor != null) {
backgroundProcessor.shutdown();
- if (!backgroundProcessor.awaitTermination(SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS)) {
+ if (!backgroundProcessor.awaitTermination(SHUTDOWN_TIMEOUT, MILLISECONDS)) {
logger.warn("Timeout waiting for background tasks to complete.");
}
}
diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/QueueManagerImpl.java b/geode-core/src/main/java/org/apache/geode/cache/client/internal/QueueManagerImpl.java
index 12b7d99..212d2de 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/QueueManagerImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/QueueManagerImpl.java
@@ -284,7 +284,7 @@ public class QueueManagerImpl implements QueueManager {
// We don't want primary recovery (and therefore user threads) to wait for
// things like pinging connections for health checks.
final String name = "queueTimer-" + this.pool.getName();
- this.recoveryThread = LoggingExecutors.newScheduledThreadPool(name, 1, false);
+ this.recoveryThread = LoggingExecutors.newScheduledThreadPool(1, name, false);
getState().start(background, getPool().getSubscriptionAckInterval());
diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/pooling/ConnectionManagerImpl.java b/geode-core/src/main/java/org/apache/geode/cache/client/internal/pooling/ConnectionManagerImpl.java
index ae48659..01b826e 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/pooling/ConnectionManagerImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/pooling/ConnectionManagerImpl.java
@@ -490,7 +490,7 @@ public class ConnectionManagerImpl implements ConnectionManager {
this.backgroundProcessor = backgroundProcessor;
String name = "poolLoadConditioningMonitor-" + getPoolName();
loadConditioningProcessor =
- LoggingExecutors.newScheduledThreadPool(name, 1, false);
+ LoggingExecutors.newScheduledThreadPool(1, name, false);
endpointManager.addListener(endpointListener);
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterOperationExecutors.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterOperationExecutors.java
index 7ea6532..375ab50 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterOperationExecutors.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterOperationExecutors.java
@@ -212,24 +212,25 @@ public class ClusterOperationExecutors implements OperationExecutors {
stats.getSerialQueueHelper());
poolQueue = serialQueue;
}
- serialThread = CoreLoggingExecutors.newSerialThreadPool("Serial Message Processor",
+ serialThread = CoreLoggingExecutors.newSerialThreadPool(poolQueue, "Serial Message Processor",
thread -> stats.incSerialThreadStarts(),
this::doSerialThread, stats.getSerialProcessorHelper(),
- threadMonitor, poolQueue);
+ threadMonitor);
}
threadPool =
- CoreLoggingExecutors.newThreadPoolWithFeedStatistics("Pooled Message Processor ",
+ CoreLoggingExecutors.newThreadPoolWithFeedStatistics(MAX_THREADS,
+ INCOMING_QUEUE_LIMIT, stats.getOverflowQueueHelper(), "Pooled Message Processor ",
thread -> stats.incProcessingThreadStarts(), this::doProcessingThread,
- MAX_THREADS, stats.getNormalPoolHelper(), threadMonitor,
- INCOMING_QUEUE_LIMIT, stats.getOverflowQueueHelper());
+ stats.getNormalPoolHelper(),
+ threadMonitor);
highPriorityPool = CoreLoggingExecutors.newThreadPoolWithFeedStatistics(
- "Pooled High Priority Message Processor ",
- thread -> stats.incHighPriorityThreadStarts(), this::doHighPriorityThread,
- MAX_THREADS, stats.getHighPriorityPoolHelper(), threadMonitor,
- INCOMING_QUEUE_LIMIT, stats.getHighPriorityQueueHelper());
+ MAX_THREADS, INCOMING_QUEUE_LIMIT, stats.getHighPriorityQueueHelper(),
+ "Pooled High Priority Message Processor ", thread -> stats.incHighPriorityThreadStarts(),
+ this::doHighPriorityThread, stats.getHighPriorityPoolHelper(),
+ threadMonitor);
{
BlockingQueue<Runnable> poolQueue;
@@ -239,47 +240,50 @@ public class ClusterOperationExecutors implements OperationExecutors {
} else {
poolQueue = new OverflowQueueWithDMStats<>(stats.getWaitingQueueHelper());
}
- waitingPool = CoreLoggingExecutors.newThreadPool("Pooled Waiting Message Processor ",
+ waitingPool = CoreLoggingExecutors.newThreadPool(MAX_WAITING_THREADS, poolQueue,
+ "Pooled Waiting Message Processor ",
thread -> stats.incWaitingThreadStarts(), this::doWaitingThread,
- MAX_WAITING_THREADS, stats.getWaitingPoolHelper(), threadMonitor, poolQueue);
+ stats.getWaitingPoolHelper(), threadMonitor);
}
// should this pool using the waiting pool stats?
prMetaDataCleanupThreadPool =
CoreLoggingExecutors.newThreadPoolWithFeedStatistics(
- "PrMetaData cleanup Message Processor ",
- thread -> stats.incWaitingThreadStarts(), this::doWaitingThread,
- MAX_PR_META_DATA_CLEANUP_THREADS, stats.getWaitingPoolHelper(), threadMonitor,
- 0, stats.getWaitingQueueHelper());
+ MAX_PR_META_DATA_CLEANUP_THREADS, 0, stats.getWaitingQueueHelper(),
+ "PrMetaData cleanup Message Processor ", thread -> stats.incWaitingThreadStarts(),
+ this::doWaitingThread, stats.getWaitingPoolHelper(),
+ threadMonitor);
if (MAX_PR_THREADS > 1) {
partitionedRegionPool =
CoreLoggingExecutors.newThreadPoolWithFeedStatistics(
+ MAX_PR_THREADS, INCOMING_QUEUE_LIMIT, stats.getPartitionedRegionQueueHelper(),
"PartitionedRegion Message Processor",
thread -> stats.incPartitionedRegionThreadStarts(), this::doPartitionRegionThread,
- MAX_PR_THREADS, stats.getPartitionedRegionPoolHelper(), threadMonitor,
- INCOMING_QUEUE_LIMIT, stats.getPartitionedRegionQueueHelper());
+ stats.getPartitionedRegionPoolHelper(),
+ threadMonitor);
} else {
partitionedRegionThread = CoreLoggingExecutors.newSerialThreadPoolWithFeedStatistics(
+ INCOMING_QUEUE_LIMIT, stats.getPartitionedRegionQueueHelper(),
"PartitionedRegion Message Processor",
thread -> stats.incPartitionedRegionThreadStarts(), this::doPartitionRegionThread,
- stats.getPartitionedRegionPoolHelper(), threadMonitor,
- INCOMING_QUEUE_LIMIT, stats.getPartitionedRegionQueueHelper());
+ stats.getPartitionedRegionPoolHelper(), threadMonitor);
}
if (MAX_FE_THREADS > 1) {
functionExecutionPool =
CoreLoggingExecutors.newFunctionThreadPoolWithFeedStatistics(
+ MAX_FE_THREADS, INCOMING_QUEUE_LIMIT, stats.getFunctionExecutionQueueHelper(),
FUNCTION_EXECUTION_PROCESSOR_THREAD_PREFIX,
thread -> stats.incFunctionExecutionThreadStarts(), this::doFunctionExecutionThread,
- MAX_FE_THREADS, stats.getFunctionExecutionPoolHelper(), threadMonitor,
- INCOMING_QUEUE_LIMIT, stats.getFunctionExecutionQueueHelper());
+ stats.getFunctionExecutionPoolHelper(),
+ threadMonitor);
} else {
functionExecutionThread =
CoreLoggingExecutors.newSerialThreadPoolWithFeedStatistics(
+ INCOMING_QUEUE_LIMIT, stats.getFunctionExecutionQueueHelper(),
FUNCTION_EXECUTION_PROCESSOR_THREAD_PREFIX,
thread -> stats.incFunctionExecutionThreadStarts(), this::doFunctionExecutionThread,
- stats.getFunctionExecutionPoolHelper(), threadMonitor,
- INCOMING_QUEUE_LIMIT, stats.getFunctionExecutionQueueHelper());
+ stats.getFunctionExecutionPoolHelper(), threadMonitor);
}
}
@@ -802,9 +806,10 @@ public class ClusterOperationExecutors implements OperationExecutors {
serialQueuedMap.put(id, poolQueue);
- return CoreLoggingExecutors.newSerialThreadPool("Pooled Serial Message Processor" + id + "-",
+ return CoreLoggingExecutors.newSerialThreadPool(poolQueue,
+ "Pooled Serial Message Processor" + id + "-",
thread -> stats.incSerialPooledThreadStarts(), this::doSerialPooledThread,
- stats.getSerialPooledProcessorHelper(), threadMonitoring, poolQueue);
+ stats.getSerialPooledProcessorHelper(), threadMonitoring);
}
private void doSerialPooledThread(Runnable command) {
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/FunctionExecutionPooledExecutor.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/FunctionExecutionPooledExecutor.java
index ae20b2f..45b8333 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/FunctionExecutionPooledExecutor.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/FunctionExecutionPooledExecutor.java
@@ -12,10 +12,13 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.distributed.internal;
+import static java.lang.Integer.getInteger;
+import static java.lang.Long.getLong;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.geode.distributed.internal.OperationExecutors.FUNCTION_EXECUTION_PROCESSOR_THREAD_PREFIX;
+import static org.apache.geode.util.internal.GeodeGlossary.GEMFIRE_PREFIX;
import java.util.List;
import java.util.concurrent.BlockingQueue;
@@ -24,7 +27,6 @@ import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.Logger;
@@ -32,28 +34,29 @@ import org.apache.geode.SystemFailure;
import org.apache.geode.annotations.internal.MakeNotStatic;
import org.apache.geode.internal.monitoring.ThreadsMonitoring;
import org.apache.geode.logging.internal.log4j.api.LogService;
-import org.apache.geode.util.internal.GeodeGlossary;
/**
* A ThreadPoolExecutor with stat support. This executor also has a buffer that rejected executions
* spill over into.
*
+ * <p>
* This executor has also been modified to handle rejected execution in one of three ways: If the
* executor is for function execution we ignore size caps on the thread pool<br>
* If the executor has a SynchronousQueue or SynchronousQueueNoSpin then rejected executions are run
* in the current thread.<br>
* Otherwise a thread is started in the pool that buffers the rejected tasks and puts them back into
* the executor.
- *
*/
public class FunctionExecutionPooledExecutor extends ThreadPoolExecutor {
- protected final PoolStatHelper stats;
- private final ThreadsMonitoring threadMonitoring;
private static final Logger logger = LogService.getLogger();
- private static final int OFFER_TIME =
- Integer.getInteger(GeodeGlossary.GEMFIRE_PREFIX + "RETRY_INTERVAL", 5000).intValue();
+ private static final int DEFAULT_RETRY_INTERVAL = 5000;
+
+ private static final int DEFAULT_IDLE_THREAD_TIMEOUT_MILLIS = 30000 * 60;
+
+ private static final int OFFER_TIME_MILLIS =
+ getInteger(GEMFIRE_PREFIX + "RETRY_INTERVAL", DEFAULT_RETRY_INTERVAL);
/**
* Identifier for function execution threads and any of their children
@@ -67,80 +70,116 @@ public class FunctionExecutionPooledExecutor extends ThreadPoolExecutor {
}
};
+ private final PoolStatHelper stats;
- /**
- * Is the current thread used for executing Functions?
- */
- public static boolean isFunctionExecutionThread() {
- return isFunctionExecutionThread.get().booleanValue();
- }
-
-
-
- /**
- * Create a new pool
- **/
- public FunctionExecutionPooledExecutor(BlockingQueue<Runnable> q, int maxPoolSize,
- PoolStatHelper stats, ThreadFactory tf, int msTimeout, RejectedExecutionHandler reh,
- ThreadsMonitoring tMonitoring) {
- super(getCorePoolSize(maxPoolSize), maxPoolSize, msTimeout, TimeUnit.MILLISECONDS, q, tf, reh);
- // if (getCorePoolSize() != 0 && getCorePoolSize() == getMaximumPoolSize()) {
- // allowCoreThreadTimeOut(true); // deadcoded for 1.5
- // }
- this.stats = stats;
- this.threadMonitoring = tMonitoring;
- }
+ private final ThreadsMonitoring threadMonitoring;
/**
* Used to buffer up tasks that would be have been rejected. Only used (i.e. non-null) if
* constructor queue is not a SynchronousQueue.
*/
- protected BlockingQueue<Runnable> bufferQueue;
+ private BlockingQueue<Runnable> bufferQueue;
+
/**
* Used to consume items off the bufferQueue and put them into the pools synchronous queue. Only
* used (i.e. non-null) if constructor queue is not a SynchronousQueue.
*/
- Thread bufferConsumer;
+ private Thread bufferConsumer;
+
+ /**
+ * Sets timeout to IDLE_THREAD_TIMEOUT
+ */
+ public FunctionExecutionPooledExecutor(int poolSize, BlockingQueue<Runnable> workQueue,
+ ThreadFactory threadFactory, PoolStatHelper poolStatHelper,
+ ThreadsMonitoring threadsMonitoring) {
+
+ // TODO: workQueue is always an OverflowQueueWithDMStats which is a LinkedBlockingQueue
+
+ /*
+ * How long an idle thread will wait, in milliseconds, before it is removed from its thread
+ * pool. Default is (30000 * 60) ms (30 minutes). It is not static so it can be set at runtime
+ * and pick up different values.
+ */
+ super(getCorePoolSize(poolSize), poolSize, getLong(GEMFIRE_PREFIX + "IDLE_THREAD_TIMEOUT",
+ DEFAULT_IDLE_THREAD_TIMEOUT_MILLIS), MILLISECONDS, getSynchronousQueue(workQueue),
+ threadFactory, newRejectedExecutionHandler(workQueue, true));
- private static BlockingQueue<Runnable> initQ(BlockingQueue<Runnable> q) {
- if (q instanceof SynchronousQueue) {
- return q;
- } else {
- return new SynchronousQueue<Runnable>();
+ stats = poolStatHelper;
+ threadMonitoring = threadsMonitoring;
+
+ if (!(workQueue instanceof SynchronousQueue)) {
+ bufferQueue = workQueue;
+ // create a thread that takes from bufferQueue and puts into result
+ final BlockingQueue<Runnable> takeQueue = workQueue;
+ final BlockingQueue<Runnable> putQueue = getQueue();
+ Runnable r = () -> {
+ try {
+ for (;;) {
+ SystemFailure.checkFailure();
+ Runnable task = takeQueue.take();
+ if (true) {
+ // In the function case, offer the request to the work queue.
+ // If it fails, execute it anyway. This will cause the RejectedExecutionHandler to
+ // spin off a thread for it.
+ if (!putQueue.offer(task, OFFER_TIME_MILLIS, MILLISECONDS)) {
+ execute(task);
+ }
+ } else {
+ // In the non-function case, put the request on the work queue.
+ putQueue.put(task);
+ }
+ }
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ // this thread is being shutdown so just return;
+ }
+ };
+ bufferConsumer = threadFactory.newThread(r);
+ bufferConsumer.start();
}
}
+ /**
+ * Is the current thread used for executing Functions?
+ */
+ public static boolean isFunctionExecutionThread() {
+ return isFunctionExecutionThread.get();
+ }
- private static RejectedExecutionHandler initREH(final BlockingQueue<Runnable> q,
- boolean forFnExec) {
- if (forFnExec) {
+ private static SynchronousQueue<Runnable> getSynchronousQueue(
+ BlockingQueue<Runnable> blockingQueue) {
+ if (blockingQueue instanceof SynchronousQueue) {
+ return (SynchronousQueue<Runnable>) blockingQueue;
+ }
+ return new SynchronousQueue<>();
+ }
+
+ private static RejectedExecutionHandler newRejectedExecutionHandler(
+ BlockingQueue<Runnable> blockingQueue, boolean forFunctionExecution) {
+ if (forFunctionExecution) {
return new RejectedExecutionHandler() {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
if (executor.isShutdown()) {
- throw new RejectedExecutionException(
- "executor has been shutdown");
+ throw new RejectedExecutionException("executor has been shutdown");
+ }
+ if (isBufferConsumer((FunctionExecutionPooledExecutor) executor)) {
+ handleRejectedExecutionForBufferConsumer(r, executor);
+ } else if (isFunctionExecutionThread()) {
+ handleRejectedExecutionForFunctionExecutionThread(r, executor);
} else {
- if (isBufferConsumer(executor)) {
- handleRejectedExecutionForBufferConsumer(r, executor);
- } else if (isFunctionExecutionThread()) {
- handleRejectedExecutionForFunctionExecutionThread(r, executor);
- } else {
- // In the normal case, add the rejected request to the blocking queue.
- try {
- q.put(r);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- // this thread is being shutdown so just return;
- return;
- }
+ // In the normal case, add the rejected request to the blocking queue.
+ try {
+ blockingQueue.put(r);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ // this thread is being shutdown so just return;
}
}
}
- private boolean isBufferConsumer(ThreadPoolExecutor executor) {
- return Thread
- .currentThread() == ((FunctionExecutionPooledExecutor) executor).bufferConsumer;
+ private boolean isBufferConsumer(FunctionExecutionPooledExecutor executor) {
+ return Thread.currentThread() == executor.bufferConsumer;
}
private boolean isFunctionExecutionThread() {
@@ -157,7 +196,7 @@ public class FunctionExecutionPooledExecutor extends ThreadPoolExecutor {
ThreadPoolExecutor executor) {
logger.warn("An additional " + FUNCTION_EXECUTION_PROCESSOR_THREAD_PREFIX
+ " thread is being launched because all " + executor.getMaximumPoolSize()
- + " thread pool threads are in use for greater than " + OFFER_TIME + " ms");
+ + " thread pool threads are in use for greater than " + OFFER_TIME_MILLIS + " ms");
launchAdditionalThread(r, executor);
}
@@ -170,8 +209,9 @@ public class FunctionExecutionPooledExecutor extends ThreadPoolExecutor {
private void handleRejectedExecutionForFunctionExecutionThread(Runnable r,
ThreadPoolExecutor executor) {
if (logger.isDebugEnabled()) {
- logger.warn("An additional " + FUNCTION_EXECUTION_PROCESSOR_THREAD_PREFIX
- + " thread is being launched to prevent slow performance due to nested function executions");
+ logger.warn(
+ "An additional {} thread is being launched to prevent slow performance due to nested function executions",
+ FUNCTION_EXECUTION_PROCESSOR_THREAD_PREFIX);
}
launchAdditionalThread(r, executor);
}
@@ -181,61 +221,19 @@ public class FunctionExecutionPooledExecutor extends ThreadPoolExecutor {
th.start();
}
};
- } else {
-
- if (q instanceof SynchronousQueue) {
- return new CallerRunsPolicy();
- // return new BlockHandler();
- } else {
- // create a thread that takes from bufferQueue and puts into result
- return new BufferHandler();
- }
}
- }
-
-
- public FunctionExecutionPooledExecutor(BlockingQueue<Runnable> q, int maxPoolSize,
- PoolStatHelper stats, ThreadFactory tf, int msTimeout, final boolean forFnExec,
- ThreadsMonitoring tMonitoring) {
- this(initQ(q), maxPoolSize, stats, tf, msTimeout, initREH(q, forFnExec), tMonitoring);
- if (!(q instanceof SynchronousQueue)) {
- this.bufferQueue = q;
- // create a thread that takes from bufferQueue and puts into result
- final BlockingQueue<Runnable> takeQueue = q;
- final BlockingQueue<Runnable> putQueue = getQueue();
- Runnable r = new Runnable() {
- @Override
- public void run() {
- try {
- for (;;) {
- SystemFailure.checkFailure();
- Runnable task = takeQueue.take();
- if (forFnExec) {
- // In the function case, offer the request to the work queue.
- // If it fails, execute it anyway. This will cause the RejectedExecutionHandler to
- // spin off a thread for it.
- if (!putQueue.offer(task, OFFER_TIME, TimeUnit.MILLISECONDS)) {
- execute(task);
- }
- } else {
- // In the non-function case, put the request on the work queue.
- putQueue.put(task);
- }
- }
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- // this thread is being shutdown so just return;
- return;
- }
- }
- };
- this.bufferConsumer = tf.newThread(r);
- this.bufferConsumer.start();
+ if (blockingQueue instanceof SynchronousQueue) {
+ return new CallerRunsPolicy();
+ // return new BlockHandler();
}
+
+ // create a thread that takes from bufferQueue and puts into result
+ return new BufferHandler();
}
- public static void setIsFunctionExecutionThread(Boolean isExecutionThread) {
+
+ static void setIsFunctionExecutionThread(Boolean isExecutionThread) {
isFunctionExecutionThread.set(isExecutionThread);
}
@@ -250,73 +248,38 @@ public class FunctionExecutionPooledExecutor extends ThreadPoolExecutor {
@Override
protected void terminated() {
- if (this.bufferConsumer != null) {
- this.bufferConsumer.interrupt();
+ if (bufferConsumer != null) {
+ bufferConsumer.interrupt();
}
super.terminated();
}
@Override
- public List shutdownNow() {
+ public List<Runnable> shutdownNow() {
terminated();
- List l = super.shutdownNow();
- if (this.bufferQueue != null) {
- this.bufferQueue.drainTo(l);
+ List<Runnable> l = super.shutdownNow();
+ if (bufferQueue != null) {
+ bufferQueue.drainTo(l);
}
return l;
}
- /**
- * Sets timeout to IDLE_THREAD_TIMEOUT
- */
- public FunctionExecutionPooledExecutor(BlockingQueue<Runnable> q, int poolSize,
- PoolStatHelper stats, ThreadFactory tf, ThreadsMonitoring tMonitoring) {
- /*
- * How long an idle thread will wait, in milliseconds, before it is removed from its thread
- * pool. Default is (30000 * 60) ms (30 minutes). It is not static so it can be set at runtime
- * and pick up different values.
- */
- this(q, poolSize, stats, tf,
- Integer.getInteger(GeodeGlossary.GEMFIRE_PREFIX + "IDLE_THREAD_TIMEOUT", 30000 * 60),
- false /* not for fn exec */, tMonitoring);
- }
-
- public FunctionExecutionPooledExecutor(BlockingQueue<Runnable> q, int poolSize,
- PoolStatHelper stats, ThreadFactory tf, boolean forFnExec, ThreadsMonitoring tMonitoring) {
- /*
- * How long an idle thread will wait, in milliseconds, before it is removed from its thread
- * pool. Default is (30000 * 60) ms (30 minutes). It is not static so it can be set at runtime
- * and pick up different values.
- */
- this(q, poolSize, stats, tf,
- Integer.getInteger(GeodeGlossary.GEMFIRE_PREFIX + "IDLE_THREAD_TIMEOUT", 30000 * 60),
- forFnExec, tMonitoring);
- }
-
- /**
- * Default timeout with no stats.
- */
- public FunctionExecutionPooledExecutor(BlockingQueue<Runnable> q, int poolSize, ThreadFactory tf,
- ThreadsMonitoring tMonitoring) {
- this(q, poolSize, null/* no stats */, tf, tMonitoring);
- }
-
@Override
protected void beforeExecute(Thread t, Runnable r) {
- if (this.stats != null) {
- this.stats.startJob();
+ if (stats != null) {
+ stats.startJob();
}
- if (this.threadMonitoring != null) {
+ if (threadMonitoring != null) {
threadMonitoring.startMonitor(ThreadsMonitoring.Mode.FunctionExecutor);
}
}
@Override
- protected void afterExecute(Runnable r, Throwable ex) {
- if (this.stats != null) {
- this.stats.endJob();
+ protected void afterExecute(Runnable r, Throwable t) {
+ if (stats != null) {
+ stats.endJob();
}
- if (this.threadMonitoring != null) {
+ if (threadMonitoring != null) {
threadMonitoring.endMonitor();
}
}
@@ -324,44 +287,12 @@ public class FunctionExecutionPooledExecutor extends ThreadPoolExecutor {
private static int getCorePoolSize(int maxSize) {
if (maxSize == Integer.MAX_VALUE) {
return 0;
- } else {
- return 1;
- // int result = Runtime.getRuntime().availableProcessors();
- // if (result < 2) {
- // result = 2;
- // }
- // if (result > maxSize) {
- // result = maxSize;
- // }
- // return result;
}
+ return 1;
}
/**
- * This handler does a put which will just wait until the queue has room.
- */
- public static class BlockHandler implements RejectedExecutionHandler {
- @Override
- public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
- if (executor.isShutdown()) {
- throw new RejectedExecutionException(
- "executor has been shutdown");
- } else {
- try {
- executor.getQueue().put(r);
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- RejectedExecutionException e = new RejectedExecutionException(
- "interrupted");
- e.initCause(ie);
- throw e;
- }
- }
- }
- }
- /**
* This handler fronts a synchronous queue, that is owned by the parent ThreadPoolExecutor, with a
- * the
* client supplied BlockingQueue that supports storage (the buffer queue). A dedicated thread is
* used to consume off the buffer queue and put into the synchronous queue.
*/
@@ -369,19 +300,14 @@ public class FunctionExecutionPooledExecutor extends ThreadPoolExecutor {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
if (executor.isShutdown()) {
- throw new RejectedExecutionException(
- "executor has been shutdown");
- } else {
- try {
- FunctionExecutionPooledExecutor pool = (FunctionExecutionPooledExecutor) executor;
- pool.bufferQueue.put(r);
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- RejectedExecutionException e = new RejectedExecutionException(
- "interrupted");
- e.initCause(ie);
- throw e;
- }
+ throw new RejectedExecutionException("executor has been shutdown");
+ }
+ try {
+ FunctionExecutionPooledExecutor pool = (FunctionExecutionPooledExecutor) executor;
+ pool.bufferQueue.put(r);
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ throw new RejectedExecutionException("interrupted", ie);
}
}
}
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
index 52dad50..f497776 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.distributed.internal;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace;
import static org.apache.geode.distributed.ConfigurationProperties.BIND_ADDRESS;
import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE;
@@ -541,10 +542,9 @@ public class InternalLocator extends Locator implements ConnectListener, LogConf
new RemoteTransportConfig(distributionConfig, MemberIdentifier.LOCATOR_DM_TYPE),
distributionConfig);
Supplier<ExecutorService> executor = () -> CoreLoggingExecutors
- .newThreadPoolWithSynchronousFeed("locator request thread ",
- MAX_POOL_SIZE, new DelayedPoolStatHelper(),
- POOL_IDLE_TIMEOUT,
- new ThreadPoolExecutor.CallerRunsPolicy());
+ .newThreadPoolWithSynchronousFeed(MAX_POOL_SIZE, POOL_IDLE_TIMEOUT, MILLISECONDS,
+ "locator request thread ", new ThreadPoolExecutor.CallerRunsPolicy(),
+ new DelayedPoolStatHelper());
final TcpSocketCreator socketCreator = SocketCreatorFactory
.getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR);
membershipLocator =
@@ -1135,7 +1135,7 @@ public class InternalLocator extends Locator implements ConnectListener, LogConf
}
try {
- system.waitUntilReconnected(waitTime, TimeUnit.MILLISECONDS);
+ system.waitUntilReconnected(waitTime, MILLISECONDS);
} catch (CancelException e) {
continue; // DistributedSystem failed to restart - loop until it gives up
}
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/LocatorLoadSnapshot.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/LocatorLoadSnapshot.java
index 7da092f..3def44e 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/LocatorLoadSnapshot.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/LocatorLoadSnapshot.java
@@ -74,7 +74,7 @@ public class LocatorLoadSnapshot {
private boolean rebalancing;
private final ScheduledExecutorService estimateTimeoutProcessor =
- LoggingExecutors.newScheduledThreadPool("loadEstimateTimeoutProcessor", 1, false);
+ LoggingExecutors.newScheduledThreadPool(1, "loadEstimateTimeoutProcessor", false);
public LocatorLoadSnapshot() {
connectionLoadMap.put(null, new HashMap<>());
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/PooledExecutorWithDMStats.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/PooledExecutorWithDMStats.java
index 99eba72..553ac29 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/PooledExecutorWithDMStats.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/PooledExecutorWithDMStats.java
@@ -12,7 +12,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.distributed.internal;
import java.util.List;
@@ -29,88 +28,71 @@ import org.apache.geode.internal.monitoring.ThreadsMonitoring;
/**
* A ThreadPoolExecutor with stat support.
- *
*/
public class PooledExecutorWithDMStats extends ThreadPoolExecutor {
- protected final PoolStatHelper stats;
- private final ThreadsMonitoring threadMonitoring;
- /**
- * Create a new pool
- **/
- public PooledExecutorWithDMStats(SynchronousQueue<Runnable> q, int maxPoolSize,
- PoolStatHelper stats, ThreadFactory tf, int msTimeout, RejectedExecutionHandler reh,
- ThreadsMonitoring tMonitoring) {
- super(getCorePoolSize(maxPoolSize), maxPoolSize, msTimeout, TimeUnit.MILLISECONDS, q, tf, reh);
- // if (getCorePoolSize() != 0 && getCorePoolSize() == getMaximumPoolSize()) {
- // allowCoreThreadTimeOut(true); // deadcoded for 1.5
- // }
- this.stats = stats;
- this.threadMonitoring = tMonitoring;
- }
+ private final PoolStatHelper poolStatHelper;
+
+ private final ThreadsMonitoring threadsMonitoring;
/**
* Used to buffer up tasks that would be have been rejected. Only used (i.e. non-null) if
* constructor queue is not a SynchronousQueue.
*/
- protected BlockingQueue<Runnable> bufferQueue;
+ private BlockingQueue<Runnable> blockingWorkQueue;
+
/**
* Used to consume items off the bufferQueue and put them into the pools synchronous queue. Only
* used (i.e. non-null) if constructor queue is not a SynchronousQueue.
*/
private Thread bufferConsumer;
- private static SynchronousQueue<Runnable> initQ(BlockingQueue<Runnable> q) {
- if (q instanceof SynchronousQueue) {
- return (SynchronousQueue<Runnable>) q;
- } else {
- return new SynchronousQueue/* NoSpin */<Runnable>();
- }
- }
-
- private static RejectedExecutionHandler initREH(BlockingQueue<Runnable> q) {
- if (q instanceof SynchronousQueue) {
- return new CallerRunsPolicy();
- // return new BlockHandler();
- } else {
- // create a thread that takes from bufferQueue and puts into result
- return new BufferHandler();
- }
- }
-
/**
* Create a new pool that uses the supplied Channel for queuing, and with all default parameter
* settings except for pool size.
**/
- public PooledExecutorWithDMStats(BlockingQueue<Runnable> q, int maxPoolSize, PoolStatHelper stats,
- ThreadFactory tf, int msTimeout, ThreadsMonitoring tMonitoring) {
- this(initQ(q), maxPoolSize, stats, tf, msTimeout, initREH(q), tMonitoring);
- if (!(q instanceof SynchronousQueue)) {
- this.bufferQueue = q;
+ public PooledExecutorWithDMStats(int poolSize, long keepAliveTime, TimeUnit unit,
+ BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, PoolStatHelper poolStatHelper,
+ ThreadsMonitoring threadsMonitoring) {
+ this(poolSize, keepAliveTime, unit, getSynchronousQueue(workQueue), threadFactory,
+ newRejectedExecutionHandler(workQueue), poolStatHelper, threadsMonitoring);
+
+ if (!(workQueue instanceof SynchronousQueue)) {
+ blockingWorkQueue = workQueue;
// create a thread that takes from bufferQueue and puts into result
- final BlockingQueue<Runnable> takeQueue = q;
+ final BlockingQueue<Runnable> takeQueue = workQueue;
final BlockingQueue<Runnable> putQueue = getQueue();
- Runnable r = new Runnable() {
- @Override
- public void run() {
- try {
- for (;;) {
- SystemFailure.checkFailure();
- Runnable job = takeQueue.take();
- putQueue.put(job);
- }
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- // this thread is being shutdown so just return;
- return;
+ Runnable r = () -> {
+ try {
+ for (;;) {
+ SystemFailure.checkFailure();
+ Runnable job = takeQueue.take();
+ putQueue.put(job);
}
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ // this thread is being shutdown so just return;
}
};
- this.bufferConsumer = tf.newThread(r);
- this.bufferConsumer.start();
+ bufferConsumer = threadFactory.newThread(r);
+ bufferConsumer.start();
}
}
+ /**
+ * Create a new pool
+ */
+ public PooledExecutorWithDMStats(int poolSize, long keepAliveTime, TimeUnit unit,
+ SynchronousQueue<Runnable> workQueue, ThreadFactory threadFactory,
+ RejectedExecutionHandler rejectedExecutionHandler, PoolStatHelper poolStatHelper,
+ ThreadsMonitoring threadsMonitoring) {
+ super(getCorePoolSize(poolSize), poolSize, keepAliveTime, unit, workQueue, threadFactory,
+ rejectedExecutionHandler);
+
+ this.poolStatHelper = poolStatHelper;
+ this.threadsMonitoring = threadsMonitoring;
+ }
+
@Override
public void shutdown() {
try {
@@ -122,81 +104,47 @@ public class PooledExecutorWithDMStats extends ThreadPoolExecutor {
@Override
protected void terminated() {
- if (this.bufferConsumer != null) {
- this.bufferConsumer.interrupt();
+ if (bufferConsumer != null) {
+ bufferConsumer.interrupt();
}
super.terminated();
}
@Override
- public List shutdownNow() {
+ public List<Runnable> shutdownNow() {
terminated();
- List l = super.shutdownNow();
- if (this.bufferQueue != null) {
- this.bufferQueue.drainTo(l);
+ List<Runnable> l = super.shutdownNow();
+ if (blockingWorkQueue != null) {
+ blockingWorkQueue.drainTo(l);
}
return l;
}
- /**
- * Sets timeout to IDLE_THREAD_TIMEOUT
- */
- public PooledExecutorWithDMStats(BlockingQueue<Runnable> q, int poolSize, PoolStatHelper stats,
- ThreadFactory tf, ThreadsMonitoring tMonitoring,
- String systemPropertyPrefix) {
- /*
- * How long an idle thread will wait, in milliseconds, before it is removed from its thread
- * pool. Default is (30000 * 60) ms (30 minutes). It is not static so it can be set at runtime
- * and pick up different values.
- */
- this(q, poolSize, stats, tf,
- Integer.getInteger(systemPropertyPrefix + "IDLE_THREAD_TIMEOUT", 30000 * 60)
- .intValue(),
- tMonitoring);
- }
-
- /**
- * Default timeout with no stats.
- */
- public PooledExecutorWithDMStats(BlockingQueue<Runnable> q, int poolSize, ThreadFactory tf,
- ThreadsMonitoring tMonitoring, String systemPropertyPrefix) {
- this(q, poolSize, null/* no stats */, tf, tMonitoring, systemPropertyPrefix);
- }
-
@Override
protected void beforeExecute(Thread t, Runnable r) {
- if (this.stats != null) {
- this.stats.startJob();
+ if (poolStatHelper != null) {
+ poolStatHelper.startJob();
}
- if (this.threadMonitoring != null) {
- threadMonitoring.startMonitor(ThreadsMonitoring.Mode.PooledExecutor);
+ if (threadsMonitoring != null) {
+ threadsMonitoring.startMonitor(ThreadsMonitoring.Mode.PooledExecutor);
}
}
@Override
protected void afterExecute(Runnable r, Throwable ex) {
- if (this.stats != null) {
- this.stats.endJob();
+ if (poolStatHelper != null) {
+ poolStatHelper.endJob();
}
- if (this.threadMonitoring != null) {
- threadMonitoring.endMonitor();
+ if (threadsMonitoring != null) {
+ threadsMonitoring.endMonitor();
}
}
private static int getCorePoolSize(int maxSize) {
if (maxSize == Integer.MAX_VALUE) {
return 0;
- } else {
- return 1;
- // int result = Runtime.getRuntime().availableProcessors();
- // if (result < 2) {
- // result = 2;
- // }
- // if (result > maxSize) {
- // result = maxSize;
- // }
- // return result;
}
+ return 1;
}
/**
@@ -206,17 +154,13 @@ public class PooledExecutorWithDMStats extends ThreadPoolExecutor {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
if (executor.isShutdown()) {
- throw new RejectedExecutionException(
- "executor has been shutdown");
- } else {
- try {
- executor.getQueue().put(r);
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- RejectedExecutionException e = new RejectedExecutionException(
- "interrupted");
- e.initCause(ie);
- }
+ throw new RejectedExecutionException("executor has been shutdown");
+ }
+ try {
+ executor.getQueue().put(r);
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ throw new RejectedExecutionException("interrupted", ie);
}
}
}
@@ -230,20 +174,30 @@ public class PooledExecutorWithDMStats extends ThreadPoolExecutor {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
if (executor.isShutdown()) {
- throw new RejectedExecutionException(
- "executor has been shutdown");
- } else {
- try {
- PooledExecutorWithDMStats pool = (PooledExecutorWithDMStats) executor;
- pool.bufferQueue.put(r);
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- RejectedExecutionException e = new RejectedExecutionException(
- "interrupted");
- e.initCause(ie);
- throw e;
- }
+ throw new RejectedExecutionException("executor has been shutdown");
}
+ try {
+ PooledExecutorWithDMStats pool = (PooledExecutorWithDMStats) executor;
+ pool.blockingWorkQueue.put(r);
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ throw new RejectedExecutionException("interrupted", ie);
+ }
+ }
+ }
+
+ private static SynchronousQueue<Runnable> getSynchronousQueue(BlockingQueue<Runnable> q) {
+ if (q instanceof SynchronousQueue) {
+ return (SynchronousQueue<Runnable>) q;
+ }
+ return new SynchronousQueue<>();
+ }
+
+ private static RejectedExecutionHandler newRejectedExecutionHandler(BlockingQueue<Runnable> q) {
+ if (q instanceof SynchronousQueue) {
+ return new CallerRunsPolicy();
}
+ // create a thread that takes from bufferQueue and puts into result
+ return new BufferHandler();
}
}
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/SerialQueuedExecutorWithDMStats.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/SerialQueuedExecutorWithDMStats.java
index c100dc9..80aca66 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/SerialQueuedExecutorWithDMStats.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/SerialQueuedExecutorWithDMStats.java
@@ -14,10 +14,11 @@
*/
package org.apache.geode.distributed.internal;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import org.apache.geode.internal.monitoring.ThreadsMonitoring;
@@ -26,33 +27,36 @@ import org.apache.geode.internal.monitoring.ThreadsMonitoring;
* stats.
*/
public class SerialQueuedExecutorWithDMStats extends ThreadPoolExecutor {
- final PoolStatHelper stats;
+
+ private final PoolStatHelper poolStatHelper;
private final ThreadsMonitoring threadMonitoring;
- public SerialQueuedExecutorWithDMStats(BlockingQueue q, PoolStatHelper stats, ThreadFactory tf,
- ThreadsMonitoring tMonitoring) {
- super(1, 1, 60, TimeUnit.SECONDS, q, tf, new PooledExecutorWithDMStats.BlockHandler());
- // allowCoreThreadTimeOut(true); // deadcoded for 1.5
- this.stats = stats;
- this.threadMonitoring = tMonitoring;
+ public SerialQueuedExecutorWithDMStats(BlockingQueue<Runnable> workQueue,
+ ThreadFactory threadFactory, PoolStatHelper poolStatHelper,
+ ThreadsMonitoring threadsMonitoring) {
+ super(1, 1, 60, SECONDS, workQueue, threadFactory,
+ new PooledExecutorWithDMStats.BlockHandler());
+
+ this.poolStatHelper = poolStatHelper;
+ threadMonitoring = threadsMonitoring;
}
@Override
protected void beforeExecute(Thread t, Runnable r) {
- if (this.stats != null) {
- this.stats.startJob();
+ if (poolStatHelper != null) {
+ poolStatHelper.startJob();
}
- if (this.threadMonitoring != null) {
+ if (threadMonitoring != null) {
threadMonitoring.startMonitor(ThreadsMonitoring.Mode.SerialQueuedExecutor);
}
}
@Override
- protected void afterExecute(Runnable r, Throwable ex) {
- if (this.stats != null) {
- this.stats.endJob();
+ protected void afterExecute(Runnable r, Throwable t) {
+ if (poolStatHelper != null) {
+ poolStatHelper.endJob();
}
- if (this.threadMonitoring != null) {
+ if (threadMonitoring != null) {
threadMonitoring.endMonitor();
}
}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/ScheduledThreadPoolExecutorWithKeepAlive.java b/geode-core/src/main/java/org/apache/geode/internal/ScheduledThreadPoolExecutorWithKeepAlive.java
index f701e18..c01dc78 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/ScheduledThreadPoolExecutorWithKeepAlive.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/ScheduledThreadPoolExecutorWithKeepAlive.java
@@ -14,6 +14,9 @@
*/
package org.apache.geode.internal;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
+import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
+
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Delayed;
@@ -28,6 +31,7 @@ import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
import org.apache.geode.internal.monitoring.ThreadsMonitoring;
@@ -36,33 +40,32 @@ import org.apache.geode.internal.monitoring.ThreadsMonitoring;
* the normal ScheduledThreadPoolExecutor, there is no way to configure it such that it only add
* threads as needed.
*
+ * <p>
* This executor is not very useful if you only want to have 1 thread. Use the
* ScheduledThreadPoolExecutor in that case. This class with throw an exception if you try to
* configure it with one thread.
- *
- *
*/
-@SuppressWarnings("synthetic-access")
-public class ScheduledThreadPoolExecutorWithKeepAlive extends ThreadPoolExecutor
+public class ScheduledThreadPoolExecutorWithKeepAlive
+ extends ThreadPoolExecutor
implements ScheduledExecutorService {
private final ScheduledThreadPoolExecutor timer;
- private final ThreadsMonitoring threadMonitoring;
+ private final ThreadsMonitoring threadsMonitoring;
- public ScheduledThreadPoolExecutorWithKeepAlive(int corePoolSize, long keepAlive,
- TimeUnit timeUnit, ThreadFactory threadFactory, ThreadsMonitoring tMonitoring) {
- super(0, corePoolSize - 1, keepAlive, timeUnit, new SynchronousQueue(), threadFactory,
+ public ScheduledThreadPoolExecutorWithKeepAlive(int poolSize, long keepAliveTime, TimeUnit unit,
+ ThreadFactory threadFactory, ThreadsMonitoring threadsMonitoring) {
+ super(0, poolSize - 1, keepAliveTime, unit, new SynchronousQueue<>(), threadFactory,
new BlockCallerPolicy());
- timer = new ScheduledThreadPoolExecutor(1, threadFactory) {
+ timer = new ScheduledThreadPoolExecutor(1, threadFactory) {
@Override
protected void terminated() {
super.terminated();
ScheduledThreadPoolExecutorWithKeepAlive.super.shutdown();
}
-
};
- this.threadMonitoring = tMonitoring;
+
+ this.threadsMonitoring = threadsMonitoring;
}
@Override
@@ -72,57 +75,59 @@ public class ScheduledThreadPoolExecutorWithKeepAlive extends ThreadPoolExecutor
@Override
protected void beforeExecute(Thread t, Runnable r) {
- if (this.threadMonitoring != null) {
- threadMonitoring.startMonitor(ThreadsMonitoring.Mode.ScheduledThreadExecutor);
+ if (threadsMonitoring != null) {
+ threadsMonitoring.startMonitor(ThreadsMonitoring.Mode.ScheduledThreadExecutor);
}
}
@Override
protected void afterExecute(Runnable r, Throwable ex) {
- if (this.threadMonitoring != null) {
- threadMonitoring.endMonitor();
+ if (threadsMonitoring != null) {
+ threadsMonitoring.endMonitor();
}
}
@Override
- public Future submit(Callable task) {
- return schedule(task, 0, TimeUnit.NANOSECONDS);
+ public <T> Future<T> submit(Callable<T> task) {
+ return schedule(task, 0, NANOSECONDS);
}
@Override
- public Future submit(Runnable task, Object result) {
- return schedule(task, 0, TimeUnit.NANOSECONDS, result);
+ public <T> Future<T> submit(Runnable task, T result) {
+ return schedule(task, 0, NANOSECONDS, result);
}
@Override
- public Future submit(Runnable task) {
- return schedule(task, 0, TimeUnit.NANOSECONDS);
+ public Future<?> submit(Runnable task) {
+ return schedule(task, 0, NANOSECONDS);
}
@Override
- public ScheduledFuture schedule(Callable callable, long delay, TimeUnit unit) {
- DelegatingScheduledFuture future = new DelegatingScheduledFuture(callable);
- ScheduledFuture timerFuture = timer.schedule(new HandOffTask(future), delay, unit);
+ public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
+ DelegatingScheduledFuture<V> future = new DelegatingScheduledFuture<>(callable);
+ ScheduledFuture<V> timerFuture =
+ uncheckedCast(timer.schedule(new HandOffTask(future), delay, unit));
future.setDelegate(timerFuture);
return future;
}
@Override
- public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) {
+ public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
return schedule(command, delay, unit, null);
}
- private ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit, Object result) {
- DelegatingScheduledFuture future = new DelegatingScheduledFuture(command, result);
- ScheduledFuture timerFuture = timer.schedule(new HandOffTask(future), delay, unit);
+ private <V> ScheduledFuture<V> schedule(Runnable command, long delay, TimeUnit unit, V result) {
+ DelegatingScheduledFuture<V> future = new DelegatingScheduledFuture<>(command, result);
+ ScheduledFuture<V> timerFuture =
+ uncheckedCast(timer.schedule(new HandOffTask(future), delay, unit));
future.setDelegate(timerFuture);
return future;
}
@Override
- public ScheduledFuture scheduleAtFixedRate(Runnable command, long initialDelay, long period,
+ public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period,
TimeUnit unit) {
- DelegatingScheduledFuture future = new DelegatingScheduledFuture(command, null, true);
+ DelegatingScheduledFuture future = new DelegatingScheduledFuture<>(command, null, true);
ScheduledFuture timerFuture =
timer.scheduleAtFixedRate(new HandOffTask(future), initialDelay, period, unit);
future.setDelegate(timerFuture);
@@ -130,9 +135,9 @@ public class ScheduledThreadPoolExecutorWithKeepAlive extends ThreadPoolExecutor
}
@Override
- public ScheduledFuture scheduleWithFixedDelay(Runnable command, long initialDelay, long delay,
+ public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay,
TimeUnit unit) {
- DelegatingScheduledFuture future = new DelegatingScheduledFuture(command, null, true);
+ DelegatingScheduledFuture future = new DelegatingScheduledFuture<>(command, null, true);
ScheduledFuture timerFuture =
timer.scheduleWithFixedDelay(new HandOffTask(future), initialDelay, delay, unit);
future.setDelegate(timerFuture);
@@ -157,8 +162,8 @@ public class ScheduledThreadPoolExecutorWithKeepAlive extends ThreadPoolExecutor
* @see ScheduledThreadPoolExecutor#shutdownNow()
*/
@Override
- public List shutdownNow() {
- List tasks = timer.shutdownNow();
+ public List<Runnable> shutdownNow() {
+ List<Runnable> tasks = timer.shutdownNow();
super.shutdownNow();
return tasks;
}
@@ -174,7 +179,7 @@ public class ScheduledThreadPoolExecutorWithKeepAlive extends ThreadPoolExecutor
if (remaining < 0) {
return false;
}
- return super.awaitTermination(remaining, TimeUnit.NANOSECONDS);
+ return super.awaitTermination(remaining, NANOSECONDS);
}
@Override
@@ -207,25 +212,23 @@ public class ScheduledThreadPoolExecutorWithKeepAlive extends ThreadPoolExecutor
return super.isTerminated() && timer.isTerminated();
}
- // method that is in ScheduledThreadPoolExecutor that we should expose here
public void setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean b) {
timer.setContinueExistingPeriodicTasksAfterShutdownPolicy(b);
}
- // method that is in ScheduledThreadPoolExecutor that we should expose here
public void setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean b) {
- timer.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
+ timer.setExecuteExistingDelayedTasksAfterShutdownPolicy(b);
}
/**
* A Runnable which we put in the timer which simply hands off the contain task for execution in
* the thread pool when the timer fires.
- *
*/
private class HandOffTask implements Runnable {
+
private final Runnable task;
- public HandOffTask(Runnable task) {
+ private HandOffTask(Runnable task) {
this.task = task;
}
@@ -244,28 +247,28 @@ public class ScheduledThreadPoolExecutorWithKeepAlive extends ThreadPoolExecutor
* The future returned by the schedule* methods on this class. This future will not return a value
* until the task has actually executed in the thread pool, but it allows us to cancel associated
* timer task.
- *
*/
- private static class DelegatingScheduledFuture<V> extends FutureTask<V>
+ private static class DelegatingScheduledFuture<V>
+ extends FutureTask<V>
implements ScheduledFuture<V> {
- private ScheduledFuture<V> delegate;
+ private final AtomicReference<ScheduledFuture<V>> delegate = new AtomicReference<>();
private final boolean periodic;
- public DelegatingScheduledFuture(Runnable runnable, V result) {
+ private DelegatingScheduledFuture(Runnable runnable, V result) {
this(runnable, result, false);
}
- public DelegatingScheduledFuture(Callable<V> callable) {
+ private DelegatingScheduledFuture(Callable<V> callable) {
this(callable, false);
}
- public DelegatingScheduledFuture(Runnable runnable, V result, boolean periodic) {
+ private DelegatingScheduledFuture(Runnable runnable, V result, boolean periodic) {
super(runnable, result);
this.periodic = periodic;
}
- public DelegatingScheduledFuture(Callable<V> callable, boolean periodic) {
+ private DelegatingScheduledFuture(Callable<V> callable, boolean periodic) {
super(callable);
this.periodic = periodic;
}
@@ -273,40 +276,40 @@ public class ScheduledThreadPoolExecutorWithKeepAlive extends ThreadPoolExecutor
@Override
public void run() {
if (periodic) {
- super.runAndReset();
+ runAndReset();
} else {
super.run();
}
}
public void setDelegate(ScheduledFuture<V> future) {
- this.delegate = future;
+ delegate.set(future);
}
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
- delegate.cancel(true);
+ delegate.get().cancel(true);
return super.cancel(mayInterruptIfRunning);
}
@Override
public long getDelay(TimeUnit unit) {
- return delegate.getDelay(unit);
+ return delegate.get().getDelay(unit);
}
@Override
public int compareTo(Delayed o) {
- return delegate.compareTo(o);
+ return delegate.get().compareTo(o);
}
@Override
public boolean equals(Object o) {
- return delegate.equals(o);
+ return delegate.get().equals(o);
}
@Override
public int hashCode() {
- return delegate.hashCode();
+ return delegate.get().hashCode();
}
}
@@ -315,19 +318,17 @@ public class ScheduledThreadPoolExecutorWithKeepAlive extends ThreadPoolExecutor
* for the task.
*/
protected static class BlockCallerPolicy implements RejectedExecutionHandler {
+
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
if (executor.isShutdown()) {
throw new RejectedExecutionException("executor has been shutdown");
- } else {
- try {
- executor.getQueue().put(r);
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- RejectedExecutionException e = new RejectedExecutionException("interrupted");
- e.initCause(ie);
- throw e;
- }
+ }
+ try {
+ executor.getQueue().put(r);
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ throw new RejectedExecutionException("interrupted", ie);
}
}
}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreImpl.java
index 8d71134..1c2cca2 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreImpl.java
@@ -508,10 +508,10 @@ public class DiskStoreImpl implements DiskStore {
this.oplogCompactor = null;
}
- this.diskStoreTaskPool = LoggingExecutors.newFixedThreadPoolWithFeedSize("Idle OplogCompactor",
- MAX_CONCURRENT_COMPACTIONS, Integer.MAX_VALUE);
+ this.diskStoreTaskPool = LoggingExecutors.newFixedThreadPoolWithFeedSize(
+ MAX_CONCURRENT_COMPACTIONS, Integer.MAX_VALUE, "Idle OplogCompactor");
this.delayedWritePool =
- LoggingExecutors.newFixedThreadPoolWithFeedSize("Oplog Delete Task", 1, MAX_PENDING_TASKS);
+ LoggingExecutors.newFixedThreadPoolWithFeedSize(1, MAX_PENDING_TASKS, "Oplog Delete Task");
}
// //////////////////// Instance Methods //////////////////////
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreMonitor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreMonitor.java
index d05f440..3b7c219 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreMonitor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreMonitor.java
@@ -116,7 +116,7 @@ public class DiskStoreMonitor {
if (disableMonitor) {
exec = null;
} else {
- exec = LoggingExecutors.newScheduledThreadPool("DiskStoreMonitor", 1);
+ exec = LoggingExecutors.newScheduledThreadPool(1, "DiskStoreMonitor");
// always monitor the log dir, even if there are no disk stores
exec.scheduleWithFixedDelay(() -> {
try {
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/ExpiryTask.java b/geode-core/src/main/java/org/apache/geode/internal/cache/ExpiryTask.java
index deb6c6c..392541a 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/ExpiryTask.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/ExpiryTask.java
@@ -53,9 +53,8 @@ public abstract class ExpiryTask extends SystemTimer.SystemTimerTask {
// default to inline expiry to fix bug 37115
int nThreads = Integer.getInteger(GeodeGlossary.GEMFIRE_PREFIX + "EXPIRY_THREADS", 0);
if (nThreads > 0) {
- executor = CoreLoggingExecutors.newThreadPoolWithSynchronousFeed("Expiry ",
- (Runnable command) -> doExpiryThread(command),
- nThreads);
+ executor = CoreLoggingExecutors.newThreadPoolWithSynchronousFeed(nThreads, "Expiry ",
+ (Runnable command) -> doExpiryThread(command));
} else {
executor = null;
}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index 10170a4..e644a06 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -24,6 +24,7 @@ import static java.util.Collections.unmodifiableMap;
import static java.util.Collections.unmodifiableSet;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.Executors.newScheduledThreadPool;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace;
import static org.apache.geode.cache.Region.SEPARATOR;
import static org.apache.geode.cache.Region.SEPARATOR_CHAR;
@@ -1019,13 +1020,13 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
persistentMemberManager = persistentMemberManagerFactory.get();
if (useAsyncEventListeners) {
- eventThreadPool = newThreadPoolWithFixedFeed("Message Event Thread",
+ eventThreadPool = newThreadPoolWithFixedFeed(EVENT_THREAD_LIMIT, 1000, MILLISECONDS,
+ EVENT_QUEUE_LIMIT, "Message Event Thread",
command -> {
threadWantsSharedResources();
command.run();
- }, EVENT_THREAD_LIMIT, cachePerfStats.getEventPoolHelper(), 1000,
- getThreadMonitorObj(),
- EVENT_QUEUE_LIMIT);
+ },
+ cachePerfStats.getEventPoolHelper(), getThreadMonitorObj());
} else {
eventThreadPool = null;
}
@@ -1860,8 +1861,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
private ExecutorService getShutdownAllExecutorService(int size) {
- return newFixedThreadPool("ShutdownAll-", true,
- shutdownAllPoolSize == -1 ? size : shutdownAllPoolSize);
+ int poolSize = shutdownAllPoolSize == -1 ? size : shutdownAllPoolSize;
+ return newFixedThreadPool(poolSize, "ShutdownAll-", true);
}
private void shutDownOnePRGracefully(PartitionedRegion partitionedRegion) {
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/PRQueryProcessor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/PRQueryProcessor.java
index d681804..cbea5e4 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/PRQueryProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/PRQueryProcessor.java
@@ -334,7 +334,7 @@ public class PRQueryProcessor {
static synchronized void initializeExecutorService() {
if (execService == null || execService.isShutdown() || execService.isTerminated()) {
int numThreads = (TEST_NUM_THREADS > 1 ? TEST_NUM_THREADS : NUM_THREADS);
- execService = LoggingExecutors.newFixedThreadPool("PRQueryProcessor", true, numThreads);
+ execService = LoggingExecutors.newFixedThreadPool(numThreads, "PRQueryProcessor", true);
}
}
}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
index 8411a13..ebc778a 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
@@ -867,7 +867,7 @@ public class PartitionedRegion extends LocalRegion
if (this.getEvictionAttributes() != null
&& this.getEvictionAttributes().getAlgorithm().isLRUHeap()) {
this.sortedBuckets = new ArrayList<BucketRegion>();
- this.bucketSorter = LoggingExecutors.newScheduledThreadPool("BucketSorterThread", 1);
+ this.bucketSorter = LoggingExecutors.newScheduledThreadPool(1, "BucketSorterThread");
}
// If eviction is on, Create an instance of PartitionedRegionLRUStatistics
if ((this.getEvictionAttributes() != null
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/control/HeapMemoryMonitor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/control/HeapMemoryMonitor.java
index 2b3ef17..70ded46 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/control/HeapMemoryMonitor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/control/HeapMemoryMonitor.java
@@ -337,7 +337,7 @@ public class HeapMemoryMonitor implements NotificationListener, MemoryMonitor {
return;
}
- this.pollerExecutor = LoggingExecutors.newScheduledThreadPool("GemfireHeapPoller", 1);
+ this.pollerExecutor = LoggingExecutors.newScheduledThreadPool(1, "GemfireHeapPoller");
this.pollerExecutor.scheduleAtFixedRate(new HeapPoller(), POLLER_INTERVAL, POLLER_INTERVAL,
TimeUnit.MILLISECONDS);
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/control/InternalResourceManager.java b/geode-core/src/main/java/org/apache/geode/internal/cache/control/InternalResourceManager.java
index 6ac8fb4..0085c8c 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/control/InternalResourceManager.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/control/InternalResourceManager.java
@@ -131,7 +131,7 @@ public class InternalResourceManager implements ResourceManager {
// Create a new executor that other classes may use for handling resource
// related tasks
this.scheduledExecutor = LoggingExecutors
- .newScheduledThreadPool("ResourceManagerRecoveryThread ", MAX_RESOURCE_MANAGER_EXE_THREADS);
+ .newScheduledThreadPool(MAX_RESOURCE_MANAGER_EXE_THREADS, "ResourceManagerRecoveryThread ");
// Initialize the load probe
try {
@@ -144,10 +144,10 @@ public class InternalResourceManager implements ResourceManager {
// Create a new executor the resource manager and the monitors it creates
// can use to handle dispatching of notifications.
this.notifyExecutor =
- CoreLoggingExecutors.newSerialThreadPoolWithFeedStatistics("Notification Handler",
+ CoreLoggingExecutors.newSerialThreadPoolWithFeedStatistics(0,
+ this.stats.getResourceEventQueueStatHelper(), "Notification Handler",
thread -> thread.setPriority(Thread.MAX_PRIORITY), null,
- this.stats.getResourceEventPoolStatHelper(), getThreadMonitorObj(),
- 0, this.stats.getResourceEventQueueStatHelper());
+ this.stats.getResourceEventPoolStatHelper(), getThreadMonitorObj());
// Create the monitors
Map<ResourceType, ResourceMonitor> tempMonitors = new HashMap<ResourceType, ResourceMonitor>();
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/eviction/HeapEvictor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/eviction/HeapEvictor.java
index 595b033..2a54890 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/eviction/HeapEvictor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/eviction/HeapEvictor.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.internal.cache.eviction;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.geode.util.internal.GeodeGlossary.GEMFIRE_PREFIX;
import java.util.ArrayList;
@@ -115,8 +116,8 @@ public class HeapEvictor implements ResourceListener<MemoryEvent> {
if (!DISABLE_HEAP_EVICTOR_THREAD_POOL) {
QueueStatHelper poolStats = this.cache.getCachePerfStats().getEvictionQueueStatHelper();
- this.evictorThreadPool = CoreLoggingExecutors.newFixedThreadPoolWithTimeout(threadName,
- MAX_EVICTOR_THREADS, 15, poolStats);
+ this.evictorThreadPool = CoreLoggingExecutors.newFixedThreadPoolWithTimeout(
+ MAX_EVICTOR_THREADS, 15, SECONDS, poolStats, threadName);
} else {
// disabled
this.evictorThreadPool = null;
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/eviction/LRUListWithAsyncSorting.java b/geode-core/src/main/java/org/apache/geode/internal/cache/eviction/LRUListWithAsyncSorting.java
index b2f935b..9e66a4b 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/eviction/LRUListWithAsyncSorting.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/eviction/LRUListWithAsyncSorting.java
@@ -71,7 +71,7 @@ public class LRUListWithAsyncSorting extends AbstractEvictionList {
if (threads < 1) {
threads = Math.max((Runtime.getRuntime().availableProcessors() / 4), 1);
}
- return LoggingExecutors.newFixedThreadPool("LRUListWithAsyncSortingThread", true, threads);
+ return LoggingExecutors.newFixedThreadPool(threads, "LRUListWithAsyncSortingThread", true);
}
LRUListWithAsyncSorting(EvictionController controller) {
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/InternalClientMembership.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/InternalClientMembership.java
index 3c29a08..920c86c 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/InternalClientMembership.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/InternalClientMembership.java
@@ -14,6 +14,8 @@
*/
package org.apache.geode.internal.cache.tier;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -533,7 +535,8 @@ public class InternalClientMembership {
// protected by calling method synchronized on systems
if (executor == null) {
executor =
- LoggingExecutors.newFixedThreadPoolWithTimeout("ClientMembership Event Invoker", 1, 15);
+ LoggingExecutors.newFixedThreadPoolWithTimeout(1, 15, SECONDS,
+ "ClientMembership Event Invoker");
}
}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java
index 8100178..c2d9615 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java
@@ -14,6 +14,8 @@
*/
package org.apache.geode.internal.cache.tier.sockets;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_ACCESSOR_PP;
import static org.apache.geode.internal.cache.tier.CommunicationMode.ClientToServerForQueue;
import static org.apache.geode.internal.cache.tier.sockets.Handshake.REPLY_REFUSED;
@@ -52,7 +54,6 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
@@ -656,8 +657,9 @@ public class AcceptorImpl implements Acceptor, Runnable {
"Handshaker " + serverSock.getInetAddress() + ":" + localPort + " Thread ";
try {
logger.warn("Handshaker max Pool size: " + HANDSHAKE_POOL_SIZE);
- return CoreLoggingExecutors.newThreadPoolWithSynchronousFeedThatHandlesRejection(threadName,
- thread -> getStats().incAcceptThreadsCreated(), null, 1, HANDSHAKE_POOL_SIZE, 60);
+ return CoreLoggingExecutors.newThreadPoolWithSynchronousFeedThatHandlesRejection(1,
+ HANDSHAKE_POOL_SIZE, 60, SECONDS, threadName,
+ thread -> getStats().incAcceptThreadsCreated(), null);
} catch (IllegalArgumentException poolInitException) {
stats.close();
serverSock.close();
@@ -668,6 +670,7 @@ public class AcceptorImpl implements Acceptor, Runnable {
private ExecutorService initializeClientQueueInitializerThreadPool() {
return CoreLoggingExecutors.newThreadPoolWithSynchronousFeed(
+ CLIENT_QUEUE_INITIALIZATION_POOL_SIZE, 60000, MILLISECONDS,
"Client Queue Initialization Thread ",
command -> {
try {
@@ -675,8 +678,8 @@ public class AcceptorImpl implements Acceptor, Runnable {
} catch (CancelException e) {
logger.debug("Client Queue Initialization was canceled.", e);
}
- }, CLIENT_QUEUE_INITIALIZATION_POOL_SIZE, getStats().getCnxPoolHelper(), 60000,
- getThreadMonitorObj());
+ },
+ getStats().getCnxPoolHelper(), getThreadMonitorObj());
}
private ExecutorService initializeServerConnectionThreadPool() throws IOException {
@@ -693,13 +696,12 @@ public class AcceptorImpl implements Acceptor, Runnable {
try {
String threadName = "ServerConnection on port " + localPort + " Thread ";
if (isSelector()) {
- return CoreLoggingExecutors.newThreadPoolWithUnlimitedFeed(threadName, threadInitializer,
- commandWrapper, maxThreads,
- getStats().getCnxPoolHelper(), Integer.MAX_VALUE, getThreadMonitorObj());
+ return CoreLoggingExecutors.newThreadPoolWithUnlimitedFeed(maxThreads, Integer.MAX_VALUE,
+ MILLISECONDS, threadName, threadInitializer, commandWrapper,
+ getStats().getCnxPoolHelper(), getThreadMonitorObj());
}
- return CoreLoggingExecutors.newThreadPoolWithSynchronousFeed(threadName, threadInitializer,
- commandWrapper,
- MINIMUM_MAX_CONNECTIONS, maxConnections, 0L);
+ return CoreLoggingExecutors.newThreadPoolWithSynchronousFeed(MINIMUM_MAX_CONNECTIONS,
+ maxConnections, 0L, SECONDS, threadName, threadInitializer, commandWrapper);
} catch (IllegalArgumentException poolInitException) {
stats.close();
serverSock.close();
@@ -1684,7 +1686,7 @@ public class AcceptorImpl implements Acceptor, Runnable {
private void shutdownPools() {
pool.shutdown();
try {
- if (!pool.awaitTermination(PoolImpl.SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS)) {
+ if (!pool.awaitTermination(PoolImpl.SHUTDOWN_TIMEOUT, MILLISECONDS)) {
logger.warn("Timeout waiting for background tasks to complete.");
pool.shutdownNow();
}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderEventProcessor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderEventProcessor.java
index 4d84b80..0ef1fd3 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderEventProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderEventProcessor.java
@@ -252,8 +252,8 @@ public class ConcurrentParallelGatewaySenderEventProcessor
}
ExecutorService stopperService = LoggingExecutors.newFixedThreadPool(
- "ConcurrentParallelGatewaySenderEventProcessor Stopper Thread",
- true, processors.length);
+ processors.length, "ConcurrentParallelGatewaySenderEventProcessor Stopper Thread",
+ true);
try {
List<Future<Boolean>> futures = stopperService.invokeAll(stopperCallables);
for (Future<Boolean> f : futures) {
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java
index 88ef0b1..9366d5f 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java
@@ -645,7 +645,7 @@ public class ParallelGatewaySenderQueue implements RegionQueue {
private void initializeConflationThreadPool() {
int poolSize = Runtime.getRuntime().availableProcessors();
conflationExecutor =
- LoggingExecutors.newFixedThreadPool("WAN Queue Conflation Thread", true, poolSize);
+ LoggingExecutors.newFixedThreadPool(poolSize, "WAN Queue Conflation Thread", true);
}
/**
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessor.java
index 7d83ecb..06f74ae 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessor.java
@@ -292,8 +292,8 @@ public class ConcurrentSerialGatewaySenderEventProcessor
}
ExecutorService stopperService = LoggingExecutors.newFixedThreadPool(
- "ConcurrentSerialGatewaySenderEventProcessor Stopper Thread",
- true, processors.size());
+ processors.size(), "ConcurrentSerialGatewaySenderEventProcessor Stopper Thread",
+ true);
try {
List<Future<Boolean>> futures = stopperService.invokeAll(stopperCallables);
for (Future<Boolean> f : futures) {
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessor.java
index daf97e7..aea4b07 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessor.java
@@ -14,6 +14,8 @@
*/
package org.apache.geode.internal.cache.wan.serial;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.io.IOException;
import java.util.Collections;
import java.util.Iterator;
@@ -819,7 +821,8 @@ public class SerialGatewaySenderEventProcessor extends AbstractGatewaySenderEven
*/
private void initializeListenerExecutor() {
this.executor =
- LoggingExecutors.newFixedThreadPoolWithTimeout("Queued Gateway Listener Thread", 1, 120);
+ LoggingExecutors.newFixedThreadPoolWithTimeout(1, 120, SECONDS,
+ "Queued Gateway Listener Thread");
}
private void shutdownListenerExecutor() {
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/CoreLoggingExecutors.java b/geode-core/src/main/java/org/apache/geode/internal/logging/CoreLoggingExecutors.java
index 70ceea6..c70eb24 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/logging/CoreLoggingExecutors.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/CoreLoggingExecutors.java
@@ -14,8 +14,8 @@
*/
package org.apache.geode.internal.logging;
+import static java.lang.Integer.getInteger;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.geode.internal.lang.SystemPropertyHelper.GEMFIRE_PREFIX;
import java.util.concurrent.ArrayBlockingQueue;
@@ -28,6 +28,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import org.apache.geode.distributed.internal.FunctionExecutionPooledExecutor;
import org.apache.geode.distributed.internal.OverflowQueueWithDMStats;
@@ -48,143 +49,135 @@ import org.apache.geode.logging.internal.executors.LoggingThreadFactory.ThreadIn
*/
public class CoreLoggingExecutors {
- public static ExecutorService newSerialThreadPool(String threadName,
- ThreadInitializer threadInitializer, CommandWrapper commandWrapper,
- PoolStatHelper stats, ThreadsMonitoring threadsMonitoring, BlockingQueue<Runnable> feed) {
- ThreadFactory threadFactory =
- new LoggingThreadFactory(threadName, threadInitializer, commandWrapper);
- return new SerialQueuedExecutorWithDMStats(feed, stats, threadFactory, threadsMonitoring);
+ private static final String IDLE_THREAD_TIMEOUT_MILLIS_PROPERTY = "IDLE_THREAD_TIMEOUT";
+ private static final int DEFAULT_IDLE_THREAD_TIMEOUT_MILLIS = 30000 * 60;
+
+ public static ExecutorService newFixedThreadPoolWithTimeout(int poolSize, long keepAliveTime,
+ TimeUnit unit, QueueStatHelper queueStatHelper, String threadName) {
+ BlockingQueue<Runnable> workQueue = createWorkQueueWithStatistics(0, queueStatHelper);
+ return LoggingExecutors.newFixedThreadPool(poolSize, keepAliveTime, unit, workQueue, threadName,
+ true);
}
- public static ExecutorService newSerialThreadPoolWithFeedStatistics(String threadName,
+ public static ExecutorService newFunctionThreadPoolWithFeedStatistics(int poolSize,
+ int workQueueSize, QueueStatHelper queueStatHelper, String threadName,
ThreadInitializer threadInitializer, CommandWrapper commandWrapper,
- PoolStatHelper poolStats,
- ThreadsMonitoring threadsMonitoring, int feedSize, QueueStatHelper feedStats) {
- BlockingQueue<Runnable> feed = createFeedWithStatistics(feedSize, feedStats);
- return newSerialThreadPool(threadName, threadInitializer, commandWrapper, poolStats,
- threadsMonitoring, feed);
- }
-
- public static ExecutorService newSerialThreadPoolWithUnlimitedFeed(String threadName,
- ThreadInitializer threadInitializer,
- CommandWrapper commandWrapper, PoolStatHelper stats, ThreadsMonitoring threadsMonitoring) {
- LinkedBlockingQueue<Runnable> feed = new LinkedBlockingQueue<>();
- return newSerialThreadPool(threadName, threadInitializer, commandWrapper, stats,
- threadsMonitoring, feed);
- }
-
- public static ExecutorService newThreadPoolWithUnlimitedFeed(String threadName,
- ThreadInitializer threadInitializer,
- CommandWrapper commandWrapper, int poolSize,
- PoolStatHelper poolStats, int msTimeout, ThreadsMonitoring threadsMonitoring) {
- LinkedBlockingQueue<Runnable> feed = new LinkedBlockingQueue<>();
+ PoolStatHelper poolStatsHelper, ThreadsMonitoring threadsMonitoring) {
+ BlockingQueue<Runnable> workQueue =
+ createWorkQueueWithStatistics(workQueueSize, queueStatHelper);
ThreadFactory threadFactory =
new LoggingThreadFactory(threadName, threadInitializer, commandWrapper);
- return new PooledExecutorWithDMStats(feed, poolSize, poolStats, threadFactory, msTimeout,
+ return new FunctionExecutionPooledExecutor(poolSize, workQueue, threadFactory, poolStatsHelper,
threadsMonitoring);
}
- public static ExecutorService newThreadPoolWithFixedFeed(String threadName,
- CommandWrapper commandWrapper,
- int poolSize, PoolStatHelper poolStats, int msTimeout, ThreadsMonitoring threadsMonitoring,
- int feedSize) {
- ArrayBlockingQueue<Runnable> feed = new ArrayBlockingQueue<>(feedSize);
- ThreadFactory threadFactory = new LoggingThreadFactory(threadName, commandWrapper);
- return new PooledExecutorWithDMStats(feed, poolSize, poolStats, threadFactory, msTimeout,
- threadsMonitoring);
- }
-
- public static ExecutorService newFunctionThreadPoolWithFeedStatistics(String threadName,
- ThreadInitializer threadInitializer, CommandWrapper commandWrapper,
- int poolSize, PoolStatHelper poolStats,
- ThreadsMonitoring threadsMonitoring, int feedSize, QueueStatHelper feedStats) {
- BlockingQueue<Runnable> feed = createFeedWithStatistics(feedSize, feedStats);
+ public static ExecutorService newSerialThreadPool(BlockingQueue<Runnable> workQueue,
+ String threadName, ThreadInitializer threadInitializer, CommandWrapper commandWrapper,
+ PoolStatHelper poolStatsHelper, ThreadsMonitoring threadsMonitoring) {
ThreadFactory threadFactory =
new LoggingThreadFactory(threadName, threadInitializer, commandWrapper);
- return new FunctionExecutionPooledExecutor(feed, poolSize, poolStats, threadFactory, true,
+ return new SerialQueuedExecutorWithDMStats(workQueue, threadFactory, poolStatsHelper,
threadsMonitoring);
}
- private static BlockingQueue<Runnable> createFeedWithStatistics(int feedSize,
- QueueStatHelper feedStats) {
- BlockingQueue<Runnable> feed;
- if (feedSize == 0) {
- feed = new OverflowQueueWithDMStats<>(feedStats);
- } else {
- feed = new OverflowQueueWithDMStats<>(feedSize, feedStats);
- }
- return feed;
+ public static ExecutorService newSerialThreadPoolWithFeedStatistics(int workQueueSize,
+ QueueStatHelper queueStatHelper, String threadName, ThreadInitializer threadInitializer,
+ CommandWrapper commandWrapper, PoolStatHelper poolStatsHelper,
+ ThreadsMonitoring threadsMonitoring) {
+ BlockingQueue<Runnable> workQueue =
+ createWorkQueueWithStatistics(workQueueSize, queueStatHelper);
+ return newSerialThreadPool(workQueue, threadName, threadInitializer, commandWrapper,
+ poolStatsHelper,
+ threadsMonitoring);
}
- public static ExecutorService newThreadPoolWithFeedStatistics(String threadName,
- ThreadInitializer threadInitializer, CommandWrapper commandWrapper,
- int poolSize, PoolStatHelper poolStats,
- ThreadsMonitoring threadsMonitoring, int feedSize, QueueStatHelper feedStats) {
- BlockingQueue<Runnable> feed = createFeedWithStatistics(feedSize, feedStats);
- return newThreadPool(threadName, threadInitializer, commandWrapper, poolSize, poolStats,
- threadsMonitoring, feed);
+ public static ScheduledExecutorService newScheduledThreadPool(int poolSize, long keepAliveTime,
+ TimeUnit unit, String threadName, ThreadsMonitoring threadsMonitoring) {
+ ThreadFactory threadFactory = new LoggingThreadFactory(threadName);
+ ScheduledThreadPoolExecutorWithKeepAlive result =
+ new ScheduledThreadPoolExecutorWithKeepAlive(poolSize, keepAliveTime, unit, threadFactory,
+ threadsMonitoring);
+ result.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
+ result.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
+ return result;
}
- public static ExecutorService newThreadPool(String threadName,
- ThreadInitializer threadInitializer, CommandWrapper commandWrapper,
- int poolSize, PoolStatHelper poolStats,
- ThreadsMonitoring threadsMonitoring, BlockingQueue<Runnable> feed) {
+ public static ExecutorService newThreadPool(int poolSize, BlockingQueue<Runnable> workQueue,
+ String threadName, ThreadInitializer threadInitializer, CommandWrapper commandWrapper,
+ PoolStatHelper poolStatsHelper, ThreadsMonitoring threadsMonitoring) {
ThreadFactory threadFactory =
new LoggingThreadFactory(threadName, threadInitializer, commandWrapper);
- return new PooledExecutorWithDMStats(feed, poolSize, poolStats, threadFactory,
- threadsMonitoring, GEMFIRE_PREFIX);
+ return new PooledExecutorWithDMStats(poolSize, getIdleThreadTimeoutMillis(), MILLISECONDS,
+ workQueue, threadFactory, poolStatsHelper, threadsMonitoring);
}
- public static ExecutorService newThreadPoolWithSynchronousFeed(String threadName,
- CommandWrapper commandWrapper,
- int poolSize) {
+ public static ExecutorService newThreadPoolWithFixedFeed(int poolSize, long keepAliveTime,
+ TimeUnit unit, int workQueueSize, String threadName, CommandWrapper commandWrapper,
+ PoolStatHelper poolStatsHelper, ThreadsMonitoring threadsMonitoring) {
+ ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<>(workQueueSize);
ThreadFactory threadFactory = new LoggingThreadFactory(threadName, commandWrapper);
- SynchronousQueue<Runnable> feed = new SynchronousQueue<>();
- return new PooledExecutorWithDMStats(feed, poolSize, threadFactory, null,
- GEMFIRE_PREFIX);
+ return new PooledExecutorWithDMStats(poolSize, keepAliveTime, unit, workQueue, threadFactory,
+ poolStatsHelper, threadsMonitoring);
+ }
+
+ public static ExecutorService newThreadPoolWithFeedStatistics(int poolSize, int workQueueSize,
+ QueueStatHelper queueStatHelper, String threadName, ThreadInitializer threadInitializer,
+ CommandWrapper commandWrapper, PoolStatHelper poolStatsHelper,
+ ThreadsMonitoring threadsMonitoring) {
+ BlockingQueue<Runnable> workQueue =
+ createWorkQueueWithStatistics(workQueueSize, queueStatHelper);
+ return newThreadPool(poolSize, workQueue, threadName, threadInitializer, commandWrapper,
+ poolStatsHelper, threadsMonitoring);
}
- public static ExecutorService newThreadPoolWithSynchronousFeed(String threadName,
- CommandWrapper commandWrapper,
- int poolSize, PoolStatHelper poolStats, int msTimeout, ThreadsMonitoring threadsMonitoring) {
+ public static ExecutorService newThreadPoolWithSynchronousFeed(int poolSize, String threadName,
+ CommandWrapper commandWrapper) {
ThreadFactory threadFactory = new LoggingThreadFactory(threadName, commandWrapper);
- SynchronousQueue<Runnable> feed = new SynchronousQueue<>();
- return new PooledExecutorWithDMStats(feed, poolSize, poolStats, threadFactory, msTimeout,
- threadsMonitoring);
+ SynchronousQueue<Runnable> workQueue = new SynchronousQueue<>();
+ return new PooledExecutorWithDMStats(poolSize, getIdleThreadTimeoutMillis(), MILLISECONDS,
+ workQueue, threadFactory, null, null);
+ }
+
+ public static ExecutorService newThreadPoolWithSynchronousFeed(int poolSize, long keepAliveTime,
+ TimeUnit unit, String threadName, CommandWrapper commandWrapper,
+ PoolStatHelper poolStatsHelper, ThreadsMonitoring threadsMonitoring) {
+ ThreadFactory threadFactory = new LoggingThreadFactory(threadName, commandWrapper);
+ SynchronousQueue<Runnable> workQueue = new SynchronousQueue<>();
+ return new PooledExecutorWithDMStats(poolSize, keepAliveTime, unit, workQueue, threadFactory,
+ poolStatsHelper, threadsMonitoring);
}
- public static ExecutorService newThreadPoolWithSynchronousFeed(String threadName, int poolSize,
- PoolStatHelper stats, int msTimeout, RejectedExecutionHandler rejectionHandler) {
- final SynchronousQueue<Runnable> feed = new SynchronousQueue<>();
+ public static ExecutorService newThreadPoolWithSynchronousFeed(int poolSize, long keepAliveTime,
+ TimeUnit unit, String threadName, RejectedExecutionHandler rejectionHandler,
+ PoolStatHelper poolStatsHelper) {
+ SynchronousQueue<Runnable> workQueue = new SynchronousQueue<>();
ThreadFactory threadFactory = new LoggingThreadFactory(threadName);
- return new PooledExecutorWithDMStats(feed, poolSize, stats, threadFactory, msTimeout,
- rejectionHandler, null);
+ return new PooledExecutorWithDMStats(poolSize, keepAliveTime, unit, workQueue, threadFactory,
+ rejectionHandler, poolStatsHelper, null);
}
- public static ExecutorService newThreadPoolWithSynchronousFeed(String threadName,
- ThreadInitializer threadInitializer, CommandWrapper commandWrapper,
- int corePoolSize, int maximumPoolSize, long keepAliveSeconds) {
- final BlockingQueue<Runnable> blockingQueue = new SynchronousQueue<>();
+ public static ExecutorService newThreadPoolWithSynchronousFeed(int corePoolSize,
+ int maximumPoolSize, long keepAliveTime, TimeUnit unit, String threadName,
+ ThreadInitializer threadInitializer, CommandWrapper commandWrapper) {
+ BlockingQueue<Runnable> blockingQueue = new SynchronousQueue<>();
ThreadFactory threadFactory =
new LoggingThreadFactory(threadName, threadInitializer, commandWrapper);
- return new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveSeconds, SECONDS,
- blockingQueue,
+ return new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, unit, blockingQueue,
threadFactory);
}
- public static ExecutorService newThreadPoolWithSynchronousFeed(String threadName,
- int corePoolSize, int maximumPoolSize, long keepAliveSeconds) {
- return newThreadPoolWithSynchronousFeed(threadName, null, null, corePoolSize, maximumPoolSize,
- keepAliveSeconds);
+ /** Used for P2P Reader Threads in ConnectionTable */
+ public static ExecutorService newThreadPoolWithSynchronousFeed(int corePoolSize,
+ int maximumPoolSize, long keepAliveTime, TimeUnit unit, String threadName) {
+ return newThreadPoolWithSynchronousFeed(corePoolSize, maximumPoolSize, keepAliveTime, unit,
+ threadName, null, null);
}
public static ExecutorService newThreadPoolWithSynchronousFeedThatHandlesRejection(
- String threadName,
- ThreadInitializer threadInitializer, CommandWrapper commandWrapper,
- int corePoolSize, int maximumPoolSize,
- long keepAliveSeconds) {
- final BlockingQueue<Runnable> blockingQueue = new SynchronousQueue<>();
- final RejectedExecutionHandler rejectedExecutionHandler = (r, pool) -> {
+ int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, String threadName,
+ ThreadInitializer threadInitializer, CommandWrapper commandWrapper) {
+ BlockingQueue<Runnable> blockingQueue = new SynchronousQueue<>();
+ RejectedExecutionHandler rejectedExecutionHandler = (r, executor) -> {
try {
blockingQueue.put(r);
} catch (InterruptedException ex) {
@@ -194,30 +187,39 @@ public class CoreLoggingExecutors {
};
ThreadFactory threadFactory =
new LoggingThreadFactory(threadName, threadInitializer, commandWrapper);
- return new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveSeconds, SECONDS,
- blockingQueue,
- threadFactory, rejectedExecutionHandler);
+ return new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, unit,
+ blockingQueue, threadFactory, rejectedExecutionHandler);
}
- public static ExecutorService newFixedThreadPoolWithTimeout(String threadName,
- int poolSize, int keepAliveSeconds, QueueStatHelper feedStats) {
- BlockingQueue<Runnable> feed = createFeedWithStatistics(0, feedStats);
- return LoggingExecutors.newFixedThreadPool(threadName, true, poolSize, keepAliveSeconds, feed);
- }
-
- public static ScheduledExecutorService newScheduledThreadPool(String threadName, int poolSize,
- int keepAliveMillis, ThreadsMonitoring threadsMonitoring) {
- ScheduledThreadPoolExecutorWithKeepAlive result =
- new ScheduledThreadPoolExecutorWithKeepAlive(poolSize,
- keepAliveMillis, MILLISECONDS, new LoggingThreadFactory(threadName),
- threadsMonitoring);
- result.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
- result.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
- return result;
+ public static ExecutorService newThreadPoolWithUnlimitedFeed(int poolSize, long keepAliveTime,
+ TimeUnit unit, String threadName, ThreadInitializer threadInitializer,
+ CommandWrapper commandWrapper, PoolStatHelper poolStatsHelper,
+ ThreadsMonitoring threadsMonitoring) {
+ LinkedBlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
+ ThreadFactory threadFactory =
+ new LoggingThreadFactory(threadName, threadInitializer, commandWrapper);
+ return new PooledExecutorWithDMStats(poolSize, keepAliveTime, unit, workQueue, threadFactory,
+ poolStatsHelper, threadsMonitoring);
}
private CoreLoggingExecutors() {
// no instances allowed
}
+ private static BlockingQueue<Runnable> createWorkQueueWithStatistics(int workQueueSize,
+ QueueStatHelper queueStatHelper) {
+ BlockingQueue<Runnable> workQueue;
+ if (workQueueSize == 0) {
+ workQueue = new OverflowQueueWithDMStats<>(queueStatHelper);
+ } else {
+ workQueue = new OverflowQueueWithDMStats<>(workQueueSize, queueStatHelper);
+ }
+ return workQueue;
+ }
+
+ private static int getIdleThreadTimeoutMillis() {
+ return getInteger(GEMFIRE_PREFIX + IDLE_THREAD_TIMEOUT_MILLIS_PROPERTY,
+ DEFAULT_IDLE_THREAD_TIMEOUT_MILLIS);
+ }
+
}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/tcp/ConnectionTable.java b/geode-core/src/main/java/org/apache/geode/internal/tcp/ConnectionTable.java
index a5c43f9..df9a4a5 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/tcp/ConnectionTable.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/tcp/ConnectionTable.java
@@ -14,6 +14,9 @@
*/
package org.apache.geode.internal.tcp;
+import static java.lang.Integer.MAX_VALUE;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.io.Closeable;
import java.io.IOException;
import java.lang.ref.Reference;
@@ -211,8 +214,8 @@ public class ConnectionTable {
if (conserveSockets) {
return LoggingExecutors.newThreadOnEachExecute("SharedP2PReader");
}
- return CoreLoggingExecutors.newThreadPoolWithSynchronousFeed("UnsharedP2PReader", 1,
- Integer.MAX_VALUE, READER_POOL_KEEP_ALIVE_TIME);
+ return CoreLoggingExecutors.newThreadPoolWithSynchronousFeed(1, MAX_VALUE,
+ READER_POOL_KEEP_ALIVE_TIME, SECONDS, "UnsharedP2PReader");
}
/** conduit calls acceptConnection after an accept */
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/SystemManagementService.java b/geode-core/src/main/java/org/apache/geode/management/internal/SystemManagementService.java
index 2e9403e..1d36426 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/SystemManagementService.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/SystemManagementService.java
@@ -587,8 +587,8 @@ public class SystemManagementService extends BaseManagementService {
federatingManager = federatingManagerFactory.create(repo, system, this, cache,
statisticsFactory, statisticsClock, new MBeanProxyFactory(jmxAdapter, this),
new MemberMessenger(jmxAdapter, system),
- () -> LoggingExecutors.newFixedThreadPool("FederatingManager", true,
- Runtime.getRuntime().availableProcessors()));
+ () -> LoggingExecutors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(),
+ "FederatingManager", true));
cache.getJmxManagerAdvisor().broadcastChange();
return true;
}
diff --git a/geode-logging/src/main/java/org/apache/geode/logging/internal/executors/LoggingExecutors.java b/geode-logging/src/main/java/org/apache/geode/logging/internal/executors/LoggingExecutors.java
index 2f35e9e..ef3ca66 100644
--- a/geode-logging/src/main/java/org/apache/geode/logging/internal/executors/LoggingExecutors.java
+++ b/geode-logging/src/main/java/org/apache/geode/logging/internal/executors/LoggingExecutors.java
@@ -14,12 +14,15 @@
*/
package org.apache.geode.logging.internal.executors;
+import static java.lang.Integer.MAX_VALUE;
+import static java.util.concurrent.ForkJoinPool.defaultForkJoinWorkerThreadFactory;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory;
import java.util.concurrent.ForkJoinWorkerThread;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
@@ -31,84 +34,81 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class LoggingExecutors {
- public static ScheduledExecutorService newScheduledThreadPool(String threadName, int poolSize,
- boolean executeDelayedTasks) {
- ScheduledThreadPoolExecutor result =
- new ScheduledThreadPoolExecutor(poolSize, new LoggingThreadFactory(threadName));
- result.setExecuteExistingDelayedTasksAfterShutdownPolicy(executeDelayedTasks);
- return result;
- }
- public static ExecutorService newFixedThreadPoolWithFeedSize(String threadName,
- int poolSize, int feedSize) {
- LinkedBlockingQueue<Runnable> feed = new LinkedBlockingQueue<>(feedSize);
- RejectedExecutionHandler rejectionHandler = new ThreadPoolExecutor.CallerRunsPolicy();
- ThreadFactory threadFactory = new LoggingThreadFactory(threadName);
- ThreadPoolExecutor executor = new ThreadPoolExecutor(poolSize, poolSize, 10, SECONDS, feed,
- threadFactory, rejectionHandler);
- executor.allowCoreThreadTimeOut(true);
- return executor;
+ public static ExecutorService newCachedThreadPool(String threadName, boolean isDaemon) {
+ ThreadFactory threadFactory = new LoggingThreadFactory(threadName, isDaemon);
+ SynchronousQueue<Runnable> workQueue = new SynchronousQueue<>();
+ return new ThreadPoolExecutor(0, MAX_VALUE, 60, SECONDS, workQueue, threadFactory);
}
- public static ExecutorService newSingleThreadExecutor(String threadName, boolean isDaemon) {
+ public static ThreadPoolExecutor newFixedThreadPool(int poolSize, long keepAliveTime,
+ TimeUnit unit, BlockingQueue<Runnable> workQueue, String threadName, boolean isDaemon) {
ThreadFactory threadFactory = new LoggingThreadFactory(threadName, isDaemon);
- return new ThreadPoolExecutor(1, 1, 0L, SECONDS,
- new LinkedBlockingQueue<Runnable>(),
+ return new ThreadPoolExecutor(poolSize, poolSize, keepAliveTime, unit, workQueue,
threadFactory);
}
- public static ExecutorService newCachedThreadPool(String threadName, boolean isDaemon) {
- ThreadFactory threadFactory = new LoggingThreadFactory(threadName, isDaemon);
- return new ThreadPoolExecutor(0, Integer.MAX_VALUE,
- 60L, TimeUnit.SECONDS,
- new SynchronousQueue<Runnable>(),
- threadFactory);
+ private static ThreadPoolExecutor newFixedThreadPool(int poolSize, long keepAliveTime,
+ TimeUnit unit, String threadName, boolean isDaemon) {
+ BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
+ return newFixedThreadPool(poolSize, keepAliveTime, unit, workQueue, threadName, isDaemon);
}
- public static ExecutorService newWorkStealingPool(String threadName, int maxParallelThreads) {
- final ForkJoinPool.ForkJoinWorkerThreadFactory factory = pool -> {
- ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
- LoggingUncaughtExceptionHandler.setOnThread(worker);
- worker.setName(threadName + worker.getPoolIndex());
- return worker;
- };
- return new ForkJoinPool(maxParallelThreads, factory, null, true);
+ public static ExecutorService newFixedThreadPool(int poolSize, String threadName,
+ boolean isDaemon) {
+ return newFixedThreadPool(poolSize, 0, SECONDS, threadName, isDaemon);
}
- public static Executor newThreadOnEachExecute(String threadName) {
- return command -> new LoggingThread(threadName, command).start();
+ public static ExecutorService newFixedThreadPoolWithFeedSize(int poolSize, int workQueueSize,
+ String threadName) {
+ LinkedBlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(workQueueSize);
+ ThreadFactory threadFactory = new LoggingThreadFactory(threadName);
+ RejectedExecutionHandler rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy();
+ ThreadPoolExecutor executor = new ThreadPoolExecutor(poolSize, poolSize, 10, SECONDS, workQueue,
+ threadFactory, rejectedExecutionHandler);
+ executor.allowCoreThreadTimeOut(true);
+ return executor;
}
- public static ScheduledExecutorService newScheduledThreadPool(String threadName, int poolSize) {
- return newScheduledThreadPool(threadName, poolSize, true);
+ public static ExecutorService newFixedThreadPoolWithTimeout(int poolSize, int keepAliveTime,
+ TimeUnit unit, String threadName) {
+ return newFixedThreadPool(poolSize, keepAliveTime, unit, threadName, true);
}
- public static ScheduledExecutorService newSingleThreadScheduledExecutor(String threadName) {
- return newScheduledThreadPool(threadName, 1);
+ public static ScheduledExecutorService newScheduledThreadPool(int poolSize, String threadName) {
+ return newScheduledThreadPool(poolSize, threadName, true);
+ }
+
+ public static ScheduledExecutorService newScheduledThreadPool(int poolSize, String threadName,
+ boolean executeDelayedTasks) {
+ LoggingThreadFactory threadFactory = new LoggingThreadFactory(threadName);
+ ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(poolSize, threadFactory);
+ executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(executeDelayedTasks);
+ return executor;
}
- public static ThreadPoolExecutor newFixedThreadPool(String threadName, boolean isDaemon,
- int poolSize, long keepAliveSeconds,
- BlockingQueue<Runnable> feed) {
+ public static ExecutorService newSingleThreadExecutor(String threadName, boolean isDaemon) {
+ LinkedBlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
ThreadFactory threadFactory = new LoggingThreadFactory(threadName, isDaemon);
- return new ThreadPoolExecutor(poolSize, poolSize,
- keepAliveSeconds, SECONDS,
- feed, threadFactory);
+ return new ThreadPoolExecutor(1, 1, 0, SECONDS, workQueue, threadFactory);
}
- private static ThreadPoolExecutor newFixedThreadPool(String threadName, boolean isDaemon,
- long keepAliveSeconds, int poolSize) {
- LinkedBlockingQueue<Runnable> feed = new LinkedBlockingQueue<>();
- return newFixedThreadPool(threadName, isDaemon, poolSize, keepAliveSeconds, feed);
+ public static ScheduledExecutorService newSingleThreadScheduledExecutor(String threadName) {
+ return newScheduledThreadPool(1, threadName);
}
- public static ExecutorService newFixedThreadPool(String threadName, boolean isDaemon,
- int poolSize) {
- return newFixedThreadPool(threadName, isDaemon, 0L, poolSize);
+ /** Used for P2P Reader Threads in ConnectionTable */
+ public static Executor newThreadOnEachExecute(String threadName) {
+ return command -> new LoggingThread(threadName, command).start();
}
- public static ExecutorService newFixedThreadPoolWithTimeout(String threadName, int poolSize,
- int keepAliveSeconds) {
- return newFixedThreadPool(threadName, true, keepAliveSeconds, poolSize);
+ public static ExecutorService newWorkStealingPool(String threadName, int maximumParallelThreads) {
+ ForkJoinWorkerThreadFactory factory = pool -> {
+ ForkJoinWorkerThread worker = defaultForkJoinWorkerThreadFactory.newThread(pool);
+ LoggingUncaughtExceptionHandler.setOnThread(worker);
+ worker.setName(threadName + worker.getPoolIndex());
+ return worker;
+ };
+ return new ForkJoinPool(maximumParallelThreads, factory, null, true);
}
}
diff --git a/geode-logging/src/main/java/org/apache/geode/logging/internal/executors/LoggingThreadFactory.java b/geode-logging/src/main/java/org/apache/geode/logging/internal/executors/LoggingThreadFactory.java
index a8d7efa..b85a32f 100644
--- a/geode-logging/src/main/java/org/apache/geode/logging/internal/executors/LoggingThreadFactory.java
+++ b/geode-logging/src/main/java/org/apache/geode/logging/internal/executors/LoggingThreadFactory.java
@@ -22,25 +22,30 @@ import java.util.concurrent.atomic.AtomicInteger;
* log uncaught exceptions. They will also always be daemon
* and have unique names that contain the "baseName" passed
* to the constructor.
+ *
* <p>
* What happens each time a thread is created can be customized
* using the optional "threadInitializer".
+ *
* <p>
* What happens each time a thread is run can be customized
* using the optional "commandWrapper".
*/
public class LoggingThreadFactory implements ThreadFactory {
+ private final AtomicInteger threadCount = new AtomicInteger(1);
+
private final String baseName;
private final CommandWrapper commandWrapper;
private final ThreadInitializer threadInitializer;
private final boolean isDaemon;
- private final AtomicInteger threadCount = new AtomicInteger(1);
+ @FunctionalInterface
public interface ThreadInitializer {
void initialize(Thread thread);
}
+ @FunctionalInterface
public interface CommandWrapper {
/**
* Invoke the current method passing it a runnable that it can
@@ -108,10 +113,6 @@ public class LoggingThreadFactory implements ThreadFactory {
this(baseName, null, commandWrapper, true);
}
- private String getUniqueName() {
- return baseName + threadCount.getAndIncrement();
- }
-
@Override
public Thread newThread(Runnable runnable) {
Runnable commandToRun;
@@ -126,4 +127,8 @@ public class LoggingThreadFactory implements ThreadFactory {
}
return thread;
}
+
+ private String getUniqueName() {
+ return baseName + threadCount.getAndIncrement();
+ }
}
diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMembership.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMembership.java
index 9743031..c8135a9 100644
--- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMembership.java
+++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMembership.java
@@ -812,7 +812,7 @@ public class GMSMembership<ID extends MemberIdentifier> implements Membership<ID
/** starts periodic task to perform cleanup chores such as expire surprise members */
private void startCleanupTimer() {
this.cleanupTimer =
- LoggingExecutors.newScheduledThreadPool("GMSMembership.cleanupTimer", 1, false);
+ LoggingExecutors.newScheduledThreadPool(1, "GMSMembership.cleanupTimer", false);
this.cleanupTimer.scheduleAtFixedRate(this::cleanUpSurpriseMembers, surpriseMemberTimeout,
surpriseMemberTimeout / 3, TimeUnit.MILLISECONDS);
diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
index 5992467..c9ae6a4 100644
--- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
+++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
@@ -672,7 +672,7 @@ public class GMSHealthMonitor<ID extends MemberIdentifier> implements HealthMoni
@Override
public void start() throws MemberStartupException {
- scheduler = LoggingExecutors.newScheduledThreadPool("Geode Failure Detection Scheduler", 1);
+ scheduler = LoggingExecutors.newScheduledThreadPool(1, "Geode Failure Detection Scheduler");
checkExecutor = LoggingExecutors.newCachedThreadPool("Geode Failure Detection thread ", true);
Monitor m = this.new Monitor(memberTimeout);
monitorInterval = memberTimeout / LOGICAL_INTERVAL;
diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index 095ae33..8a75c81 100644
--- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -2736,9 +2736,8 @@ public class GMSJoinLeave<ID extends MemberIdentifier> implements JoinLeave<ID>
}
logger.debug("checking availability of these members: {}", checkers);
- ExecutorService svc =
- LoggingExecutors.newFixedThreadPool("Geode View Creator verification thread ",
- true, suspects.size());
+ ExecutorService svc = LoggingExecutors.newFixedThreadPool(suspects.size(),
+ "Geode View Creator verification thread ", true);
try {
long giveUpTime = System.currentTimeMillis() + viewAckTimeout;
// submit the tasks that will remove dead members from the suspects collection