public class ThreadPool extends AbstractComponent implements java.io.Closeable
Modifier and Type | Class and Description |
---|---|
static class |
ThreadPool.Info |
static class |
ThreadPool.Names |
static class |
ThreadPool.ThreadPoolType |
Modifier and Type | Field and Description |
---|---|
static java.util.Map<java.lang.String,ThreadPool.ThreadPoolType> |
THREAD_POOL_TYPES |
static Setting<Settings> |
THREADPOOL_GROUP_SETTING |
deprecationLogger, logger, settings
Constructor and Description |
---|
ThreadPool(Settings settings) |
ThreadPool(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
close() |
long |
estimatedTimeInMillis() |
org.apache.lucene.util.Counter |
estimatedTimeInMillisCounter() |
java.util.concurrent.Executor |
executor(java.lang.String name)
Get the executor with the given name.
|
java.util.concurrent.Executor |
generic()
Get the generic executor.
|
ThreadContext |
getThreadContext() |
ThreadPoolInfo |
info() |
ThreadPool.Info |
info(java.lang.String name) |
java.util.concurrent.ScheduledFuture<?> |
schedule(TimeValue delay,
java.lang.String name,
java.lang.Runnable command)
Schedules a one-shot command to run after a given delay.
|
java.util.concurrent.ScheduledExecutorService |
scheduler() |
java.util.concurrent.ScheduledFuture<?> |
scheduleWithFixedDelay(java.lang.Runnable command,
TimeValue interval)
Schedules a periodic action that always runs on the scheduler thread.
|
void |
setClusterSettings(ClusterSettings clusterSettings) |
void |
shutdown() |
void |
shutdownNow() |
ThreadPoolStats |
stats() |
static boolean |
terminate(java.util.concurrent.ExecutorService service,
long timeout,
java.util.concurrent.TimeUnit timeUnit)
Returns
true if the given service was terminated successfully. |
static boolean |
terminate(ThreadPool pool,
long timeout,
java.util.concurrent.TimeUnit timeUnit)
Returns
true if the given pool was terminated successfully. |
logDeprecatedSetting, logRemovedSetting, nodeName
public static java.util.Map<java.lang.String,ThreadPool.ThreadPoolType> THREAD_POOL_TYPES
public ThreadPool(java.lang.String name)
public ThreadPool(Settings settings)
public void setClusterSettings(ClusterSettings clusterSettings)
public long estimatedTimeInMillis()
public org.apache.lucene.util.Counter estimatedTimeInMillisCounter()
public ThreadPoolInfo info()
public ThreadPool.Info info(java.lang.String name)
public ThreadPoolStats stats()
public java.util.concurrent.Executor generic()
Executor.execute(Runnable)
method will run the Runnable it is given in
the ThreadContext
of the thread that queues it.public java.util.concurrent.Executor executor(java.lang.String name)
Executor.execute(Runnable)
method will run the Runnable it is given in
the ThreadContext
of the thread that queues it.public java.util.concurrent.ScheduledExecutorService scheduler()
public java.util.concurrent.ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command, TimeValue interval)
command
- the action to takeinterval
- the delay intervalpublic java.util.concurrent.ScheduledFuture<?> schedule(TimeValue delay, java.lang.String name, java.lang.Runnable command)
threadPool.getThreadContext().preserveContext
on the runnable before passing
it to this method.delay
- delay before the task executesname
- the name of the thread pool on which to execute this task. SAME means "execute on the scheduler thread" which changes the
meaning of the ScheduledFuture returned by this method. In that case the ScheduledFuture will complete only when the command
completes.command
- the command to runpublic void shutdown()
public void shutdownNow()
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
java.lang.InterruptedException
public static boolean terminate(java.util.concurrent.ExecutorService service, long timeout, java.util.concurrent.TimeUnit timeUnit)
true
if the given service was terminated successfully. If the termination timed out,
the service is null
this method will return false
.public static boolean terminate(ThreadPool pool, long timeout, java.util.concurrent.TimeUnit timeUnit)
true
if the given pool was terminated successfully. If the termination timed out,
the service is null
this method will return false
.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public ThreadContext getThreadContext()