public abstract class Operation extends Object implements DataSerializable
Modifier and Type | Field and Description |
---|---|
static int |
GENERIC_PARTITION_ID
Marks an
Operation as non partition specific. |
Constructor and Description |
---|
Operation() |
Modifier and Type | Method and Description |
---|---|
void |
afterRun() |
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() |
OperationResponseHandler |
getOperationResponseHandler()
Gets the OperationResponseHandler tied to this Operation.
|
int |
getPartitionId()
Returns the id of the partition that this Operation will be executed upon.
|
int |
getReplicaIndex() |
Object |
getResponse() |
<T> T |
getService() |
String |
getServiceName() |
long |
getWaitTimeout() |
boolean |
isUrgent() |
void |
logError(Throwable e)
Logs Exception/Error thrown during operation execution.
|
void |
onExecutionFailure(Throwable e)
Called when an Exception/Error is thrown during operation execution.
|
ExceptionAction |
onInvocationException(Throwable throwable)
Called when an Exception/Error is thrown
during an invocation.
|
protected void |
onSetCallId()
This method is called every time a new callId is set to the operation.
|
void |
readData(ObjectDataInput in)
Reads fields from the input stream
|
protected void |
readInternal(ObjectDataInput in) |
boolean |
returnsResponse() |
abstract void |
run() |
void |
sendResponse(Object value) |
Operation |
setCallerUuid(String callerUuid) |
Operation |
setNodeEngine(NodeEngine nodeEngine) |
Operation |
setOperationResponseHandler(OperationResponseHandler responseHandler)
Sets the OperationResponseHandler.
|
Operation |
setPartitionId(int partitionId)
Sets the partition id.
|
Operation |
setReplicaIndex(int replicaIndex) |
Operation |
setService(Object service) |
Operation |
setServiceName(String serviceName) |
Operation |
setValidateTarget(boolean validateTarget) |
void |
setWaitTimeout(long timeout) |
String |
toString() |
protected void |
toString(StringBuilder sb)
A template method allows for additional information to be passed into the
toString() method. |
boolean |
validatesTarget() |
void |
writeData(ObjectDataOutput out)
Writes object fields to output stream
|
protected void |
writeInternal(ObjectDataOutput out) |
public static final int GENERIC_PARTITION_ID
Operation
as non partition specific.public boolean isUrgent()
public boolean returnsResponse()
public Object getResponse()
public String getServiceName()
public final int getPartitionId()
setPartitionId(int)
public final Operation setPartitionId(int partitionId)
partitionId
- the id of the partition.getPartitionId()
public final int getReplicaIndex()
public final Operation setReplicaIndex(int replicaIndex)
public final long getCallId()
protected void onSetCallId()
getCallId()
.
For example an operation can distinguish the first invocation and invocation retries by keeping
the initial callId.public boolean validatesTarget()
public final Operation setValidateTarget(boolean validateTarget)
public final NodeEngine getNodeEngine()
public final Operation setNodeEngine(NodeEngine nodeEngine)
public final <T> T getService()
public final Address getCallerAddress()
public final Connection getConnection()
public final OperationResponseHandler getOperationResponseHandler()
public final Operation setOperationResponseHandler(OperationResponseHandler responseHandler)
responseHandler
- the OperationResponseHandler to set.public final void sendResponse(Object value)
public final long getInvocationTime()
ClusterClock.getClusterTime()
.public final long getCallTimeout()
GroupProperty.OPERATION_CALL_TIMEOUT_MILLIS
setCallTimeout(long)
,
OperationAccessor.setCallTimeout(Operation, long)
public final long getWaitTimeout()
public final void setWaitTimeout(long timeout)
public ExceptionAction onInvocationException(Throwable throwable)
throwable
- Exception/Error thrown during invocationpublic String getCallerUuid()
protected final ILogger getLogger()
public void onExecutionFailure(Throwable e)
e
- Exception/Error thrown during operation executionpublic void logError(Throwable e)
e
- Exception/Error thrown during operation executionpublic final void writeData(ObjectDataOutput out) throws IOException
DataSerializable
writeData
in interface DataSerializable
out
- outputIOException
public final void readData(ObjectDataInput in) throws IOException
DataSerializable
readData
in interface DataSerializable
in
- inputIOException
protected void writeInternal(ObjectDataOutput out) throws IOException
IOException
protected void readInternal(ObjectDataInput in) throws IOException
IOException
protected void toString(StringBuilder sb)
toString()
method. So an Operation
subclass can override this method and add additional debugging content. The default implementation does nothing so
one is not forced to provide an empty implementation.
It is a good practice always to call the super.toString(stringBuffer) when implementing this method to make sure
that the super class can inject content if needed.sb
- the StringBuilder to add the debug info to.Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.