Package dev.getelements.elements.rt
Interface Scheduler
- All Known Implementing Classes:
SimpleScheduler
public interface Scheduler
The Scheduler is the main entry point dispatching requests and operations to the various
Resource instances
contained in the underlying services. This allows for both immediate and timed dispatches of various operations
to Resource instances and is responsible for coordinating and serializing access to each Resource.
Created by patricktwohig on 8/22/15.-
Method Summary
Modifier and TypeMethodDescription<T> Future<T> perform(ResourceId resourceId, Function<ResourceService.ResourceTransaction, T> operation, Consumer<Throwable> failure) Performs an action against the resource with the providedResourceId.<T> Future<T> perform(Path path, Function<ResourceService.ResourceTransaction, T> operation, Consumer<Throwable> failure) Performs an action against the resource with the providedResourceId<T> Future<T> performAfterDelay(ResourceId resourceId, long time, TimeUnit timeUnit, Function<ResourceService.ResourceTransaction, T> operation, Consumer<Throwable> failure) performAfterDelayV(ResourceId resourceId, long time, TimeUnit timeUnit, Consumer<ResourceService.ResourceTransaction> operation, Consumer<Throwable> failure) InvokeperformAfterDelay(ResourceId, long, TimeUnit, Function, Consumer)with aConsumer<Resource>instead of aFunction<Resource,.?> performV(ResourceId resourceId, Consumer<ResourceService.ResourceTransaction> operation, Consumer<Throwable> failure) Performs an action against the resource with the provided ID.performV(Path path, Consumer<ResourceService.ResourceTransaction> operation, Consumer<Throwable> failure) Performs an action against the resource with the providedPath.resumeTask(TaskId taskId, Consumer<Throwable> failure) Resumes the task associated with the suppliedTaskId.resumeTaskAfterDelay(TaskId taskId, long time, TimeUnit timeUnit, Runnable resumed, Consumer<Throwable> failure) Resumes the task associated with the suppliedTaskId.scheduleDestruction(ResourceId resourceId, long delay, TimeUnit timeUnit) Provided theResourceId, this will schedule destruction at some point in the near future, but not before.scheduleUnlink(Path path, long delay, TimeUnit timeUnit) Provided thePath, this will schedule an unlink operation at some point in the near future, but not before the delay time specified in the parameters of this method.default voidstart()Starts the Scheduler.default voidstop()Shuts down the Scheduler.<T> Future<T>
-
Method Details
-
submitV
-
submit
-
scheduleUnlink
Provided thePath, this will schedule an unlink operation at some point in the near future, but not before the delay time specified in the parameters of this method. Any pending operations to relase their locks gracefully unlink an potentially destroy anyResources associated with the suppliedPath. If theResourceis removed this will ensure that theResource.close()method is called appropriately. This returns aRunnableFuture<Void>which may be run sooner to short-circuit the unlink operation- Parameters:
path- thePathto unlink- Returns:
- a
RunnableFuture<Void>used to signal destruction, may be run sooner by the calling code
-
scheduleDestruction
Provided theResourceId, this will schedule destruction at some point in the near future, but not before. the delay specified in the arguments to this method. This allows any pending operations to scheduleRelease their locks gracefully and destroy theResourceassociated with the supplied.ResourceId. This ensures that the underlyingResourceis removed from theResourceServiceand itsResource.close()method invoked. This returns aRunnableFuture<Void>which may be run sooner to short-circuit the unlink operation- Parameters:
resourceId- theResourceId- Returns:
- a
RunnableFuture<Void>used to signal destruction, may be run sooner by the calling code
-
perform
<T> Future<T> perform(ResourceId resourceId, Function<ResourceService.ResourceTransaction, T> operation, Consumer<Throwable> failure) Performs an action against the resource with the providedResourceId.- Parameters:
resourceId- the id of the resourceoperation- the operation to perform- Returns:
Future<T>which can be used to monitor the status of the request
-
performV
default Future<Void> performV(ResourceId resourceId, Consumer<ResourceService.ResourceTransaction> operation, Consumer<Throwable> failure) Performs an action against the resource with the provided ID. -
perform
<T> Future<T> perform(Path path, Function<ResourceService.ResourceTransaction, T> operation, Consumer<Throwable> failure) Performs an action against the resource with the providedResourceId- Type Parameters:
T-- Parameters:
path- the path of the resourceoperation- the operation to perform- Returns:
Future<T>which can be used to monitor the status of the request
-
performV
default Future<Void> performV(Path path, Consumer<ResourceService.ResourceTransaction> operation, Consumer<Throwable> failure) Performs an action against the resource with the providedPath. -
performAfterDelay
<T> Future<T> performAfterDelay(ResourceId resourceId, long time, TimeUnit timeUnit, Function<ResourceService.ResourceTransaction, T> operation, Consumer<Throwable> failure) Performs the suppliedFunction<Resource,after a specified delay. The delay is calculated using the supplied time andT> TimeUnit.- Type Parameters:
T-- Parameters:
resourceId- the id of the resourcetime- the time value to delaytimeUnit- the units of the time valueoperation- the operation to perform- Returns:
Future<T>which can be used to monitor the status of the request
-
performAfterDelayV
default Future<Void> performAfterDelayV(ResourceId resourceId, long time, TimeUnit timeUnit, Consumer<ResourceService.ResourceTransaction> operation, Consumer<Throwable> failure) InvokeperformAfterDelay(ResourceId, long, TimeUnit, Function, Consumer)with aConsumer<Resource>instead of aFunction<Resource,.?> -
resumeTask
Resumes the task associated with the suppliedTaskId. This allows for the specification of a delay after a specified period of time. -
resumeTaskAfterDelay
default Future<Void> resumeTaskAfterDelay(TaskId taskId, long time, TimeUnit timeUnit, Runnable resumed, Consumer<Throwable> failure) Resumes the task associated with the suppliedTaskId. This allows for the specification of a delay after a specified period of time. -
stop
Shuts down the Scheduler. Attempting to invoke any the other methods after invoking this will result in anIllegalStateExceptionuntil a subsequent call tostart()is made.- Throws:
IllegalStateException
-
start
Starts the Scheduler. Attempting to invoke any the other methods before invoking this will result in anIllegalStateException.- Throws:
IllegalStateException
-