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 MetricsProvider
public OperationRunner[] getPartitionOperationRunners()
OperationExecutor
getPartitionOperationRunners
in interface OperationExecutor
public OperationRunner[] getGenericOperationRunners()
OperationExecutor
getGenericOperationRunners
in interface OperationExecutor
public void scan(LiveOperations result)
scan
in interface OperationExecutor
public int getRunningOperationCount()
getRunningOperationCount
in interface OperationExecutor
public int getQueueSize()
getQueueSize
in interface OperationExecutor
public int getPriorityQueueSize()
getPriorityQueueSize
in interface OperationExecutor
public long getExecutedOperationCount()
OperationExecutor
getExecutedOperationCount
in interface OperationExecutor
public int getPartitionThreadCount()
OperationExecutor
getPartitionThreadCount
in interface OperationExecutor
public int getGenericThreadCount()
OperationExecutor
getGenericThreadCount
in interface OperationExecutor
public boolean isOperationThread()
OperationExecutor
Operation
thread.isOperationThread
in interface OperationExecutor
Operation
thread, false otherwise.public int getPartitionThreadId(int partitionId)
OperationExecutor
getPartitionThreadId
in interface OperationExecutor
partitionId
- given partitionIdpublic void execute(Operation op)
OperationExecutor
Operation
at some point in the future.execute
in interface OperationExecutor
op
- the operation to execute.public void execute(PartitionSpecificRunnable task)
OperationExecutor
PartitionSpecificRunnable
at some point in the future.execute
in interface OperationExecutor
task
- the task the execute.public void handle(Packet packet)
PacketHandler
handle
in interface PacketHandler
packet
- the response packet to handlepublic void executeOnPartitionThreads(Runnable task)
OperationExecutor
executeOnPartitionThreads
in interface OperationExecutor
task
- the task the execute.public void interruptPartitionThreads()
OperationExecutor
interruptPartitionThreads
in interface OperationExecutor
public void run(Operation operation)
OperationExecutor
Operation
on the calling thread.run
in interface OperationExecutor
operation
- the Operation
to run.public void runOrExecute(Operation op)
OperationExecutor
Operation
on the calling thread if allowed. Otherwise the operation is submitted for executing
using OperationExecutor.execute(Operation)
.runOrExecute
in interface OperationExecutor
op
- the Operation
to run or execute.public boolean isRunAllowed(Operation op)
OperationExecutor
Operation
is allowed to run on the current thread.isRunAllowed
in interface OperationExecutor
op
- the Operation
to checkpublic boolean isInvocationAllowed(Operation op, boolean isAsync)
OperationExecutor
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.isInvocationAllowed
in interface OperationExecutor
op
- 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()
OperationExecutor
start
in interface OperationExecutor
public void shutdown()
OperationExecutor
shutdown
in interface OperationExecutor
Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.