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()
RExecutorService
getTaskCount
in interface RExecutorService
public RFuture<Integer> getTaskCountAsync()
RExecutorServiceAsync
getTaskCountAsync
in interface RExecutorServiceAsync
public boolean hasTask(String taskId)
RExecutorService
true
if this Executor Service has task
by taskId
awaiting for execution and/or currently in executionhasTask
in interface RExecutorService
taskId
- - id of tasktrue
if this Executor Service has taskpublic Set<String> getTaskIds()
RExecutorService
getTaskIds
in interface RExecutorService
public RFuture<Set<String>> getTaskIdsAsync()
RExecutorServiceAsync
getTaskIdsAsync
in interface RExecutorServiceAsync
public RFuture<Boolean> hasTaskAsync(String taskId)
RExecutorServiceAsync
true
if this Executor Service has task
by taskId
awaiting for execution and/or currently in executionhasTaskAsync
in interface RExecutorServiceAsync
taskId
- - id of tasktrue
if this Executor Service has taskpublic int countActiveWorkers()
RExecutorService
countActiveWorkers
in interface RExecutorService
public void registerWorkers(int workers)
registerWorkers
in interface RExecutorService
public void registerWorkers(WorkerOptions options)
RExecutorService
registerWorkers
in interface RExecutorService
options
- - worker optionspublic void registerWorkers(int workers, ExecutorService executor)
registerWorkers
in interface RExecutorService
public void execute(Runnable... tasks)
RExecutorService
execute
in interface RExecutorService
tasks
- - tasks to executepublic void shutdown()
shutdown
in interface ExecutorService
public String getName()
RExecutorService
getName
in interface RExecutorService
public boolean delete()
RExecutorService
delete
in interface RExecutorService
true
if any of objects were deletedpublic RFuture<Boolean> deleteAsync()
RExecutorServiceAsync
deleteAsync
in interface RExecutorServiceAsync
true
if any of objects were deletedpublic List<Runnable> shutdownNow()
shutdownNow
in interface ExecutorService
public boolean isShutdown()
isShutdown
in interface ExecutorService
public boolean isTerminated()
isTerminated
in interface ExecutorService
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
awaitTermination
in interface ExecutorService
InterruptedException
public <T> RExecutorFuture<T> submit(Callable<T> task)
RExecutorService
get
method will return the task's result upon
successful completion.submit
in interface ExecutorService
submit
in interface RExecutorService
T
- the type of the task's resulttask
- the task to submitpublic <T> RExecutorFuture<T> submit(Callable<T> task, long timeToLive, TimeUnit timeUnit)
RExecutorService
timeToLive
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 RExecutorService
T
- 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)
RExecutorServiceAsync
timeToLive
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 RExecutorServiceAsync
T
- 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)
RExecutorServiceAsync
submitAsync
in interface RExecutorServiceAsync
T
- type of return valuetask
- - task to executepublic RExecutorBatchFuture submit(Callable<?>... tasks)
RExecutorService
submit
in interface RExecutorService
tasks
- - tasks to executeprotected TaskParameters createTaskParameters(Callable<?> task)
protected TaskParameters createTaskParameters(Runnable task)
public RExecutorBatchFuture submitAsync(Callable<?>... tasks)
RExecutorServiceAsync
submitAsync
in interface RExecutorServiceAsync
tasks
- - tasks to executepublic <T> RExecutorFuture<T> submit(Runnable task, T result)
RExecutorService
get
method will
return the given result upon successful completion.submit
in interface ExecutorService
submit
in interface RExecutorService
T
- the type of the resulttask
- the task to submitresult
- the result to returnpublic RExecutorBatchFuture submit(Runnable... tasks)
RExecutorService
submit
in interface RExecutorService
tasks
- - tasks to executepublic RExecutorBatchFuture submitAsync(Runnable... tasks)
RExecutorServiceAsync
submitAsync
in interface RExecutorServiceAsync
tasks
- - tasks to executepublic RExecutorFuture<?> submit(Runnable task)
RExecutorService
get
method will
return null
upon successful completion.submit
in interface ExecutorService
submit
in interface RExecutorService
task
- the task to submitpublic RExecutorFuture<?> submit(Runnable task, long timeToLive, TimeUnit timeUnit)
RExecutorService
timeToLive
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 RExecutorService
task
- the task to submittimeToLive
- - time to live intervaltimeUnit
- - unit of time to live intervalpublic RExecutorFuture<?> submitAsync(Runnable task, long timeToLive, TimeUnit timeUnit)
RExecutorServiceAsync
timeToLive
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 RExecutorServiceAsync
task
- the task to submittimeToLive
- - time to live intervaltimeUnit
- - unit of time to live intervalpublic RExecutorFuture<?> submitAsync(Runnable task)
RExecutorServiceAsync
submitAsync
in interface RExecutorServiceAsync
task
- - task to executepublic RScheduledFuture<?> schedule(Runnable task, long delay, TimeUnit unit)
RScheduledExecutorService
delay
. Returns a RScheduledFuture representing that task.
The Future's get
method will return the given result upon successful completion.schedule
in interface ScheduledExecutorService
schedule
in interface RScheduledExecutorService
task
- 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)
RScheduledExecutorServiceAsync
delay
. Returns a RScheduledFuture representing that task.
The Future's get
method will return the given result upon successful completion.scheduleAsync
in interface RScheduledExecutorServiceAsync
task
- 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)
RScheduledExecutorService
delay
. Returns a RScheduledFuture representing that task.
The Future's get
method will return the given result upon successful completion.schedule
in interface ScheduledExecutorService
schedule
in interface RScheduledExecutorService
V
- 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)
RScheduledExecutorServiceAsync
delay
. Returns a RScheduledFuture representing that task.
The Future's get
method will return the given result upon successful completion.scheduleAsync
in interface RScheduledExecutorServiceAsync
V
- 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)
RScheduledExecutorService
timeToLive
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 RScheduledExecutorService
command
- 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)
RScheduledExecutorServiceAsync
timeToLive
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 RScheduledExecutorServiceAsync
task
- 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)
RScheduledExecutorService
timeToLive
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 RScheduledExecutorService
V
- 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)
RScheduledExecutorServiceAsync
timeToLive
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 RScheduledExecutorServiceAsync
V
- 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)
RScheduledExecutorService
initialDelay
, 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 ScheduledExecutorService
scheduleAtFixedRate
in interface RScheduledExecutorService
task
- 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)
RScheduledExecutorServiceAsync
initialDelay
, 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 RScheduledExecutorServiceAsync
task
- 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)
RScheduledExecutorService
schedule
in interface RScheduledExecutorService
task
- - command the task to executepublic RScheduledFuture<?> scheduleAsync(Runnable task, CronSchedule cronSchedule)
RScheduledExecutorServiceAsync
scheduleAsync
in interface RScheduledExecutorServiceAsync
task
- the task to executecronSchedule
- cron schedule objectpublic RScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit)
RScheduledExecutorService
initialDelay
, 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 ScheduledExecutorService
scheduleWithFixedDelay
in interface RScheduledExecutorService
task
- 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)
RScheduledExecutorServiceAsync
initialDelay
, 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 RScheduledExecutorServiceAsync
task
- 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)
RExecutorService
cancelTask
in interface RExecutorService
taskId
- - id of tasktrue
if task has been canceled successfullyRExecutorFuture.getTaskId()
public RFuture<Boolean> cancelTaskAsync(String taskId)
RExecutorServiceAsync
cancelTaskAsync
in interface RExecutorServiceAsync
taskId
- - 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 ExecutorService
InterruptedException
ExecutionException
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
invokeAny
in interface ExecutorService
InterruptedException
ExecutionException
TimeoutException
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
invokeAll
in interface ExecutorService
InterruptedException
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
invokeAll
in interface ExecutorService
InterruptedException
Copyright © 2014–2020 Redisson. All rights reserved.