use of com.hazelcast.internal.partition.impl.InternalMigrationListener.MigrationParticipant in project hazelcast by hazelcast.
the class MigrationManager method finalizeMigration.
private void finalizeMigration(MigrationInfo migrationInfo) {
try {
Address thisAddress = node.getThisAddress();
int partitionId = migrationInfo.getPartitionId();
boolean source = thisAddress.equals(migrationInfo.getSource());
boolean destination = thisAddress.equals(migrationInfo.getDestination());
assert migrationInfo.getStatus() == MigrationStatus.SUCCESS || migrationInfo.getStatus() == MigrationStatus.FAILED : "Invalid migration: " + migrationInfo;
if (source || destination) {
boolean success = migrationInfo.getStatus() == MigrationStatus.SUCCESS;
MigrationParticipant participant = source ? MigrationParticipant.SOURCE : MigrationParticipant.DESTINATION;
if (success) {
internalMigrationListener.onMigrationCommit(participant, migrationInfo);
} else {
internalMigrationListener.onMigrationRollback(participant, migrationInfo);
}
MigrationEndpoint endpoint = source ? MigrationEndpoint.SOURCE : MigrationEndpoint.DESTINATION;
FinalizeMigrationOperation op = new FinalizeMigrationOperation(migrationInfo, endpoint, success);
op.setPartitionId(partitionId).setNodeEngine(nodeEngine).setValidateTarget(false).setService(partitionService);
nodeEngine.getOperationService().execute(op);
removeActiveMigration(partitionId);
} else {
final Address partitionOwner = partitionStateManager.getPartitionImpl(partitionId).getOwnerOrNull();
if (node.getThisAddress().equals(partitionOwner)) {
removeActiveMigration(partitionId);
partitionStateManager.clearMigratingFlag(partitionId);
} else {
logger.severe("Failed to finalize migration because this member " + thisAddress + " is not a participant of the migration: " + migrationInfo);
}
}
} catch (Exception e) {
logger.warning(e);
} finally {
migrationInfo.doneProcessing();
}
}
Aggregations