use of com.hazelcast.spi.MigrationAwareService in project hazelcast by hazelcast.
the class MigrationRequestOperation method prepareMigrationOperations.
private Collection<Operation> prepareMigrationOperations() {
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
PartitionReplicationEvent replicationEvent = new PartitionReplicationEvent(migrationInfo.getPartitionId(), migrationInfo.getDestinationNewReplicaIndex());
Collection<Operation> tasks = new LinkedList<Operation>();
for (ServiceInfo serviceInfo : nodeEngine.getServiceInfos(MigrationAwareService.class)) {
MigrationAwareService service = (MigrationAwareService) serviceInfo.getService();
Operation op = service.prepareReplicationOperation(replicationEvent);
if (op != null) {
op.setServiceName(serviceInfo.getName());
tasks.add(op);
}
}
return tasks;
}
use of com.hazelcast.spi.MigrationAwareService in project hazelcast by hazelcast.
the class BaseMigrationOperation method executeBeforeMigrations.
void executeBeforeMigrations() throws Exception {
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
PartitionMigrationEvent event = getMigrationEvent();
Throwable t = null;
for (MigrationAwareService service : nodeEngine.getServices(MigrationAwareService.class)) {
// 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);
}
}
use of com.hazelcast.spi.MigrationAwareService in project hazelcast by hazelcast.
the class BeforePromotionOperation method run.
@Override
public void run() throws Exception {
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.spi.MigrationAwareService in project hazelcast by hazelcast.
the class FinalizeMigrationOperation method notifyServices.
private void notifyServices(NodeEngineImpl nodeEngine) {
PartitionMigrationEvent event = getPartitionMigrationEvent();
Collection<MigrationAwareService> migrationAwareServices = nodeEngine.getServices(MigrationAwareService.class);
// knows replica is moved away from itself.
if (nodeEngine.getThisAddress().equals(migrationInfo.getSource()) && migrationInfo.getSourceCurrentReplicaIndex() > 0) {
// 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.spi.MigrationAwareService in project hazelcast by hazelcast.
the class ReplicaSyncRequest method createReplicationOperations.
private List<Operation> createReplicationOperations() {
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
Collection<ServiceInfo> services = nodeEngine.getServiceInfos(MigrationAwareService.class);
PartitionReplicationEvent event = new PartitionReplicationEvent(getPartitionId(), getReplicaIndex());
List<Operation> tasks = new LinkedList<Operation>();
for (ServiceInfo serviceInfo : services) {
MigrationAwareService service = (MigrationAwareService) serviceInfo.getService();
Operation op = service.prepareReplicationOperation(event);
if (op != null) {
op.setServiceName(serviceInfo.getName());
tasks.add(op);
}
}
return tasks;
}
Aggregations