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 |
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 |
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() |
void |
handle(Packet packet)
Signals the PacketHandler that there is a packet to be handled.
|
void |
interruptPartitionThreads()
Interrupts the partition threads.
|
boolean |
isInvocationAllowed(Operation op,
boolean isAsync)
Checks if the
Operation is allowed to be invoked from the current thread. |
boolean |
isOperationThread()
Checks if the current thread is an
Operation thread. |
boolean |
isRunAllowed(Operation op)
Checks if the
Operation is allowed to run on the current thread. |
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 |
scan(LiveOperations result) |
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 scan(LiveOperations result)
scan in interface OperationExecutorpublic 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 boolean isOperationThread()
OperationExecutorOperation thread.isOperationThread in interface OperationExecutorOperation thread, false otherwise.public 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 execute(PartitionSpecificRunnable task)
OperationExecutorPartitionSpecificRunnable at some point in the future.execute in interface OperationExecutortask - the task the execute.public void handle(Packet packet)
PacketHandlerhandle in interface PacketHandlerpacket - the response packet to handlepublic void executeOnPartitionThreads(Runnable task)
OperationExecutorexecuteOnPartitionThreads in interface OperationExecutortask - the task the execute.public void interruptPartitionThreads()
OperationExecutorinterruptPartitionThreads in interface OperationExecutorpublic 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 © 2017 Hazelcast, Inc.. All Rights Reserved.