Package org.apache.cassandra.concurrent
Class WrappedExecutorPlus
java.lang.Object
org.apache.cassandra.concurrent.WrappedExecutorPlus
- All Implemented Interfaces:
Executor,ExecutorService,ExecutorPlus,ResizableThreadPool
- Direct Known Subclasses:
CompactionManager.ValidationExecutor
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.cassandra.concurrent.ExecutorPlus
ExecutorPlus.MaximumPoolSizeListener -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) voidvoidexecute(WithResources withResources, Runnable task) Invoketask.intReturns the approximate number of threads that are actively executing tasks.longReturns the approximate total number of tasks that have completed execution.intReturns core pool size of thread pool, the minimum number of workers (where that makes sense for a thread pool, SEPExecutor does not have a minimum size).intReturns maximum pool size of thread pool.intintReturns the approximate total of tasks waiting to be executed.booleaninvokeAll(Collection<? extends Callable<T>> tasks) invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) <T> TinvokeAny(Collection<? extends Callable<T>> tasks) <T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) booleanbooleanvoidMAY executetaskimmediately, if the calling thread is permitted to do so.voidsetCorePoolSize(int newCorePoolSize) Allows user to resize minimum size of the thread pool.voidsetMaximumPoolSize(int newMaximumPoolSize) Allows user to resize maximum size of the thread pool.voidshutdown()Future<?>OverridesExecutorService.submit(Runnable)to return a CassandraFuture<T> Future<T>OverridesExecutorService.submit(Runnable, Object)to return a CassandraFuture<T> Future<T>OverridesExecutorService.submit(Callable)to return a CassandraFutureFuture<?>submit(WithResources withResources, Runnable task) Invoketask, returning a future yieldingnullif successful, or the abnormal termination oftaskotherwise.<T> Future<T>submit(WithResources withResources, Runnable task, T result) Invoketask, returning a future yieldingresultif successful, or the abnormal termination oftaskotherwise.<T> Future<T>submit(WithResources withResources, Callable<T> task) Invoketask, returning a future representing this computation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.cassandra.concurrent.ResizableThreadPool
oldestTaskQueueTime
-
Field Details
-
executor
-
-
Constructor Details
-
WrappedExecutorPlus
-
-
Method Details
-
maybeExecuteImmediately
Description copied from interface:ExecutorPlusMAY executetaskimmediately, if the calling thread is permitted to do so.- Specified by:
maybeExecuteImmediatelyin interfaceExecutorPlus
-
execute
Description copied from interface:ExecutorPlusInvoketask. The invoking thread will first instantiate the resources provided before invokingtask, so that thread state may be modified and cleaned up. The invoking thread will execute something semantically equivlent to:try (Closeable close = withResources.get()) { task.run(); }- Specified by:
executein interfaceExecutorPlus- Parameters:
withResources- the resources to create and hold while executingtasktask- the task to execute
-
submit
Description copied from interface:ExecutorPlusInvoketask, returning a future representing this computation. The invoking thread will first instantiate the resources provided before invokingtask, so that thread state may be modified and cleaned up. The invoking thread will execute something semantically equivlent to:try (Closeable close = withResources.get()) { return task.call(); }- Specified by:
submitin interfaceExecutorPlus- Parameters:
withResources- the resources to create and hold while executingtasktask- the task to execute
-
submit
Description copied from interface:ExecutorPlusInvoketask, returning a future yieldingresultif successful, or the abnormal termination oftaskotherwise. The invoking thread will first instantiate the resources provided before invokingtask, so that thread state may be modified and cleaned up. The invoking thread will execute something semantically equivlent to:try (Closeable close = withResources.get()) { task.run(); return result; }- Specified by:
submitin interfaceExecutorPlus- Parameters:
withResources- the resources to create and hold while executingtasktask- the task to executeresult- the result if successful
-
submit
Description copied from interface:ExecutorPlusInvoketask, returning a future yieldingnullif successful, or the abnormal termination oftaskotherwise. The invoking thread will first instantiate the resources provided before invokingtask, so that thread state may be modified and cleaned uptry (Closeable close = withResources.get()) { task.run(); return null; }- Specified by:
submitin interfaceExecutorPlus- Parameters:
withResources- the resources to create and hold while executingtasktask- the task to execute
-
inExecutor
public boolean inExecutor()- Specified by:
inExecutorin interfaceExecutorPlus- Returns:
- true iff the caller is a worker thread actively serving this executor
-
submit
Description copied from interface:ExecutorPlusOverridesExecutorService.submit(Callable)to return a CassandraFuture- Specified by:
submitin interfaceExecutorPlus- Specified by:
submitin interfaceExecutorService
-
submit
Description copied from interface:ExecutorPlusOverridesExecutorService.submit(Runnable, Object)to return a CassandraFuture- Specified by:
submitin interfaceExecutorPlus- Specified by:
submitin interfaceExecutorService
-
submit
Description copied from interface:ExecutorPlusOverridesExecutorService.submit(Runnable)to return a CassandraFuture- Specified by:
submitin interfaceExecutorPlus- Specified by:
submitin interfaceExecutorService
-
getActiveTaskCount
public int getActiveTaskCount()Description copied from interface:ResizableThreadPoolReturns the approximate number of threads that are actively executing tasks.- Specified by:
getActiveTaskCountin interfaceResizableThreadPool- Returns:
- the number of threads
-
getCompletedTaskCount
public long getCompletedTaskCount()Description copied from interface:ResizableThreadPoolReturns the approximate total number of tasks that have completed execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.- Specified by:
getCompletedTaskCountin interfaceResizableThreadPool- Returns:
- the number of tasks
-
getPendingTaskCount
public int getPendingTaskCount()Description copied from interface:ResizableThreadPoolReturns the approximate total of tasks waiting to be executed. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation.- Specified by:
getPendingTaskCountin interfaceResizableThreadPool- Returns:
- the number of tasks
-
getMaxTasksQueued
public int getMaxTasksQueued()- Specified by:
getMaxTasksQueuedin interfaceResizableThreadPool
-
getCorePoolSize
public int getCorePoolSize()Description copied from interface:ResizableThreadPoolReturns core pool size of thread pool, the minimum number of workers (where that makes sense for a thread pool, SEPExecutor does not have a minimum size).- Specified by:
getCorePoolSizein interfaceResizableThreadPool
-
setCorePoolSize
public void setCorePoolSize(int newCorePoolSize) Description copied from interface:ResizableThreadPoolAllows user to resize minimum size of the thread pool.- Specified by:
setCorePoolSizein interfaceResizableThreadPool
-
getMaximumPoolSize
public int getMaximumPoolSize()Description copied from interface:ResizableThreadPoolReturns maximum pool size of thread pool.- Specified by:
getMaximumPoolSizein interfaceResizableThreadPool
-
setMaximumPoolSize
public void setMaximumPoolSize(int newMaximumPoolSize) Description copied from interface:ResizableThreadPoolAllows user to resize maximum size of the thread pool.- Specified by:
setMaximumPoolSizein interfaceResizableThreadPool
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorPlus- Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorPlus- Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException - Specified by:
invokeAnyin interfaceExecutorPlus- Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAnyin interfaceExecutorPlus- Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
execute
-