com.hazelcast.spi
Class Operation

java.lang.Object
  extended by com.hazelcast.spi.Operation
All Implemented Interfaces:
DataSerializable
Direct Known Subclasses:
AbstractOperation, AbstractReplicatedMapOperation, AtomicLongBaseOperation, AtomicReferenceBaseOperation, Backup, BeginTxBackupOperation, BroadcastTxRollbackOperation, CallableTaskOperation, CancellationOperation, CheckReplicaVersion, ClearRemoteTransactionBackupOperation, ClearRemoteTransactionOperation, CollectionOperation, CollectRemoteTransactionsOperation, FinalizeRemoteTransactionBackupOperation, FinalizeRemoteTransactionOperation, GetMapConfigOperation, IsReplicaVersionSync, KeyBasedMapOperation, MemberCallableTaskOperation, MultiMapOperation, PurgeTxBackupOperation, PutRemoteTransactionBackupOperation, PutRemoteTransactionOperation, QueueOperation, ReplicaSyncRequest, ReplicaSyncResponse, ReplicaSyncRetryResponse, ReplicateTxOperation, RollbackTxBackupOperation, ScriptExecutorOperation, ThreadDumpOperation, UpdateManagementCenterUrlOperation, UpdateMapConfigOperation

public abstract class Operation
extends Object
implements DataSerializable

An operation could be compared to a Runnable. It contains logic that is going to be executed; this logic will be placed in the run() method.


Field Summary
static long CALL_ID_LOCAL_SKIPPED
          A call id for an invocation that is skipping local registration.
static int GENERIC_PARTITION_ID
           
 
Constructor Summary
Operation()
           
 
Method Summary
abstract  void afterRun()
           
abstract  void beforeRun()
           
 Address getCallerAddress()
           
 String getCallerUuid()
           
 long getCallId()
          Gets the callId of this Operation.
 long getCallTimeout()
          Gets the call timeout in milliseconds.
 Connection getConnection()
           
 long getInvocationTime()
          Gets the time in milliseconds since this invocation started.
protected  ILogger getLogger()
           
 NodeEngine getNodeEngine()
           
 int getPartitionId()
          Returns the id of the partition that this Operation will be executed upon.
 int getReplicaIndex()
           
abstract  Object getResponse()
           
 ResponseHandler getResponseHandler()
           
<T> T
getService()
           
 String getServiceName()
           
 long getWaitTimeout()
           
 boolean isUrgent()
           
 void logError(Throwable e)
           
 ExceptionAction onException(Throwable throwable)
           
 void readData(ObjectDataInput in)
          Reads fields from the input stream
protected abstract  void readInternal(ObjectDataInput in)
           
abstract  boolean returnsResponse()
           
abstract  void run()
           
 Operation setCallerUuid(String callerUuid)
           
 Operation setNodeEngine(NodeEngine nodeEngine)
           
 Operation setPartitionId(int partitionId)
          Sets the partition id.
 Operation setReplicaIndex(int replicaIndex)
           
 Operation setResponseHandler(ResponseHandler responseHandler)
           
 Operation setService(Object service)
           
 Operation setServiceName(String serviceName)
           
 Operation setValidateTarget(boolean validateTarget)
           
 void setWaitTimeout(long timeout)
           
 String toString()
           
 boolean validatesTarget()
           
 void writeData(ObjectDataOutput out)
          Writes object fields to output stream
