Class BusyExecutor
- java.lang.Object
-
- org.apache.ignite.internal.processors.query.stat.BusyExecutor
-
public class BusyExecutor extends Object
Executor with busy run support. Can run any tasks while active and safelly wait untill they stopped.
-
-
Constructor Summary
Constructors Constructor Description BusyExecutor(String name, IgniteThreadPoolExecutor pool, Supplier<Boolean> stopping, Function<Class<?>,IgniteLogger> logSupplier)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate()Allow operations.booleanbusyRun(Runnable r)Run task on busy lock.voiddeactivate()Stop all running tasks.voidexecute(Runnable r)Execute task in thread pool under busy lock.voidexecute(CancellableTask ct)Execute cancellable task in thread pool under busy lock.CompletableFuture<Boolean>submit(Runnable r)Submit task to execute in thread pool under busy lock.
-
-
-
Constructor Detail
-
BusyExecutor
public BusyExecutor(String name, IgniteThreadPoolExecutor pool, Supplier<Boolean> stopping, Function<Class<?>,IgniteLogger> logSupplier)
Constructor.- Parameters:
name- Executor name.pool- Underlying thread pool executor.stopping- External stopping state supplier.logSupplier- Log supplier.
-
-
Method Detail
-
activate
public void activate()
Allow operations.
-
deactivate
public void deactivate()
Stop all running tasks. Block new task scheduling, execute cancell runnable and wait till each task stops.
-
busyRun
public boolean busyRun(Runnable r)
Run task on busy lock.- Parameters:
r- Task to run.- Returns:
trueif task was succesfully scheduled,false- otherwise (due to inactive state).
-
submit
public CompletableFuture<Boolean> submit(Runnable r)
Submit task to execute in thread pool under busy lock. Task surrounded with try/catch and if it's complete with any exception - resulting future will return- Parameters:
r- Task to execute.- Returns:
- Completable future with executed flag in result.
-
execute
public void execute(Runnable r)
Execute task in thread pool under busy lock.- Parameters:
r- Task to execute.
-
execute
public void execute(CancellableTask ct)
Execute cancellable task in thread pool under busy lock. Track task to cancel on executor stop.- Parameters:
ct- Cancellable task to execute.
-
-