Package org.apache.ignite.internal.util
Class StripedExecutor
- java.lang.Object
-
- org.apache.ignite.internal.util.StripedExecutor
-
- All Implemented Interfaces:
Executor,ExecutorService,MetricsAwareExecutorService
- Direct Known Subclasses:
SecurityAwareStripedExecutor
public class StripedExecutor extends Object implements ExecutorService, MetricsAwareExecutorService
Striped executor.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStripedExecutor.StripeStripe.
-
Field Summary
Fields Modifier and Type Field Description static intDFLT_DATA_STREAMING_EXECUTOR_SERVICE_TASKS_STEALING_THRESHOLD
-
Constructor Summary
Constructors Constructor Description StripedExecutor(int cnt, String igniteInstanceName, String poolName, IgniteLogger log, IgniteInClosure<Throwable> errHnd, boolean stealTasks, GridWorkerListener gridWorkerLsnr, long failureDetectionTimeout)StripedExecutor(int cnt, String igniteInstanceName, String poolName, IgniteLogger log, IgniteInClosure<Throwable> errHnd, GridWorkerListener gridWorkerLsnr, long failureDetectionTimeout)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intactiveStripesCount()voidawaitComplete(int... stripes)Method for await all task completion in some specific striped indexes or all.booleanawaitTermination(long timeout, @NotNull TimeUnit unit)longcompletedTasks()booleandetectStarvation()Checks starvation in striped pool.voidexecute(int idx, Runnable cmd)Execute command.voidexecute(@NotNull Runnable cmd)<T> @NotNull List<Future<T>>invokeAll(@NotNull Collection<? extends Callable<T>> tasks)Operation not supported.<T> @NotNull List<Future<T>>invokeAll(@NotNull Collection<? extends Callable<T>> tasks, long timeout, @NotNull TimeUnit unit)Operation not supported.<T> TinvokeAny(@NotNull Collection<? extends Callable<T>> tasks)Operation not supported.<T> TinvokeAny(@NotNull Collection<? extends Callable<T>> tasks, long timeout, @NotNull TimeUnit unit)Operation not supported.booleanisShutdown()booleanisTerminated()intqueueSize()intqueueStripeSize(int idx)voidregisterMetrics(MetricRegistryImpl mreg)Register thread pool metrics.voidshutdown()@NotNull List<Runnable>shutdownNow()voidstop()Stops executor.StripedExecutor.Stripe[]stripes()boolean[]stripesActiveStatuses()long[]stripesCompletedTasks()intstripesCount()int[]stripesQueueSizes()@NotNull Future<?>submit(@NotNull Runnable task)Operation not supported.<T> @NotNull Future<T>submit(@NotNull Runnable task, T res)Operation not supported.<T> @NotNull Future<T>submit(@NotNull Callable<T> task)Operation not supported.StringtoString()
-
-
-
Constructor Detail
-
StripedExecutor
public StripedExecutor(int cnt, String igniteInstanceName, String poolName, IgniteLogger log, IgniteInClosure<Throwable> errHnd, GridWorkerListener gridWorkerLsnr, long failureDetectionTimeout)- Parameters:
cnt- Count.igniteInstanceName- Node name.poolName- Pool name.log- Logger.errHnd- Critical failure handler.gridWorkerLsnr- Listener to link with every stripe worker.
-
StripedExecutor
public StripedExecutor(int cnt, String igniteInstanceName, String poolName, IgniteLogger log, IgniteInClosure<Throwable> errHnd, boolean stealTasks, GridWorkerListener gridWorkerLsnr, long failureDetectionTimeout)- Parameters:
cnt- Count.igniteInstanceName- Node name.poolName- Pool name.log- Logger.errHnd- Critical failure handler.stealTasks-Trueto steal tasks.gridWorkerLsnr- listener to link with every stripe worker.
-
-
Method Detail
-
detectStarvation
public boolean detectStarvation()
Checks starvation in striped pool. Maybe too verbose but this is needed to faster debug possible issues.- Returns:
- Flag representing presence of possible starvation in striped pool.
-
stripesCount
public int stripesCount()
- Returns:
- Stripes count.
-
stripes
public StripedExecutor.Stripe[] stripes()
- Returns:
- Stripes of this executor.
-
execute
public void execute(int idx, Runnable cmd)Execute command.- Parameters:
idx- Index.cmd- Command.
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfaceExecutorService
-
execute
public void execute(@NotNull @NotNull Runnable cmd)
-
shutdownNow
@NotNull public @NotNull List<Runnable> shutdownNow()
- Specified by:
shutdownNowin interfaceExecutorService- Returns:
- Empty list (always).
-
awaitTermination
public boolean awaitTermination(long timeout, @NotNull @NotNull TimeUnit unit) throws InterruptedException- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminatedin interfaceExecutorService
-
stop
public void stop()
Stops executor.
-
queueSize
public int queueSize()
- Returns:
- Return total queue size of all stripes.
-
queueStripeSize
public int queueStripeSize(int idx)
- Parameters:
idx- Stripe index.- Returns:
- Queue size of specific stripe.
-
completedTasks
public long completedTasks()
- Returns:
- Completed tasks count.
-
stripesCompletedTasks
public long[] stripesCompletedTasks()
- Returns:
- Completed tasks per stripe count.
-
stripesActiveStatuses
public boolean[] stripesActiveStatuses()
- Returns:
- Number of active tasks per stripe.
-
activeStripesCount
public int activeStripesCount()
- Returns:
- Number of active tasks.
-
stripesQueueSizes
public int[] stripesQueueSizes()
- Returns:
- Size of queue per stripe.
-
submit
@NotNull public <T> @NotNull Future<T> submit(@NotNull @NotNull Runnable task, T res)
Operation not supported.- Specified by:
submitin interfaceExecutorService
-
submit
@NotNull public @NotNull Future<?> submit(@NotNull @NotNull Runnable task)
Operation not supported.- Specified by:
submitin interfaceExecutorService
-
submit
@NotNull public <T> @NotNull Future<T> submit(@NotNull @NotNull Callable<T> task)
Operation not supported.- Specified by:
submitin interfaceExecutorService
-
invokeAll
@NotNull public <T> @NotNull List<Future<T>> invokeAll(@NotNull @NotNull Collection<? extends Callable<T>> tasks) throws InterruptedException
Operation not supported.- Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
@NotNull public <T> @NotNull List<Future<T>> invokeAll(@NotNull @NotNull Collection<? extends Callable<T>> tasks, long timeout, @NotNull @NotNull TimeUnit unit) throws InterruptedException
Operation not supported.- Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
@NotNull public <T> T invokeAny(@NotNull @NotNull Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionExceptionOperation not supported.- Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionException
-
invokeAny
public <T> T invokeAny(@NotNull @NotNull Collection<? extends Callable<T>> tasks, long timeout, @NotNull @NotNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutExceptionOperation not supported.- Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
awaitComplete
public void awaitComplete(int... stripes) throws InterruptedExceptionMethod for await all task completion in some specific striped indexes or all. The method guarantees what all tasks which were passed before this call will be completed before method return control.- Parameters:
stripes- Striped idxs for await. Empty params means await all stripes.- Throws:
InterruptedException
-
registerMetrics
public void registerMetrics(MetricRegistryImpl mreg)
Register thread pool metrics.- Specified by:
registerMetricsin interfaceMetricsAwareExecutorService- Parameters:
mreg- Metrics registry.
-
-