public final class OperationExecutorImpl extends Object implements OperationExecutor, MetricsProvider
OperationExecutor that schedules:
execute(Object, int, boolean) accepts an Object instead of a runnable to prevent needing to
create wrapper runnables around tasks. This is done to reduce the amount of object litter and therefor
reduce pressure on the GC.
There are 2 category of operation threads:
| Modifier and Type | Field and Description |
|---|---|
static HazelcastProperty |
IDLE_STRATEGY |
| Constructor and Description |
|---|
OperationExecutorImpl(HazelcastProperties properties,
LoggingService loggerService,
Address thisAddress,
OperationRunnerFactory runnerFactory,
NodeExtension nodeExtension,
String hzName,
ClassLoader configClassLoader) |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(Packet packet)
Performs this operation on the given argument.
|
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() |
int |
getQueueSize() |
int |
getRunningOperationCount() |
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 |
populate(LiveOperations liveOperations)
Populate the LiveOperations
|
void |
provideMetrics(MetricsRegistry registry) |
void |
run(Operation operation)
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.
|
int |
toPartitionThreadIndex(int partitionId) |
String |
toString() |
public static final HazelcastProperty IDLE_STRATEGY
public OperationExecutorImpl(HazelcastProperties properties, LoggingService loggerService, Address thisAddress, OperationRunnerFactory runnerFactory, NodeExtension nodeExtension, String hzName, ClassLoader configClassLoader)
public void provideMetrics(MetricsRegistry registry)
provideMetrics in interface MetricsProviderpublic OperationRunner[] getPartitionOperationRunners()
OperationExecutorgetPartitionOperationRunners in interface OperationExecutorpublic OperationRunner[] getGenericOperationRunners()
OperationExecutorgetGenericOperationRunners in interface OperationExecutorpublic void populate(LiveOperations liveOperations)
LiveOperationsTrackerpopulate in interface LiveOperationsTrackerliveOperations - the LiveOperations to populate.public int getRunningOperationCount()
getRunningOperationCount in interface OperationExecutorpublic int getQueueSize()
getQueueSize in interface OperationExecutorpublic int getPriorityQueueSize()
getPriorityQueueSize in interface OperationExecutorpublic long getExecutedOperationCount()
OperationExecutorgetExecutedOperationCount in interface OperationExecutorpublic int getPartitionThreadCount()
OperationExecutorgetPartitionThreadCount in interface OperationExecutorpublic int getGenericThreadCount()
OperationExecutorgetGenericThreadCount in interface OperationExecutorpublic int getPartitionThreadId(int partitionId)
OperationExecutorgetPartitionThreadId in interface OperationExecutorpartitionId - given partitionIdpublic void execute(Operation op)
OperationExecutorOperation at some point in the future.execute in interface OperationExecutorop - the operation to execute.public void executeOnPartitions(PartitionTaskFactory taskFactory, BitSet partitions)
OperationExecutorOperationExecutor.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!executeOnPartitions in interface OperationExecutortaskFactory - 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.public void execute(PartitionSpecificRunnable task)
OperationExecutorPartitionSpecificRunnable at some point in the
future.execute in interface OperationExecutortask - the task the execute.public void accept(Packet packet)
Consumerpublic void executeOnPartitionThreads(Runnable task)
OperationExecutorexecuteOnPartitionThreads in interface OperationExecutortask - the task the execute.public void run(Operation operation)
OperationExecutorOperation on the calling thread.run in interface OperationExecutoroperation - the Operation to run.public void runOrExecute(Operation op)
OperationExecutorOperation on the calling thread if allowed.
Otherwise the operation is submitted for executing using
OperationExecutor.execute(Operation).runOrExecute in interface OperationExecutorop - the Operation to run or execute.public boolean isRunAllowed(Operation op)
OperationExecutorOperation is allowed to run on the current thread.isRunAllowed in interface OperationExecutorop - the Operation to checkpublic boolean isInvocationAllowed(Operation op, boolean isAsync)
OperationExecutorOperation 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.isInvocationAllowed in interface OperationExecutorop - the Operation to checkisAsync - is the invocation async, if false invocation does not return
a future to block onpublic int toPartitionThreadIndex(int partitionId)
public void start()
OperationExecutorstart in interface OperationExecutorpublic void shutdown()
OperationExecutorshutdown in interface OperationExecutorCopyright © 2020 Hazelcast, Inc.. All Rights Reserved.