public class RedissonExecutorService extends Object implements RScheduledExecutorService
| Modifier and Type | Class and Description |
|---|---|
static class |
RedissonExecutorService.ClassBody |
| Modifier and Type | Field and Description |
|---|---|
static int |
SHUTDOWN_STATE |
static int |
TERMINATED_STATE |
MAPREDUCE_NAME| Constructor and Description |
|---|
RedissonExecutorService(Codec codec,
CommandExecutor commandExecutor,
Redisson redisson,
String name,
QueueTransferService queueTransferService,
ConcurrentMap<String,ResponseEntry> responses,
ExecutorOptions options) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
boolean |
cancelTask(String taskId)
Cancel task by id
|
RFuture<Boolean> |
cancelTaskAsync(String taskId)
Cancel task by id
|
int |
countActiveWorkers()
Returns active workers amount available for tasks execution.
|
protected TaskParameters |
createTaskParameters(Callable<?> task) |
protected TaskParameters |
createTaskParameters(Runnable task) |
boolean |
delete()
Deletes executor request queue and state objects
|
RFuture<Boolean> |
deleteAsync()
Deletes executor request queue and state objects
|
void |
execute(Runnable... tasks)
Submits tasks batch for execution synchronously.
|
void |
execute(Runnable task) |
protected String |
generateRequestId() |
String |
getName()
Returns executor name
|
int |
getTaskCount()
Returns amount of tasks awaiting for execution and/or currently in execution.
|
RFuture<Integer> |
getTaskCountAsync()
Returns amount of tasks awaiting for execution and/or currently in execution.
|
Set<String> |
getTaskIds()
Returns list of task ids awaiting for execution and/or currently in execution.
|
RFuture<Set<String>> |
getTaskIdsAsync()
Returns list of task ids awaiting for execution and/or currently in execution.
|
boolean |
hasTask(String taskId)
Returns
true if this Executor Service has task
by taskId awaiting for execution and/or currently in execution |
RFuture<Boolean> |
hasTaskAsync(String taskId)
Returns
true if this Executor Service has task
by taskId awaiting for execution and/or currently in execution |
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks) |
<T> 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 |
registerWorkers(int workers) |
void |
registerWorkers(int workers,
ExecutorService executor) |
void |
registerWorkers(WorkerOptions options)
Register workers
|
<V> RScheduledFuture<V> |
schedule(Callable<V> task,
long delay,
TimeUnit unit)
Synchronously schedules a value-returning task for execution asynchronously
after the given
delay. |
<V> RScheduledFuture<V> |
schedule(Callable<V> callable,
long delay,
TimeUnit unit,
long timeToLive,
TimeUnit ttlUnit)
Synchronously schedules a value-returning task with defined
timeToLive parameter
for execution asynchronously after the given delay. |
RScheduledFuture<?> |
schedule(Runnable task,
CronSchedule cronSchedule)
Synchronously schedules a Runnable task for execution asynchronously
cron schedule object.
|
RScheduledFuture<?> |
schedule(Runnable task,
long delay,
TimeUnit unit)
Synchronously schedules a Runnable task for execution asynchronously
after the given
delay. |
RScheduledFuture<?> |
schedule(Runnable command,
long delay,
TimeUnit unit,
long ttl,
TimeUnit ttlUnit)
Synchronously schedules a Runnable task with defined
timeToLive parameter
for execution asynchronously after the given delay. |
<V> RScheduledFuture<V> |
scheduleAsync(Callable<V> task,
long delay,
TimeUnit unit)
Schedules a value-returning task for execution asynchronously
after the given
delay. |
<V> RScheduledFuture<V> |
scheduleAsync(Callable<V> task,
long delay,
TimeUnit unit,
long timeToLive,
TimeUnit ttlUnit)
Schedules a value-returning task with defined
timeToLive parameter
for execution asynchronously after the given delay. |
RScheduledFuture<?> |
scheduleAsync(Runnable task,
CronSchedule cronSchedule)
Synchronously schedules a Runnable task for execution asynchronously
cron schedule object.
|
RScheduledFuture<?> |
scheduleAsync(Runnable task,
long delay,
TimeUnit unit)
Schedules a Runnable task for execution asynchronously
after the given
delay. |
RScheduledFuture<?> |
scheduleAsync(Runnable task,
long delay,
TimeUnit unit,
long timeToLive,
TimeUnit ttlUnit)
Schedules a Runnable task with defined
timeToLive parameter
for execution asynchronously after the given delay. |
RScheduledFuture<?> |
scheduleAtFixedRate(Runnable task,
long initialDelay,
long period,
TimeUnit unit)
Synchronously schedules a Runnable task for execution asynchronously
after the given
initialDelay, and subsequently with the given
period. |
RScheduledFuture<?> |
scheduleAtFixedRateAsync(Runnable task,
long initialDelay,
long period,
TimeUnit unit)
Schedules a Runnable task for execution asynchronously
after the given
initialDelay, and subsequently with the given
period. |
RScheduledFuture<?> |
scheduleWithFixedDelay(Runnable task,
long initialDelay,
long delay,
TimeUnit unit)
Synchronously schedules a Runnable task for execution asynchronously
after the given
initialDelay, and subsequently with the given
delay started from the task finishing moment. |
RScheduledFuture<?> |
scheduleWithFixedDelayAsync(Runnable task,
long initialDelay,
long delay,
TimeUnit unit)
Schedules a Runnable task for execution asynchronously
after the given
initialDelay, and subsequently with the given
delay started from the task finishing moment. |
void |
shutdown() |
List<Runnable> |
shutdownNow() |
RExecutorBatchFuture |
submit(Callable<?>... tasks)
Synchronously submits tasks batch for execution asynchronously.
|
<T> RExecutorFuture<T> |
submit(Callable<T> task)
Synchronously submits a value-returning task for execution asynchronously and returns a
Future representing the pending results of the task.
|
<T> RExecutorFuture<T> |
submit(Callable<T> task,
long timeToLive,
TimeUnit timeUnit)
Synchronously submits a value-returning task with defined
timeToLive parameter
for execution asynchronously. |
RExecutorBatchFuture |
submit(Runnable... tasks)
Synchronously submits tasks batch for execution asynchronously.
|
RExecutorFuture<?> |
submit(Runnable task)
Synchronously submits a Runnable task for execution asynchronously.
|
RExecutorFuture<?> |
submit(Runnable task,
long timeToLive,
TimeUnit timeUnit)
Synchronously submits a task with defined
timeToLive parameter
for execution asynchronously. |
<T> RExecutorFuture<T> |
submit(Runnable task,
T result)
Synchronously submits a Runnable task for execution asynchronously
and returns a RExecutorFuture representing that task.
|
RExecutorBatchFuture |
submitAsync(Callable<?>... tasks)
Submits tasks batch for execution asynchronously.
|
<T> RExecutorFuture<T> |
submitAsync(Callable<T> task)
Submits task for execution asynchronously
|
<T> RExecutorFuture<T> |
submitAsync(Callable<T> task,
long timeToLive,
TimeUnit timeUnit)
Submits a value-returning task with defined
timeToLive parameter
for execution asynchronously. |
RExecutorBatchFuture |
submitAsync(Runnable... tasks)
Submits tasks batch for execution asynchronously.
|
RExecutorFuture<?> |
submitAsync(Runnable task)
Submits task for execution asynchronously
|
RExecutorFuture<?> |
submitAsync(Runnable task,
long timeToLive,
TimeUnit timeUnit)
Submits a task with defined
timeToLive parameter
for execution asynchronously. |
public static final int SHUTDOWN_STATE
public static final int TERMINATED_STATE
public RedissonExecutorService(Codec codec, CommandExecutor commandExecutor, Redisson redisson, String name, QueueTransferService queueTransferService, ConcurrentMap<String,ResponseEntry> responses, ExecutorOptions options)
protected String generateRequestId()
public int getTaskCount()
RExecutorServicegetTaskCount in interface RExecutorServicepublic RFuture<Integer> getTaskCountAsync()
RExecutorServiceAsyncgetTaskCountAsync in interface RExecutorServiceAsyncpublic boolean hasTask(String taskId)
RExecutorServicetrue if this Executor Service has task
by taskId awaiting for execution and/or currently in executionhasTask in interface RExecutorServicetaskId - - id of tasktrue if this Executor Service has taskpublic Set<String> getTaskIds()
RExecutorServicegetTaskIds in interface RExecutorServicepublic RFuture<Set<String>> getTaskIdsAsync()
RExecutorServiceAsyncgetTaskIdsAsync in interface RExecutorServiceAsyncpublic RFuture<Boolean> hasTaskAsync(String taskId)
RExecutorServiceAsynctrue if this Executor Service has task
by taskId awaiting for execution and/or currently in executionhasTaskAsync in interface RExecutorServiceAsynctaskId - - id of tasktrue if this Executor Service has taskpublic int countActiveWorkers()
RExecutorServicecountActiveWorkers in interface RExecutorServicepublic void registerWorkers(int workers)
registerWorkers in interface RExecutorServicepublic void registerWorkers(WorkerOptions options)
RExecutorServiceregisterWorkers in interface RExecutorServiceoptions - - worker optionspublic void registerWorkers(int workers,
ExecutorService executor)
registerWorkers in interface RExecutorServicepublic void execute(Runnable... tasks)
RExecutorServiceexecute in interface RExecutorServicetasks - - tasks to executepublic void shutdown()
shutdown in interface ExecutorServicepublic String getName()
RExecutorServicegetName in interface RExecutorServicepublic boolean delete()
RExecutorServicedelete in interface RExecutorServicetrue if any of objects were deletedpublic RFuture<Boolean> deleteAsync()
RExecutorServiceAsyncdeleteAsync in interface RExecutorServiceAsynctrue if any of objects were deletedpublic List<Runnable> shutdownNow()
shutdownNow in interface ExecutorServicepublic boolean isShutdown()
isShutdown in interface ExecutorServicepublic boolean isTerminated()
isTerminated in interface ExecutorServicepublic boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface ExecutorServiceInterruptedExceptionpublic <T> RExecutorFuture<T> submit(Callable<T> task)
RExecutorServiceget method will return the task's result upon
successful completion.submit in interface ExecutorServicesubmit in interface RExecutorServiceT - the type of the task's resulttask - the task to submitpublic <T> RExecutorFuture<T> submit(Callable<T> task, long timeToLive, TimeUnit timeUnit)
RExecutorServicetimeToLive parameter
for execution asynchronously. Returns a Future representing the pending
results of the task. The Future's get method will return the
task's result upon successful completion.submit in interface RExecutorServiceT - the type of the task's resulttask - the task to submittimeToLive - - time to live intervaltimeUnit - - unit of time to live intervalpublic <T> RExecutorFuture<T> submitAsync(Callable<T> task, long timeToLive, TimeUnit timeUnit)
RExecutorServiceAsynctimeToLive parameter
for execution asynchronously. Returns a Future representing the pending
results of the task. The Future's get method will return the
task's result upon successful completion.submitAsync in interface RExecutorServiceAsyncT - the type of the task's resulttask - the task to submittimeToLive - - time to live intervaltimeUnit - - unit of time to live intervalpublic <T> RExecutorFuture<T> submitAsync(Callable<T> task)
RExecutorServiceAsyncsubmitAsync in interface RExecutorServiceAsyncT - type of return valuetask - - task to executepublic RExecutorBatchFuture submit(Callable<?>... tasks)
RExecutorServicesubmit in interface RExecutorServicetasks - - tasks to executeprotected TaskParameters createTaskParameters(Callable<?> task)
protected TaskParameters createTaskParameters(Runnable task)
public RExecutorBatchFuture submitAsync(Callable<?>... tasks)
RExecutorServiceAsyncsubmitAsync in interface RExecutorServiceAsynctasks - - tasks to executepublic <T> RExecutorFuture<T> submit(Runnable task, T result)
RExecutorServiceget method will
return the given result upon successful completion.submit in interface ExecutorServicesubmit in interface RExecutorServiceT - the type of the resulttask - the task to submitresult - the result to returnpublic RExecutorBatchFuture submit(Runnable... tasks)
RExecutorServicesubmit in interface RExecutorServicetasks - - tasks to executepublic RExecutorBatchFuture submitAsync(Runnable... tasks)
RExecutorServiceAsyncsubmitAsync in interface RExecutorServiceAsynctasks - - tasks to executepublic RExecutorFuture<?> submit(Runnable task)
RExecutorServiceget method will
return null upon successful completion.submit in interface ExecutorServicesubmit in interface RExecutorServicetask - the task to submitpublic RExecutorFuture<?> submit(Runnable task, long timeToLive, TimeUnit timeUnit)
RExecutorServicetimeToLive parameter
for execution asynchronously. Returns a Future representing task completion.
The Future's get method will return the
task's result upon successful completion.submit in interface RExecutorServicetask - the task to submittimeToLive - - time to live intervaltimeUnit - - unit of time to live intervalpublic RExecutorFuture<?> submitAsync(Runnable task, long timeToLive, TimeUnit timeUnit)
RExecutorServiceAsynctimeToLive parameter
for execution asynchronously. Returns a Future representing task completion.
The Future's get method will return the
task's result upon successful completion.submitAsync in interface RExecutorServiceAsynctask - the task to submittimeToLive - - time to live intervaltimeUnit - - unit of time to live intervalpublic RExecutorFuture<?> submitAsync(Runnable task)
RExecutorServiceAsyncsubmitAsync in interface RExecutorServiceAsynctask - - task to executepublic RScheduledFuture<?> schedule(Runnable task, long delay, TimeUnit unit)
RScheduledExecutorServicedelay. Returns a RScheduledFuture representing that task.
The Future's get method will return the given result upon successful completion.schedule in interface ScheduledExecutorServiceschedule in interface RScheduledExecutorServicetask - the task to executedelay - the time from now to delay executionunit - the time unit of the delay parameterget() method will return
null upon completionpublic RScheduledFuture<?> scheduleAsync(Runnable task, long delay, TimeUnit unit)
RScheduledExecutorServiceAsyncdelay. Returns a RScheduledFuture representing that task.
The Future's get method will return the given result upon successful completion.scheduleAsync in interface RScheduledExecutorServiceAsynctask - the task to executedelay - the time from now to delay executionunit - the time unit of the delay parameterpublic <V> RScheduledFuture<V> schedule(Callable<V> task, long delay, TimeUnit unit)
RScheduledExecutorServicedelay. Returns a RScheduledFuture representing that task.
The Future's get method will return the given result upon successful completion.schedule in interface ScheduledExecutorServiceschedule in interface RScheduledExecutorServiceV - the type of the callable's resulttask - the function to executedelay - the time from now to delay executionunit - the time unit of the delay parameterpublic <V> RScheduledFuture<V> scheduleAsync(Callable<V> task, long delay, TimeUnit unit)
RScheduledExecutorServiceAsyncdelay. Returns a RScheduledFuture representing that task.
The Future's get method will return the given result upon successful completion.scheduleAsync in interface RScheduledExecutorServiceAsyncV - the type of the callable's resulttask - the function to executedelay - the time from now to delay executionunit - the time unit of the delay parameterpublic RScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit, long ttl, TimeUnit ttlUnit)
RScheduledExecutorServicetimeToLive parameter
for execution asynchronously after the given delay.
Returns a RScheduledFuture representing that task.
The Future's get method will return the given result upon successful completion.schedule in interface RScheduledExecutorServicecommand - the task to executedelay - the time from now to delay executionunit - the time unit of the delay parameterttl - - time to live intervalttlUnit - - unit of time to live intervalget() method will return
null upon completionpublic RScheduledFuture<?> scheduleAsync(Runnable task, long delay, TimeUnit unit, long timeToLive, TimeUnit ttlUnit)
RScheduledExecutorServiceAsynctimeToLive parameter
for execution asynchronously after the given delay.
Returns a RScheduledFuture representing that task.
The Future's get method will return the given result upon successful completion.scheduleAsync in interface RScheduledExecutorServiceAsynctask - the task to executedelay - the time from now to delay executionunit - the time unit of the delay parametertimeToLive - - time to live intervalttlUnit - - unit of time to live intervalpublic <V> RScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit, long timeToLive, TimeUnit ttlUnit)
RScheduledExecutorServicetimeToLive parameter
for execution asynchronously after the given delay.
Returns a RScheduledFuture representing that task.
The Future's get method will return the given result upon successful completion.schedule in interface RScheduledExecutorServiceV - the type of the callable's resultcallable - the function to executedelay - the time from now to delay executionunit - the time unit of the delay parametertimeToLive - - time to live intervalttlUnit - - unit of time to live intervalpublic <V> RScheduledFuture<V> scheduleAsync(Callable<V> task, long delay, TimeUnit unit, long timeToLive, TimeUnit ttlUnit)
RScheduledExecutorServiceAsynctimeToLive parameter
for execution asynchronously after the given delay.
Returns a RScheduledFuture representing that task.
The Future's get method will return the given result upon successful completion.scheduleAsync in interface RScheduledExecutorServiceAsyncV - the type of the callable's resulttask - the function to executedelay - the time from now to delay executionunit - the time unit of the delay parametertimeToLive - - time to live intervalttlUnit - - unit of time to live intervalpublic RScheduledFuture<?> scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
RScheduledExecutorServiceinitialDelay, and subsequently with the given
period.
Subsequent executions are stopped if any execution of the task throws an exception.
Otherwise, task could be terminated via cancellation or
termination of the executor.scheduleAtFixedRate in interface ScheduledExecutorServicescheduleAtFixedRate in interface RScheduledExecutorServicetask - the task to executeinitialDelay - the time to delay first executionperiod - the period between successive executionsunit - the time unit of the initialDelay and period parametersget() method will throw an
exception upon cancellationpublic RScheduledFuture<?> scheduleAtFixedRateAsync(Runnable task, long initialDelay, long period, TimeUnit unit)
RScheduledExecutorServiceAsyncinitialDelay, and subsequently with the given
period.
Subsequent executions are stopped if any execution of the task throws an exception.
Otherwise, task could be terminated via cancellation or
termination of the executor.scheduleAtFixedRateAsync in interface RScheduledExecutorServiceAsynctask - the task to executeinitialDelay - the time to delay first executionperiod - the period between successive executionsunit - the time unit of the initialDelay and period parameterspublic RScheduledFuture<?> schedule(Runnable task, CronSchedule cronSchedule)
RScheduledExecutorServiceschedule in interface RScheduledExecutorServicetask - - command the task to executepublic RScheduledFuture<?> scheduleAsync(Runnable task, CronSchedule cronSchedule)
RScheduledExecutorServiceAsyncscheduleAsync in interface RScheduledExecutorServiceAsynctask - the task to executecronSchedule - cron schedule objectpublic RScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit)
RScheduledExecutorServiceinitialDelay, and subsequently with the given
delay started from the task finishing moment.
Subsequent executions are stopped if any execution of the task throws an exception.
Otherwise, task could be terminated via cancellation or
termination of the executor.scheduleWithFixedDelay in interface ScheduledExecutorServicescheduleWithFixedDelay in interface RScheduledExecutorServicetask - the task to executeinitialDelay - the time to delay first executiondelay - the delay between the termination of one
execution and the commencement of the nextunit - the time unit of the initialDelay and delay parametersget() method will throw an
exception upon cancellationpublic RScheduledFuture<?> scheduleWithFixedDelayAsync(Runnable task, long initialDelay, long delay, TimeUnit unit)
RScheduledExecutorServiceAsyncinitialDelay, and subsequently with the given
delay started from the task finishing moment.
Subsequent executions are stopped if any execution of the task throws an exception.
Otherwise, task could be terminated via cancellation or
termination of the executor.scheduleWithFixedDelayAsync in interface RScheduledExecutorServiceAsynctask - the task to executeinitialDelay - the time to delay first executiondelay - the delay between the termination of one
execution and the commencement of the nextunit - the time unit of the initialDelay and delay parameterspublic boolean cancelTask(String taskId)
RExecutorServicecancelTask in interface RExecutorServicetaskId - - id of tasktrue if task has been canceled successfullyRExecutorFuture.getTaskId()public RFuture<Boolean> cancelTaskAsync(String taskId)
RExecutorServiceAsynccancelTaskAsync in interface RExecutorServiceAsynctaskId - - id of tasktrue if task has been canceled successfullyRExecutorFuture.getTaskId()public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
invokeAny in interface ExecutorServiceInterruptedExceptionExecutionExceptionpublic <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
invokeAny in interface ExecutorServiceInterruptedExceptionExecutionExceptionTimeoutExceptionpublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedExceptionpublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedExceptionCopyright © 2014–2020 Redisson. All rights reserved.