public class ThreadPool extends AbstractComponent
Modifier and Type | Class and Description |
---|---|
static interface |
ThreadPool.Cancellable
This interface represents an object whose execution may be cancelled during runtime.
|
static class |
ThreadPool.Info |
static class |
ThreadPool.Names |
static class |
ThreadPool.ThreadPoolType |
Modifier and Type | Field and Description |
---|---|
static org.elasticsearch.threadpool.ThreadPool.ThreadPoolTypeSettingsValidator |
THREAD_POOL_TYPE_SETTINGS_VALIDATOR |
static Map<String,ThreadPool.ThreadPoolType> |
THREAD_POOL_TYPES |
static String |
THREADPOOL_GROUP |
deprecationLogger, logger, settings
Constructor and Description |
---|
ThreadPool(Settings settings) |
ThreadPool(String name) |
Modifier and Type | Method and Description |
---|---|
static boolean |
assertNotScheduleThread(String reason) |
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
long |
estimatedTimeInMillis() |
org.apache.lucene.util.Counter |
estimatedTimeInMillisCounter() |
Executor |
executor(String name) |
Executor |
generic() |
ThreadPoolInfo |
info() |
ThreadPool.Info |
info(String name) |
ScheduledFuture<?> |
schedule(TimeValue delay,
String executor,
Runnable command)
Schedules a one-shot command to run after a given delay.
|
ScheduledExecutorService |
scheduler() |
ThreadPool.Cancellable |
scheduleWithFixedDelay(Runnable command,
TimeValue interval,
String executor)
Schedules a periodic action that runs on the specified thread pool.
|
void |
setNodeSettingsService(NodeSettingsService nodeSettingsService) |
void |
shutdown() |
void |
shutdownNow() |
ThreadPoolStats |
stats() |
static boolean |
terminate(ExecutorService service,
long timeout,
TimeUnit timeUnit)
Returns
true if the given service was terminated successfully. |
static boolean |
terminate(ThreadPool pool,
long timeout,
TimeUnit timeUnit)
Returns
true if the given pool was terminated successfully. |
void |
updateSettings(Settings settings) |
logDeprecatedSetting, logRemovedSetting, nodeName
public static Map<String,ThreadPool.ThreadPoolType> THREAD_POOL_TYPES
public static final String THREADPOOL_GROUP
public static org.elasticsearch.threadpool.ThreadPool.ThreadPoolTypeSettingsValidator THREAD_POOL_TYPE_SETTINGS_VALIDATOR
public ThreadPool(String name)
public ThreadPool(Settings settings)
public void setNodeSettingsService(NodeSettingsService nodeSettingsService)
public long estimatedTimeInMillis()
public org.apache.lucene.util.Counter estimatedTimeInMillisCounter()
public ThreadPoolInfo info()
public ThreadPool.Info info(String name)
public ThreadPoolStats stats()
public Executor generic()
public ScheduledExecutorService scheduler()
public ThreadPool.Cancellable scheduleWithFixedDelay(Runnable command, TimeValue interval, String executor)
command
- the action to takeinterval
- the delay intervalexecutor
- The name of the thread pool on which to execute this task. ThreadPool.Names.SAME
means "execute on the scheduler thread",
which there is only one of. Executing blocking or long running code on the ThreadPool.Names.SAME
thread pool should never
be done as it can cause issues with the clusterThreadPool.Cancellable
that can be used to cancel the subsequent runs of the command. If the command is running, it will
not be interrupted.public ScheduledFuture<?> schedule(TimeValue delay, String executor, Runnable command)
threadPool.getThreadContext().preserveContext
on the runnable before passing
it to this method.delay
- delay before the task executesexecutor
- 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 runEsRejectedExecutionException
- if the task cannot be scheduled for executionpublic void shutdown()
public void shutdownNow()
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
InterruptedException
public void updateSettings(Settings settings)
public static boolean terminate(ExecutorService service, long timeout, 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, 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 static boolean assertNotScheduleThread(String reason)
Copyright © 2009–2016. All rights reserved.