use of com.hazelcast.internal.partition.PartitionMigrationEvent 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.PartitionMigrationEvent in project hazelcast by hazelcast.
the class QueryRunnerTest method verifyIndexedQueryFailureWhileMigrating.
@Test
public void verifyIndexedQueryFailureWhileMigrating() {
map.addIndex(IndexType.HASH, "this");
Predicate predicate = new EqualPredicate("this", value);
mapService.beforeMigration(new PartitionMigrationEvent(MigrationEndpoint.SOURCE, partitionId, 0, 1, UUID.randomUUID()));
Query query = Query.of().mapName(map.getName()).predicate(predicate).iterationType(IterationType.ENTRY).partitionIdSet(SetUtil.allPartitionIds(instance.getPartitionService().getPartitions().size())).build();
QueryResult result = (QueryResult) queryRunner.runIndexOrPartitionScanQueryOnOwnedPartitions(query);
assertNull(result.getPartitionIds());
}
use of com.hazelcast.internal.partition.PartitionMigrationEvent in project hazelcast by hazelcast.
the class QueryRunnerTest method verifyFullScanFailureWhileMigrating.
@Test
public void verifyFullScanFailureWhileMigrating() {
Predicate predicate = new EqualPredicate("this", value);
mapService.beforeMigration(new PartitionMigrationEvent(MigrationEndpoint.SOURCE, partitionId, 0, 1, UUID.randomUUID()));
Query query = Query.of().mapName(map.getName()).predicate(predicate).iterationType(IterationType.ENTRY).partitionIdSet(SetUtil.allPartitionIds(instance.getPartitionService().getPartitions().size())).build();
QueryResult result = (QueryResult) queryRunner.runIndexOrPartitionScanQueryOnOwnedPartitions(query);
assertNull(result.getPartitionIds());
}
use of com.hazelcast.internal.partition.PartitionMigrationEvent in project hazelcast by hazelcast.
the class RingbufferServiceTest method rollbackMigration.
@Test
public void rollbackMigration() {
Ringbuffer ringbuffer = hz.getRingbuffer("foo");
int partitionId = getPartitionId(hz, ringbuffer.getName());
PartitionMigrationEvent partitionEvent = new PartitionMigrationEvent(DESTINATION, partitionId, -1, 0, UUID.randomUUID());
service.rollbackMigration(partitionEvent);
assertEquals(0, service.getContainers().size());
}
use of com.hazelcast.internal.partition.PartitionMigrationEvent 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);
}
}
}
Aggregations