public interface OperationExecutor extends Consumer<Packet>, LiveOperationsTracker
Executor
with the big difference that it is designed for assigning packets, operations
and PartitionSpecificRunnable to a thread instead of only runnables.
It depends on the implementation if an operation is executed on the calling
thread or not. For example the OperationExecutorImpl
will always
offload a partition specific Operation to the correct partition-operation-thread.
The actual processing of a operation-packet, Operation, or a
PartitionSpecificRunnable is forwarded to the OperationRunner
.Modifier and Type | Method and Description |
---|---|
void |
execute(Operation op)
Executes the given
Operation at some point in the future. |
void |
execute(PartitionSpecificRunnable task)
Executes the given
PartitionSpecificRunnable at some point in the
future. |
void |
executeOnPartitions(PartitionTaskFactory taskFactory,
BitSet partitions)
Executes a task from the taskFactory for each of the given partitions.
|
void |
executeOnPartitionThreads(Runnable task)
Executes the task on every partition thread.
|
long |
getExecutedOperationCount()
Returns the number of executed operations.
|
OperationRunner[] |
getGenericOperationRunners()
Gets all the generic operation handlers.
|
int |
getGenericThreadCount()
Returns the number of generic threads.
|
OperationRunner[] |
getPartitionOperationRunners()
Gets all the operation handlers for the partitions.
|
int |
getPartitionThreadCount()
Returns the number of partition threads.
|
int |
getPartitionThreadId(int partitionId)
Returns the ID of the partitionThread assigned to handle partition
with given partitionId
|
int |
getPriorityQueueSize()
Deprecated.
|
int |
getQueueSize()
Deprecated.
|
int |
getRunningOperationCount()
Deprecated.
|
boolean |
isInvocationAllowed(Operation op,
boolean isAsync)
Checks if the
Operation is allowed to be invoked from the current
thread. |
boolean |
isRunAllowed(Operation op)
Checks if the
Operation is allowed to run on the current thread. |
void |
run(Operation op)
Runs the
Operation on the calling thread. |
void |
runOrExecute(Operation op)
Tries to run the
Operation on the calling thread if allowed. |
void |
shutdown()
Shuts down this OperationExecutor.
|
void |
start()
Starts this OperationExecutor.
|
populate
@Deprecated int getRunningOperationCount()
@Deprecated int getQueueSize()
@Deprecated int getPriorityQueueSize()
long getExecutedOperationCount()
int getPartitionThreadCount()
int getGenericThreadCount()
OperationRunner[] getPartitionOperationRunners()
OperationRunner[] getGenericOperationRunners()
void execute(Operation op)
Operation
at some point in the future.op
- the operation to execute.NullPointerException
- if op is null.void executeOnPartitions(PartitionTaskFactory taskFactory, BitSet partitions)
execute(Operation)
would be called in a loop.
The consequence of this bubble is that no other operations can interleave
and this can lead to very bad latency for the other operations.
This method can be used to create Operations and Runnable's to be executed
on a partition thread.
No check is done if the partition is actually local or not!taskFactory
- the PartitionTaskFactory
responsible for creating
tasks.partitions
- the partitions to execute tasks on. This BitSet should not
modified after this method is called. For each of the
partitions there is a bit indicating if a task should be
executed on the partition.void execute(PartitionSpecificRunnable task)
PartitionSpecificRunnable
at some point in the
future.task
- the task the execute.NullPointerException
- if task is null.void executeOnPartitionThreads(Runnable task)
task
- the task the execute.NullPointerException
- if task is null.void run(Operation op)
Operation
on the calling thread.op
- the Operation
to run.NullPointerException
- if op is null.IllegalThreadStateException
- if the operation is not allowed
to be run on the calling thread.void runOrExecute(Operation op)
Operation
on the calling thread if allowed.
Otherwise the operation is submitted for executing using
execute(Operation)
.op
- the Operation
to run or execute.NullPointerException
- if op is null.boolean isRunAllowed(Operation op)
Operation
is allowed to run on the current thread.op
- the Operation
to checkNullPointerException
- if op is null.boolean isInvocationAllowed(Operation op, boolean isAsync)
Operation
is allowed to be invoked from the current
thread. Invoking means that the operation can be executed on another thread,
but that one is going to block for completion using the future.get/join etc.
Blocking for completion can cause problems, e.g. when you hog a partition
thread or deadlocks.op
- the Operation
to checkisAsync
- is the invocation async, if false invocation does not return
a future to block onint getPartitionThreadId(int partitionId)
partitionId
- given partitionIdvoid start()
void shutdown()
Copyright © 2019 Hazelcast, Inc.. All Rights Reserved.