use of com.hazelcast.internal.partition.MigrationAwareService in project hazelcast by hazelcast.
the class FinalizeMigrationOperation method notifyServices.
/**
* Notifies all {@link MigrationAwareService}s that the migration finished. The services can then execute the commit or
* rollback logic. If this node was the source and backup replica for a partition, the services will first be notified that
* the migration is starting.
*/
private void notifyServices() {
PartitionMigrationEvent event = getPartitionMigrationEvent();
Collection<MigrationAwareService> migrationAwareServices = getMigrationAwareServices();
// knows replica is moved away from itself.
if (isOldBackupReplicaOwner()) {
// execute beforeMigration on old backup before commit/rollback
for (MigrationAwareService service : migrationAwareServices) {
beforeMigration(event, service);
}
}
for (MigrationAwareService service : migrationAwareServices) {
finishMigration(event, service);
}
}
use of com.hazelcast.internal.partition.MigrationAwareService in project hazelcast by hazelcast.
the class AbstractPartitionOperation method createReplicationOperations.
private Collection<Operation> createReplicationOperations(PartitionReplicationEvent event, boolean nonFragmentedOnly) {
Collection<Operation> operations = new ArrayList<>();
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
Collection<ServiceInfo> services = nodeEngine.getServiceInfos(MigrationAwareService.class);
for (ServiceInfo serviceInfo : services) {
MigrationAwareService service = serviceInfo.getService();
if (nonFragmentedOnly && service instanceof FragmentedMigrationAwareService) {
// skip fragmented services
continue;
}
Operation op = service.prepareReplicationOperation(event);
if (op != null) {
op.setServiceName(serviceInfo.getName());
operations.add(op);
}
}
return operations;
}
use of com.hazelcast.internal.partition.MigrationAwareService in project hazelcast by hazelcast.
the class BeforePromotionOperation method run.
@Override
public void run() {
ILogger logger = getLogger();
if (logger.isFinestEnabled()) {
logger.finest("Running before promotion for " + getPartitionMigrationEvent());
}
PartitionMigrationEvent event = getPartitionMigrationEvent();
for (MigrationAwareService service : getMigrationAwareServices()) {
try {
service.beforeMigration(event);
} catch (Throwable e) {
logger.warning("While promoting " + getPartitionMigrationEvent(), e);
}
}
}
use of com.hazelcast.internal.partition.MigrationAwareService in project hazelcast by hazelcast.
the class BaseMigrationOperation method executeBeforeMigrations.
/**
* Notifies all {@link MigrationAwareService}s that the migration is starting.
*/
void executeBeforeMigrations() throws Exception {
PartitionMigrationEvent event = getMigrationEvent();
Throwable t = null;
for (MigrationAwareService service : getMigrationAwareServices()) {
// we need to make sure all beforeMigration() methods are executed
try {
service.beforeMigration(event);
} catch (Throwable e) {
getLogger().warning("Error while executing beforeMigration()", e);
t = e;
}
}
if (t != null) {
throw ExceptionUtil.rethrow(t);
}
}
Aggregations