Package org.apache.cassandra.concurrent
Interface ExecutorFactory
-
- All Superinterfaces:
ExecutorBuilderFactory<ExecutorPlus,SequentialExecutorPlus>
,ExecutorBuilderFactory.Jmxable<ExecutorPlus,SequentialExecutorPlus>
- All Known Implementing Classes:
ExecutorFactory.Default
public interface ExecutorFactory extends ExecutorBuilderFactory.Jmxable<ExecutorPlus,SequentialExecutorPlus>
Entry point for configuring and creating new executors. Supports quick and easy construction of default-configured executors viaExecutorBuilderFactory.sequential(String)
ExecutorBuilderFactory.pooled(String, int)
scheduled(String)
scheduled(boolean, String)
scheduled(boolean, String, int)
Supports custom configuration of executors viaExecutorBuilderFactory.configureSequential(String)
ExecutorBuilderFactory.configurePooled(String, int)
Supports any of the above with added JMX registration via sub-factoriesExecutorBuilderFactory.Jmxable.withJmx(String)
ExecutorBuilderFactory.Jmxable.withJmxInternal()
Supports any of the above with the resultant executor propagatingExecutorLocals
via sub-factorylocalAware()
Supports shared executors via sub-factorylocalAware().withJMX()
usingExecutorFactory.LocalAwareSubFactoryWithJMX.shared(String, int, ExecutorPlus.MaximumPoolSizeListener)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ExecutorFactory.Default
static class
ExecutorFactory.Global
static interface
ExecutorFactory.LocalAwareSubFactory
static interface
ExecutorFactory.LocalAwareSubFactoryWithJMX
static class
ExecutorFactory.SimulatorSemantics
-
Nested classes/interfaces inherited from interface org.apache.cassandra.concurrent.ExecutorBuilderFactory
ExecutorBuilderFactory.Jmxable<E extends ExecutorPlus,S extends SequentialExecutorPlus>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Interruptible
infiniteLoop(java.lang.String name, Interruptible.SimpleTask task, InfiniteLoopExecutor.SimulatorSafe simulatorSafe)
Create and start a new InfiniteLoopExecutor to repeatedly invokerunnable
.Interruptible
infiniteLoop(java.lang.String name, Interruptible.Task task, InfiniteLoopExecutor.SimulatorSafe simulatorSafe, InfiniteLoopExecutor.Daemon daemon, InfiniteLoopExecutor.Interrupts interrupts)
Create and start a new InfiniteLoopExecutor to repeatedly invokerunnable
.ExecutorFactory.LocalAwareSubFactory
localAware()
java.lang.ThreadGroup
newThreadGroup(java.lang.String name)
Create a new thread group for use with builders - this thread group will be situated within this factory's parent thread group, and may be supplied to multiple executor builders.default ScheduledExecutorPlus
scheduled(boolean executeOnShutdown, java.lang.String name)
default ScheduledExecutorPlus
scheduled(boolean executeOnShutdown, java.lang.String name, int priority)
ScheduledExecutorPlus
scheduled(boolean executeOnShutdown, java.lang.String name, int priority, ExecutorFactory.SimulatorSemantics simulatorSemantics)
default ScheduledExecutorPlus
scheduled(java.lang.String name)
default ScheduledExecutorPlus
scheduled(java.lang.String name, ExecutorFactory.SimulatorSemantics simulatorSemantics)
default java.lang.Thread
startThread(java.lang.String name, java.lang.Runnable runnable)
Create and start a new thread to executerunnable
; this thread will be a daemon thread.java.lang.Thread
startThread(java.lang.String name, java.lang.Runnable runnable, InfiniteLoopExecutor.Daemon daemon)
Create and start a new thread to executerunnable
-
Methods inherited from interface org.apache.cassandra.concurrent.ExecutorBuilderFactory
configurePooled, configureSequential, pooled, sequential
-
Methods inherited from interface org.apache.cassandra.concurrent.ExecutorBuilderFactory.Jmxable
withJmx, withJmxInternal
-
-
-
-
Method Detail
-
localAware
ExecutorFactory.LocalAwareSubFactory localAware()
- Returns:
- a factory that configures executors that propagate
ExecutorLocals
to the executing thread
-
scheduled
default ScheduledExecutorPlus scheduled(java.lang.String name)
- Parameters:
name
- the name of the executor, the executor's thread group, and of any worker threads- Returns:
- a default-configured
ScheduledExecutorPlus
-
scheduled
default ScheduledExecutorPlus scheduled(java.lang.String name, ExecutorFactory.SimulatorSemantics simulatorSemantics)
- Parameters:
name
- the name of the executor, the executor's thread group, and of any worker threadssimulatorSemantics
- indicate special semantics for the executor under simulation- Returns:
- a default-configured
ScheduledExecutorPlus
-
scheduled
default ScheduledExecutorPlus scheduled(boolean executeOnShutdown, java.lang.String name)
- Parameters:
executeOnShutdown
- if false, waiting tasks will be cancelled on shutdownname
- the name of the executor, the executor's thread group, and of any worker threads- Returns:
- a
ScheduledExecutorPlus
with normal thread priority
-
scheduled
default ScheduledExecutorPlus scheduled(boolean executeOnShutdown, java.lang.String name, int priority)
- Parameters:
executeOnShutdown
- if false, waiting tasks will be cancelled on shutdownname
- the name of the executor, the executor's thread group, and of any worker threadspriority
- the thread priority of workers- Returns:
- a
ScheduledExecutorPlus
-
scheduled
ScheduledExecutorPlus scheduled(boolean executeOnShutdown, java.lang.String name, int priority, ExecutorFactory.SimulatorSemantics simulatorSemantics)
- Parameters:
executeOnShutdown
- if false, waiting tasks will be cancelled on shutdownname
- the name of the executor, the executor's thread group, and of any worker threadspriority
- the thread priority of workerssimulatorSemantics
- indicate special semantics for the executor under simulation- Returns:
- a
ScheduledExecutorPlus
-
startThread
java.lang.Thread startThread(java.lang.String name, java.lang.Runnable runnable, InfiniteLoopExecutor.Daemon daemon)
Create and start a new thread to executerunnable
- Parameters:
name
- the name of the threadrunnable
- the task to executedaemon
- flag to indicate whether the thread should be a daemon or not- Returns:
- the new thread
-
startThread
default java.lang.Thread startThread(java.lang.String name, java.lang.Runnable runnable)
Create and start a new thread to executerunnable
; this thread will be a daemon thread.- Parameters:
name
- the name of the threadrunnable
- the task to execute- Returns:
- the new thread
-
infiniteLoop
Interruptible infiniteLoop(java.lang.String name, Interruptible.Task task, InfiniteLoopExecutor.SimulatorSafe simulatorSafe, InfiniteLoopExecutor.Daemon daemon, InfiniteLoopExecutor.Interrupts interrupts)
Create and start a new InfiniteLoopExecutor to repeatedly invokerunnable
. On shutdown, the executing thread will be interrupted; to support clean shutdownrunnable
should propagateInterruptedException
- Parameters:
name
- the name of the thread used to invoke the task repeatedlytask
- the task to execute repeatedlysimulatorSafe
- flag indicating if the loop thread can be intercepted / rescheduled during cluster simulationdaemon
- flag to indicate whether the loop thread should be a daemon thread or notinterrupts
- flag to indicate whether to synchronize interrupts of the task execution thread using the task's monitor this can be used to prevent interruption while performing IO operations which forbid interrupted threads. See:AbstractCommitLogSegmentManager.start()
- Returns:
- the new thread
-
infiniteLoop
default Interruptible infiniteLoop(java.lang.String name, Interruptible.SimpleTask task, InfiniteLoopExecutor.SimulatorSafe simulatorSafe)
Create and start a new InfiniteLoopExecutor to repeatedly invokerunnable
. On shutdown, the executing thread will be interrupted; to support clean shutdownrunnable
should propagateInterruptedException
- Parameters:
name
- the name of the thread used to invoke the task repeatedlytask
- the task to execute repeatedlysimulatorSafe
- flag indicating if the loop thread can be intercepted / rescheduled during cluster simulation- Returns:
- the new thread
-
newThreadGroup
java.lang.ThreadGroup newThreadGroup(java.lang.String name)
Create a new thread group for use with builders - this thread group will be situated within this factory's parent thread group, and may be supplied to multiple executor builders.
-
-