com.hazelcast.spi.impl.operationexecutor.classic
Class ClassicOperationExecutor

java.lang.Object
  extended by com.hazelcast.spi.impl.operationexecutor.classic.ClassicOperationExecutor
All Implemented Interfaces:
OperationExecutor

public final class ClassicOperationExecutor
extends Object
implements OperationExecutor

A OperationExecutor that schedules:

  1. partition specific operations to a specific partition-operation-thread (using a mod on the partition-id)
  2. non specific operations to generic-operation-threads
The 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:

  1. partition specific operation threads: these threads are responsible for executing e.g. a map.put. Operations for the same partition, always end up in the same thread.
  2. generic operation threads: these threads are responsible for executing operations that are not specific to a partition. E.g. a heart beat.


Field Summary
static int TERMINATION_TIMEOUT_SECONDS
           
 
Constructor Summary
ClassicOperationExecutor(GroupProperties properties, LoggingService loggerService, Address thisAddress, OperationRunnerFactory operationRunnerFactory, ResponsePacketHandler responsePacketHandler, HazelcastThreadGroup hazelcastThreadGroup, NodeExtension nodeExtension)
           
 
Method Summary
 void dumpPerformanceMetrics(StringBuffer sb)
           
 void execute(Operation op)
          Executes an Operation.
 void execute(Packet packet)
          Executes a Operation/Response-packet.
 void execute(PartitionSpecificRunnable task)
          Executes a PartitionSpecificRunnable.
 OperationRunner getCurrentThreadOperationRunner()
           
 OperationRunner[] getGenericOperationRunners()
          Gets all the generic operation handlers.
 int getGenericOperationThreadCount()
           
 int getOperationExecutorQueueSize()
           
 OperationRunner[] getPartitionOperationRunners()
          Gets all the operation handlers for the partitions.
 int getPartitionOperationThreadCount()
           
 int getPriorityOperationExecutorQueueSize()
           
 int getResponseQueueSize()
           
 int getRunningOperationCount()
           
 boolean isAllowedToRunInCurrentThread(Operation op)
          Checks if the operation is allowed to run on the current thread.
 boolean isInvocationAllowedFromCurrentThread(Operation op, boolean isAsync)
          Checks this operation can be invoked from the current thread.
 boolean isOperationThread()
          Checks if the current thread is an operation thread.
 void runOnCallingThread(Operation operation)
          Runs the operation on the calling thread.
 void runOnCallingThreadIfPossible(Operation op)
          Tries to run the operation on the calling thread if possible.
 void shutdown()
          Shuts down this OperationExecutor.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TERMINATION_TIMEOUT_SECONDS

public static final int TERMINATION_TIMEOUT_SECONDS
See Also:
Constant Field Values
Constructor Detail

ClassicOperationExecutor

public ClassicOperationExecutor(GroupProperties properties,
                                LoggingService loggerService,
                                Address thisAddress,
                                OperationRunnerFactory operationRunnerFactory,
                                ResponsePacketHandler responsePacketHandler,
                                HazelcastThreadGroup hazelcastThreadGroup,
                                NodeExtension nodeExtension)
Method Detail

getPartitionOperationRunners

public OperationRunner[] getPartitionOperationRunners()
Description copied from interface: OperationExecutor
Gets all the operation handlers for the partitions. Each partition will have its own operation handler. So if there are 271 partitions, then the size of the array will be 271.

Don't modify the content of the array!

Specified by:
getPartitionOperationRunners in interface OperationExecutor
Returns:
the operation handlers.

getGenericOperationRunners

public OperationRunner[] getGenericOperationRunners()
Description copied from interface: OperationExecutor
Gets all the generic operation handlers. The number of generic operation handlers depends on the number of generic threads.

Don't modify the content of the array!

Specified by:
getGenericOperationRunners in interface OperationExecutor
Returns:
the generic operation handlers.

isAllowedToRunInCurrentThread

public boolean isAllowedToRunInCurrentThread(Operation op)
Description copied from interface: OperationExecutor
Checks if the operation is allowed to run on the current thread.

Specified by:
isAllowedToRunInCurrentThread in interface OperationExecutor
Parameters:
op - the Operation to check
Returns:
true if it is allowed, false otherwise.

isOperationThread

public boolean isOperationThread()
Description copied from interface: OperationExecutor
Checks if the current thread is an operation thread.

Specified by:
isOperationThread in interface OperationExecutor
Returns:
true if is an operation thread, false otherwise.

isInvocationAllowedFromCurrentThread

public boolean isInvocationAllowedFromCurrentThread(Operation op,
                                                    boolean isAsync)
Description copied from interface: OperationExecutor
Checks this operation can 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. Blocking for completion can cause problems, e.g. when you hog a partition thread.

Specified by:
isInvocationAllowedFromCurrentThread in interface OperationExecutor
Parameters:
op - the Operation to check
isAsync - is the invocation async, if false invocation does not return a future to block on
Returns:
true if allowed, false otherwise.

getRunningOperationCount

public int getRunningOperationCount()
Specified by:
getRunningOperationCount in interface OperationExecutor

getOperationExecutorQueueSize

public int getOperationExecutorQueueSize()
Specified by:
getOperationExecutorQueueSize in interface OperationExecutor

getPriorityOperationExecutorQueueSize

public int getPriorityOperationExecutorQueueSize()
Specified by:
getPriorityOperationExecutorQueueSize in interface OperationExecutor

getResponseQueueSize

public int getResponseQueueSize()
Specified by:
getResponseQueueSize in interface OperationExecutor

getPartitionOperationThreadCount

public int getPartitionOperationThreadCount()
Specified by:
getPartitionOperationThreadCount in interface OperationExecutor

getGenericOperationThreadCount

public int getGenericOperationThreadCount()
Specified by:
getGenericOperationThreadCount in interface OperationExecutor

execute

public void execute(Operation op)
Description copied from interface: OperationExecutor
Executes an Operation.

Specified by:
execute in interface OperationExecutor
Parameters:
op - the operation to execute.

execute

public void execute(PartitionSpecificRunnable task)
Description copied from interface: OperationExecutor
Executes a PartitionSpecificRunnable.

Specified by:
execute in interface OperationExecutor
Parameters:
task - the task the execute.

runOnCallingThreadIfPossible

public void runOnCallingThreadIfPossible(Operation op)
Description copied from interface: OperationExecutor
Tries to run the operation on the calling thread if possible. Otherwise offload it to a different thread.

Specified by:
runOnCallingThreadIfPossible in interface OperationExecutor
Parameters:
op - the operation to run.

execute

public void execute(Packet packet)
Description copied from interface: OperationExecutor
Executes a Operation/Response-packet.

Specified by:
execute in interface OperationExecutor
Parameters:
packet - the packet to execute.

runOnCallingThread

public void runOnCallingThread(Operation operation)
Description copied from interface: OperationExecutor
Runs the operation on the calling thread.

Specified by:
runOnCallingThread in interface OperationExecutor
Parameters:
operation - the operation to run.

getCurrentThreadOperationRunner

public OperationRunner getCurrentThreadOperationRunner()

shutdown

public void shutdown()
Description copied from interface: OperationExecutor
Shuts down this OperationExecutor.

Specified by:
shutdown in interface OperationExecutor

dumpPerformanceMetrics

public void dumpPerformanceMetrics(StringBuffer sb)
Specified by:
dumpPerformanceMetrics in interface OperationExecutor

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.