Search in sources :

Example 1 with PartitionMigrationEvent

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);
    }
}
Also used : PartitionMigrationEvent(com.hazelcast.internal.partition.PartitionMigrationEvent) MigrationAwareService(com.hazelcast.internal.partition.MigrationAwareService)

Example 2 with PartitionMigrationEvent

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());
}
Also used : EqualPredicate(com.hazelcast.query.impl.predicates.EqualPredicate) PartitionMigrationEvent(com.hazelcast.internal.partition.PartitionMigrationEvent) EqualPredicate(com.hazelcast.query.impl.predicates.EqualPredicate) Predicate(com.hazelcast.query.Predicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with PartitionMigrationEvent

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());
}
Also used : EqualPredicate(com.hazelcast.query.impl.predicates.EqualPredicate) PartitionMigrationEvent(com.hazelcast.internal.partition.PartitionMigrationEvent) EqualPredicate(com.hazelcast.query.impl.predicates.EqualPredicate) Predicate(com.hazelcast.query.Predicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with PartitionMigrationEvent

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());
}
Also used : Ringbuffer(com.hazelcast.ringbuffer.Ringbuffer) PartitionMigrationEvent(com.hazelcast.internal.partition.PartitionMigrationEvent) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with PartitionMigrationEvent

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);
        }
    }
}
Also used : PartitionMigrationEvent(com.hazelcast.internal.partition.PartitionMigrationEvent) MigrationAwareService(com.hazelcast.internal.partition.MigrationAwareService) ILogger(com.hazelcast.logging.ILogger)

Aggregations

PartitionMigrationEvent (com.hazelcast.internal.partition.PartitionMigrationEvent)9 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 Predicate (com.hazelcast.query.Predicate)4 EqualPredicate (com.hazelcast.query.impl.predicates.EqualPredicate)4 MigrationAwareService (com.hazelcast.internal.partition.MigrationAwareService)3 ILogger (com.hazelcast.logging.ILogger)1 QueryContext (com.hazelcast.query.impl.QueryContext)1 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)1 Ringbuffer (com.hazelcast.ringbuffer.Ringbuffer)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1