public class MigrationOperation extends Operation implements TargetAware
Modifier and Type | Field and Description |
---|---|
protected List<MigrationInfo> |
completedMigrations |
protected MigrationInfo |
migrationInfo |
protected int |
partitionStateVersion |
protected boolean |
success |
GENERIC_PARTITION_ID
Constructor and Description |
---|
MigrationOperation() |
MigrationOperation(MigrationInfo migrationInfo,
List<MigrationInfo> completedMigrations,
int partitionStateVersion,
ReplicaFragmentMigrationState fragmentMigrationState,
boolean firstFragment,
boolean lastFragment) |
Modifier and Type | Method and Description |
---|---|
void |
beforeRun()
The beforeRun is called before either the
Operation.run() or the Operation.call() method is called. |
int |
getClassId()
Returns type identifier for this class.
|
int |
getFactoryId()
Returns DataSerializableFactory factory ID for this class.
|
protected PartitionMigrationEvent |
getMigrationEvent()
Returns the event which will be forwarded to
MigrationAwareService s. |
MigrationInfo |
getMigrationInfo() |
protected MigrationInterceptor.MigrationParticipant |
getMigrationParticipantType() |
Object |
getResponse()
Called if and only if
Operation.returnsResponse() returned true ,
shortly after Operation.run() returns. |
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 |
prepareOperation(Operation op) |
protected void |
readInternal(ObjectDataInput in) |
void |
run()
Runs the operation.
|
void |
setTarget(Address address)
Provides the designated target member address to which the operation
will be sent.
|
protected void |
toString(StringBuilder sb)
A template method allows for additional information to be passed into
the
Operation.toString() method. |
boolean |
validatesTarget() |
protected void |
writeInternal(ObjectDataOutput out) |
afterRun, call, executedLocally, getCallerAddress, getCallerUuid, getCallId, getCallTimeout, getClientCallId, getConnection, getInvocationTime, getLogger, getNodeEngine, getOperationResponseHandler, getPartitionId, getReplicaIndex, getService, getServiceName, getWaitTimeout, isUrgent, onSetCallId, readData, requiresExplicitServiceName, returnsResponse, sendResponse, setCallerUuid, setClientCallId, setNodeEngine, setOperationResponseHandler, setPartitionId, setReplicaIndex, setService, setServiceName, setValidateTarget, setWaitTimeout, toString, writeData
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getPartitionId
readData, writeData
protected MigrationInfo migrationInfo
protected boolean success
protected List<MigrationInfo> completedMigrations
protected int partitionStateVersion
public MigrationOperation()
public MigrationOperation(MigrationInfo migrationInfo, List<MigrationInfo> completedMigrations, int partitionStateVersion, ReplicaFragmentMigrationState fragmentMigrationState, boolean firstFragment, boolean lastFragment)
public void run() throws Exception
Operation.run()
or Operation.call()
method should be implemented; not both.
Runs after wait-support, supposed to do actual operation
Sets the active migration and the migration flag for the partition, notifies MigrationAwareService
s that
the migration is starting and runs the sent replication operations.
If the migration was successful, set the replica versions. If it failed, notify the sent migration tasks.run
in class Operation
Exception
Operation.call()
protected void prepareOperation(Operation op)
protected PartitionMigrationEvent getMigrationEvent()
MigrationAwareService
s.protected MigrationInterceptor.MigrationParticipant getMigrationParticipantType()
public void onExecutionFailure(Throwable e)
Exception
/Error
is thrown during
operation execution.
By default this method does nothing. Operation implementations can override this behaviour according to their needs.
This method is called on node & thread that's executing the operation. Notifies all sent migration tasks that the migration failed.
onExecutionFailure
in class Operation
e
- Exception/Error thrown during operation executionpublic int getClassId()
IdentifiedDataSerializable
getClassId
in interface IdentifiedDataSerializable
protected void writeInternal(ObjectDataOutput out) throws IOException
IOException
protected void readInternal(ObjectDataInput in) throws IOException
IOException
public void setTarget(Address address)
TargetAware
setTarget
will be invoked on each retry with the
current target member's Address
as argument
address
is provided as target address
setTarget
in interface TargetAware
address
- target member's addresspublic final void beforeRun()
Operation.run()
or the Operation.call()
method is called.
runs before wait-support
Validates the migration operation: the UUIDs of the node should match the one in the migrationInfo
,
the cluster should be in ClusterState.ACTIVE
and the node started and the partition state version from
the sender should match the local partition state version.public MigrationInfo getMigrationInfo()
public Object getResponse()
Operation
Operation.returnsResponse()
returned true
,
shortly after Operation.run()
returns.getResponse
in class Operation
public final boolean validatesTarget()
validatesTarget
in class Operation
public ExceptionAction onInvocationException(Throwable throwable)
Operation
Exception
/Error
is thrown
during an invocation. Invocation process will continue, it will retry
or fail according to returned ExceptionAction
.
This method is called on caller side of the invocation.
onInvocationException
in class Operation
throwable
- Exception
/Error
thrown during
invocationExceptionAction
public void logError(Throwable e)
Operation
Exception
/Error
thrown during operation execution.
Operation implementations can override this behaviour according to their needs.
This method is called on node & thread that's executing the operation.
protected void toString(StringBuilder sb)
Operation
Operation.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 to always call the super.toString(stringBuffer)
when implementing this method to make sure that the super class can
inject content if needed.public final int getFactoryId()
IdentifiedDataSerializable
getFactoryId
in interface IdentifiedDataSerializable
Copyright © 2019 Hazelcast, Inc.. All rights reserved.