protected abstract  void writeInternal(ObjectDataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GENERIC_PARTITION_ID

public static final int GENERIC_PARTITION_ID
See Also:
Constant Field Values

CALL_ID_LOCAL_SKIPPED

public static final long CALL_ID_LOCAL_SKIPPED
A call id for an invocation that is skipping local registration. For example, a local call without backups doesn't need to have its call id registered since it won't receive a response from a remote system.

See Also:
Constant Field Values
Constructor Detail

Operation

public Operation()
Method Detail

isUrgent

public boolean isUrgent()

beforeRun

public abstract void beforeRun()
                        throws Exception
Throws:
Exception

run

public abstract void run()
                  throws Exception
Throws:
Exception

afterRun

public abstract void afterRun()
                       throws Exception
Throws:
Exception

returnsResponse

public abstract boolean returnsResponse()

getResponse

public abstract Object getResponse()

getServiceName

public String getServiceName()

setServiceName

public final Operation setServiceName(String serviceName)

getPartitionId

public final int getPartitionId()
Returns the id of the partition that this Operation will be executed upon. If the partitionId is equal or larger than 0, it means that it is tied to a specific partition: for example, a map.get('foo'). If it is smaller than 0, than it means that it isn't bound to a particular partition. The partitionId should never be equal or larger than the total number of partitions. For example, if there are 271 partitions, the maximum partitionId is 270. The partitionId is used by the OperationService to figure out which member owns a specific partition, and to send the operation to that member.

Returns:
the id of the partition.
See Also:
setPartitionId(int)

setPartitionId

public final Operation setPartitionId(int partitionId)
Sets the partition id.

Parameters:
partitionId - the id of the partition.
Returns:
the updated Operation.
See Also:
getPartitionId()

getReplicaIndex

public final int getReplicaIndex()

setReplicaIndex

public final Operation setReplicaIndex(int replicaIndex)

getCallId

public final long getCallId()
Gets the callId of this Operation. The callId is used to associate the invocation of an Operation on a remote system, with the response from the execution of that operation.

Returns:
the callId.

validatesTarget

public boolean validatesTarget()

setValidateTarget

public final Operation setValidateTarget(boolean validateTarget)

getNodeEngine

public final NodeEngine getNodeEngine()

setNodeEngine

public final Operation setNodeEngine(NodeEngine nodeEngine)

getService

public final <T> T getService()

setService

public final Operation setService(Object service)

getCallerAddress

public final Address getCallerAddress()

getConnection

public final Connection getConnection()

setResponseHandler

public final Operation setResponseHandler(ResponseHandler responseHandler)

getResponseHandler

public final ResponseHandler getResponseHandler()

getInvocationTime

public final long getInvocationTime()
Gets the time in milliseconds since this invocation started. For more information, see ClusterClock.getClusterTime().

Returns:
the time of the invocation start.

getCallTimeout

public final long getCallTimeout()
Gets the call timeout in milliseconds. For example, if a call should be executed within 60 seconds orotherwise it should be aborted, then the call-timeout is 60000 milliseconds. For more information about the default value, see GroupProperties.OPERATION_CALL_TIMEOUT_MILLIS

Returns:
the call timeout in milliseconds.
See Also:
setCallTimeout(long), OperationAccessor.setCallTimeout(Operation, long)

getWaitTimeout

public final long getWaitTimeout()

setWaitTimeout

public final void setWaitTimeout(long timeout)

onException

public ExceptionAction onException(Throwable throwable)

getCallerUuid

public String getCallerUuid()

setCallerUuid

public Operation setCallerUuid(String callerUuid)

getLogger

protected final ILogger getLogger()

logError

public void logError(Throwable e)

writeData

public final void writeData(ObjectDataOutput out)
                     throws IOException
Description copied from interface: DataSerializable
Writes object fields to output stream

Specified by:
writeData in interface DataSerializable
Parameters:
out - output
Throws:
IOException

readData

public final void readData(ObjectDataInput in)
                    throws IOException
Description copied from interface: DataSerializable
Reads fields from the input stream

Specified by:
readData in interface DataSerializable
Parameters:
in - input
Throws:
IOException

writeInternal

protected abstract void writeInternal(ObjectDataOutput out)
                               throws IOException
Throws:
IOException

readInternal

protected abstract void readInternal(ObjectDataInput in)
                              throws IOException
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object


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