Package org.apache.ignite.thread
Class IgniteStripedThreadPoolExecutor
- java.lang.Object
-
- org.apache.ignite.thread.IgniteStripedThreadPoolExecutor
-
- All Implemented Interfaces:
Executor
,ExecutorService
,org.apache.ignite.internal.processors.pool.MetricsAwareExecutorService
public class IgniteStripedThreadPoolExecutor extends Object implements ExecutorService, org.apache.ignite.internal.processors.pool.MetricsAwareExecutorService
AnExecutorService
that executes submitted tasks using pooled grid threads.
-
-
Constructor Summary
Constructors Constructor Description IgniteStripedThreadPoolExecutor(int concurrentLvl, String igniteInstanceName, String threadNamePrefix, Thread.UncaughtExceptionHandler eHnd, boolean allowCoreThreadTimeOut, long keepAliveTime)
Create striped thread pool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
awaitTermination(long timeout, TimeUnit unit)
void
execute(Runnable cmd)
void
execute(Runnable task, int idx)
Executes the given command at some time in the future.<T> @NotNull List<Future<T>>
invokeAll(Collection<? extends Callable<T>> tasks)
<T> @NotNull List<Future<T>>
invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
<T> T
invokeAny(Collection<? extends Callable<T>> tasks)
<T> T
invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
boolean
isShutdown()
boolean
isTerminated()
void
registerMetrics(org.apache.ignite.internal.processors.metric.MetricRegistryImpl mreg)
Register thread pool metrics.void
shutdown()
List<Runnable>
shutdownNow()
@NotNull Future<?>
submit(Runnable task)
<T> @NotNull Future<T>
submit(Runnable task, T res)
<T> @NotNull Future<T>
submit(Callable<T> task)
int
threadId(int idx)
String
toString()
-
-
-
Constructor Detail
-
IgniteStripedThreadPoolExecutor
public IgniteStripedThreadPoolExecutor(int concurrentLvl, String igniteInstanceName, String threadNamePrefix, Thread.UncaughtExceptionHandler eHnd, boolean allowCoreThreadTimeOut, long keepAliveTime)
Create striped thread pool.- Parameters:
concurrentLvl
- Concurrency level.igniteInstanceName
- Node name.threadNamePrefix
- Thread name prefix.allowCoreThreadTimeOut
- Sets the policy governing whether core threads may time out and terminate if no tasks arrive within the keep-alive time.keepAliveTime
- When the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.eHnd
- Uncaught exception handler.
-
-
Method Detail
-
execute
public void execute(Runnable task, int idx)
Executes the given command at some time in the future. The command with the sameindex
will be executed in the same thread.- Parameters:
task
- the runnable taskidx
- Striped index.- Throws:
RejectedExecutionException
- if this task cannot be accepted for execution.NullPointerException
- If command is null
-
threadId
public int threadId(int idx)
- Parameters:
idx
- Index.- Returns:
- Stripped thread ID.
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceExecutorService
-
shutdownNow
public List<Runnable> shutdownNow()
- Specified by:
shutdownNow
in interfaceExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfaceExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminated
in interfaceExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
awaitTermination
in interfaceExecutorService
- Throws:
InterruptedException
-
submit
@NotNull public <T> @NotNull Future<T> submit(Callable<T> task)
- Specified by:
submit
in interfaceExecutorService
-
submit
@NotNull public <T> @NotNull Future<T> submit(Runnable task, T res)
- Specified by:
submit
in interfaceExecutorService
-
submit
@NotNull public @NotNull Future<?> submit(Runnable task)
- Specified by:
submit
in interfaceExecutorService
-
invokeAll
@NotNull public <T> @NotNull List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
- Specified by:
invokeAll
in interfaceExecutorService
-
invokeAll
@NotNull public <T> @NotNull List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
- Specified by:
invokeAll
in interfaceExecutorService
-
invokeAny
@NotNull public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
- Specified by:
invokeAny
in interfaceExecutorService
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
- Specified by:
invokeAny
in interfaceExecutorService
-
registerMetrics
public void registerMetrics(org.apache.ignite.internal.processors.metric.MetricRegistryImpl mreg)
Register thread pool metrics.- Specified by:
registerMetrics
in interfaceorg.apache.ignite.internal.processors.pool.MetricsAwareExecutorService
- Parameters:
mreg
- Metrics registry.
-
-