public class AtomixWorkQueue extends io.atomix.resource.AbstractResource<AtomixWorkQueue> implements WorkQueue<byte[]>
WorkQueue primitive.DistributedPrimitive.Status, DistributedPrimitive.Type| Modifier and Type | Field and Description |
|---|---|
static String |
TASK_AVAILABLE |
DEFAULT_OPERTATION_TIMEOUT_MILLIS| Modifier | Constructor and Description |
|---|---|
protected |
AtomixWorkQueue(io.atomix.copycat.client.CopycatClient client,
Properties options) |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
addMultiple(Collection<byte[]> items)
Adds a collection of tasks to the work queue.
|
CompletableFuture<Void> |
complete(Collection<String> taskIds)
Completes a collection of tasks.
|
CompletableFuture<Void> |
destroy()
Purges state associated with this primitive.
|
String |
name()
Returns the name of this primitive.
|
CompletableFuture<AtomixWorkQueue> |
open() |
CompletableFuture<Void> |
registerTaskProcessor(Consumer<byte[]> 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<byte[]>>> |
take(int maxTasks)
Picks up multiple tasks from the work queue to work on.
|
close, config, context, delete, equals, hashCode, isClosed, isOpen, onEvent, onRecovery, onStateChange, options, recover, serializer, state, toString, typeclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddOne, complete, primitiveType, takeaddStatusChangeListener, applicationId, removeStatusChangeListener, statusChangeListenerspublic static final String TASK_AVAILABLE
protected AtomixWorkQueue(io.atomix.copycat.client.CopycatClient client,
Properties options)
public String name()
DistributedPrimitivename in interface DistributedPrimitivepublic 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 completespublic CompletableFuture<AtomixWorkQueue> open()
open in interface io.atomix.catalyst.util.Managed<AtomixWorkQueue>open in interface io.atomix.resource.Resource<AtomixWorkQueue>open in class io.atomix.resource.AbstractResource<AtomixWorkQueue>public CompletableFuture<Void> addMultiple(Collection<byte[]> items)
WorkQueueaddMultiple in interface WorkQueue<byte[]>items - collection of task itemspublic CompletableFuture<Collection<Task<byte[]>>> 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<byte[]>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> taskIds)
WorkQueuepublic CompletableFuture<Void> registerTaskProcessor(Consumer<byte[]> callback, int parallelism, Executor executor)
WorkQueueregisterTaskProcessor in interface WorkQueue<byte[]>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<byte[]>public CompletableFuture<WorkQueueStats> stats()
WorkQueue