public class RedissonExecutorService extends Object implements RScheduledExecutorService
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,
String redissonId) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
boolean |
cancelScheduledTask(String taskId)
|
boolean |
cancelTask(String taskId)
Cancels task by id
|
int |
countActiveWorkers()
Returns active worker groups
|
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
|
<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)
Register workers
|
void |
registerWorkers(int workers,
ExecutorService executor)
Register workers with custom executor
|
<V> RScheduledFuture<V> |
schedule(Callable<V> task,
long delay,
TimeUnit unit)
Creates and executes a ScheduledFuture that becomes enabled after the
given delay.
|
RScheduledFuture<?> |
schedule(Runnable task,
CronSchedule cronSchedule)
Creates and executes a periodic action with cron schedule object.
|
RScheduledFuture<?> |
schedule(Runnable task,
long delay,
TimeUnit unit)
Creates and executes a one-shot action that becomes enabled
after the given delay.
|
<V> RScheduledFuture<V> |
scheduleAsync(Callable<V> task,
long delay,
TimeUnit unit)
Creates in async mode and executes a ScheduledFuture that becomes enabled after the
given delay.
|
RScheduledFuture<?> |
scheduleAsync(Runnable task,
CronSchedule cronSchedule)
Creates in async mode and executes a periodic action with cron schedule object.
|
RScheduledFuture<?> |
scheduleAsync(Runnable task,
long delay,
TimeUnit unit)
Creates in async mode and executes a one-shot action that becomes enabled
after the given delay.
|
RScheduledFuture<?> |
scheduleAtFixedRate(Runnable task,
long initialDelay,
long period,
TimeUnit unit)
Creates and executes a periodic action that becomes enabled first
after the given initial delay, and subsequently with the given
period; that is executions will commence after
initialDelay then initialDelay+period , then
initialDelay + 2 * period , and so on. |
RScheduledFuture<?> |
scheduleAtFixedRateAsync(Runnable task,
long initialDelay,
long period,
TimeUnit unit)
Creates in async mode and executes a periodic action that becomes enabled first
after the given initial delay, and subsequently with the given
period.
|
RScheduledFuture<?> |
scheduleWithFixedDelay(Runnable task,
long initialDelay,
long delay,
TimeUnit unit)
Creates and executes a periodic action that becomes enabled first
after the given initial delay, and subsequently with the
given delay between the termination of one execution and the
commencement of the next.
|
RScheduledFuture<?> |
scheduleWithFixedDelayAsync(Runnable task,
long initialDelay,
long delay,
TimeUnit unit)
Creates in async mode and executes a periodic action that becomes enabled first
after the given initial delay, and subsequently with the
given delay between the termination of one execution and the
commencement of the next.
|
void |
shutdown() |
List<Runnable> |
shutdownNow() |
RExecutorBatchFuture |
submit(Callable<?>... tasks)
Submits tasks batch for execution synchronously.
|
<T> RExecutorFuture<T> |
submit(Callable<T> task)
Submits a value-returning task for execution synchronously and returns a
Future representing the pending results of the task.
|
RExecutorBatchFuture |
submit(Runnable... tasks)
Submits tasks batch for execution synchronously.
|
RExecutorFuture<?> |
submit(Runnable task)
Submits a Runnable task for execution and returns a Future
representing that task.
|
<T> RExecutorFuture<T> |
submit(Runnable task,
T result)
Submits a Runnable task for execution and returns a Future
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
|
RExecutorBatchFuture |
submitAsync(Runnable... tasks)
Submits tasks batch for execution asynchronously.
|
RExecutorFuture<?> |
submitAsync(Runnable task)
Submits task 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, String redissonId)
protected String generateRequestId()
public int countActiveWorkers()
RExecutorService
countActiveWorkers
in interface RExecutorService
public void registerWorkers(int workers)
RExecutorService
registerWorkers
in interface RExecutorService
workers
- - workers amountpublic void registerWorkers(int workers, ExecutorService executor)
RExecutorService
registerWorkers
in interface RExecutorService
workers
- - workers amountexecutor
- - executor instancepublic 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> 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 executepublic 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<?> submitAsync(Runnable task)
RExecutorServiceAsync
submitAsync
in interface RExecutorServiceAsync
task
- - task to executepublic RScheduledFuture<?> schedule(Runnable task, long delay, TimeUnit unit)
RScheduledExecutorService
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
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
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
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<?> scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
RScheduledExecutorService
initialDelay
then initialDelay+period
, then
initialDelay + 2 * period
, and so on.
If any execution of the task
encounters an exception, subsequent executions are suppressed.
Otherwise, the task will only terminate via cancellation or
termination of the executor. If any execution of this task
takes longer than its period, then subsequent executions
may start late, but will not concurrently execute.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
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
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
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 cancelScheduledTask(String taskId)
RScheduledExecutorService
cancelScheduledTask
in interface RScheduledExecutorService
taskId
- of taskpublic boolean cancelTask(String taskId)
RExecutorService
cancelTask
in interface RExecutorService
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–2017 The Redisson Project. All rights reserved.