E - task payload type.public class DefaultDistributedWorkQueue<E> extends Object implements WorkQueue<E>
WorkQueue.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERTATION_TIMEOUT_MILLIS| Constructor and Description |
|---|
DefaultDistributedWorkQueue(WorkQueue<byte[]> backingQueue,
Serializer serializer) |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
addMultiple(Collection<E> items)
Adds a collection of tasks to the work queue.
|
CompletableFuture<Void> |
complete(Collection<String> ids)
Completes a collection of tasks.
|
CompletableFuture<Void> |
destroy()
Purges state associated with this primitive.
|
String |
name()
Returns the name of this primitive.
|
CompletableFuture<Void> |
registerTaskProcessor(Consumer<E> callback,
int parallelism,
Executor executor)
Registers a task processing callback to be automatically invoked when new tasks are
added to the work queue.
|
CompletableFuture<WorkQueueStats> |
stats()
Returns work queue statistics.
|
CompletableFuture<Void> |
stopProcessing()
Stops automatically processing tasks from work queue.
|
CompletableFuture<Collection<Task<E>>> |
take(int maxTasks)
Picks up multiple tasks from the work queue to work on.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddOne, complete, primitiveType, takeaddStatusChangeListener, applicationId, removeStatusChangeListener, statusChangeListenerspublic DefaultDistributedWorkQueue(WorkQueue<byte[]> backingQueue, Serializer serializer)
public String name()
DistributedPrimitivename in interface DistributedPrimitivepublic CompletableFuture<Void> addMultiple(Collection<E> items)
WorkQueueaddMultiple in interface WorkQueue<E>items - collection of task itemspublic CompletableFuture<Collection<Task<E>>> take(int maxTasks)
WorkQueue
Tasks that are taken remain invisible to other consumers as long as the consumer stays alive.
If a consumer unexpectedly terminates before completing the task,
the task becomes visible again to other consumers to process.
take in interface WorkQueue<E>maxTasks - maximum number of items to take from the queue. The actual number of tasks returned
can be at the max this numberpublic CompletableFuture<Void> complete(Collection<String> ids)
WorkQueuepublic CompletableFuture<WorkQueueStats> stats()
WorkQueuepublic CompletableFuture<Void> registerTaskProcessor(Consumer<E> callback, int parallelism, Executor executor)
WorkQueueregisterTaskProcessor in interface WorkQueue<E>callback - task processing callbackparallelism - max tasks that can be processed in parallelexecutor - executor to use for processing the taskspublic CompletableFuture<Void> stopProcessing()
WorkQueueregisterTaskProcessor call.stopProcessing in interface WorkQueue<E>public CompletableFuture<Void> destroy()
DistributedPrimitiveImplementations can override and provide appropriate clean up logic for purging any state state associated with the primitive. Whether modifications made within the destroy method have local or global visibility is left unspecified.
destroy in interface DistributedPrimitiveCompletableFuture that is completed when the operation completes