Search in sources :

Example 1 with MigrationStateImpl

use of com.hazelcast.internal.partition.MigrationStateImpl in project hazelcast by hazelcast.

the class PartitionDataSerializerHook method createFactory.

@Override
public DataSerializableFactory createFactory() {
    ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
    constructors[PARTITION_RUNTIME_STATE] = arg -> new PartitionRuntimeState();
    constructors[ASSIGN_PARTITIONS] = arg -> new AssignPartitions();
    constructors[PARTITION_BACKUP_REPLICA_ANTI_ENTROPY] = arg -> new PartitionBackupReplicaAntiEntropyOperation();
    constructors[FETCH_PARTITION_STATE] = arg -> new FetchPartitionStateOperation();
    constructors[HAS_ONGOING_MIGRATION] = arg -> new HasOngoingMigration();
    constructors[MIGRATION_COMMIT] = arg -> new MigrationCommitOperation();
    constructors[PARTITION_STATE_OP] = arg -> new PartitionStateOperation();
    constructors[PROMOTION_COMMIT] = arg -> new PromotionCommitOperation();
    constructors[REPLICA_SYNC_REQUEST] = arg -> new PartitionReplicaSyncRequest();
    constructors[REPLICA_SYNC_RESPONSE] = arg -> new PartitionReplicaSyncResponse();
    constructors[REPLICA_SYNC_RETRY_RESPONSE] = arg -> new PartitionReplicaSyncRetryResponse();
    constructors[SAFE_STATE_CHECK] = arg -> new SafeStateCheckOperation();
    constructors[SHUTDOWN_REQUEST] = arg -> new ShutdownRequestOperation();
    constructors[SHUTDOWN_RESPONSE] = arg -> new ShutdownResponseOperation();
    constructors[REPLICA_FRAGMENT_MIGRATION_STATE] = arg -> new ReplicaFragmentMigrationState();
    constructors[MIGRATION] = arg -> new MigrationOperation();
    constructors[MIGRATION_REQUEST] = arg -> new MigrationRequestOperation();
    constructors[NON_FRAGMENTED_SERVICE_NAMESPACE] = arg -> NonFragmentedServiceNamespace.INSTANCE;
    constructors[PARTITION_REPLICA] = arg -> new PartitionReplica();
    constructors[PUBLISH_COMPLETED_MIGRATIONS] = arg -> new PublishCompletedMigrationsOperation();
    constructors[PARTITION_STATE_CHECK_OP] = arg -> new PartitionStateCheckOperation();
    constructors[REPLICA_MIGRATION_EVENT] = arg -> new ReplicaMigrationEventImpl();
    constructors[MIGRATION_EVENT] = arg -> new MigrationStateImpl();
    constructors[PARTITION_LOST_EVENT] = arg -> new PartitionLostEventImpl();
    constructors[REPLICA_SYNC_REQUEST_OFFLOADABLE] = arg -> new PartitionReplicaSyncRequestOffloadable();
    return new ArrayDataSerializableFactory(constructors);
}
Also used : HasOngoingMigration(com.hazelcast.internal.partition.operation.HasOngoingMigration) ShutdownResponseOperation(com.hazelcast.internal.partition.operation.ShutdownResponseOperation) PartitionBackupReplicaAntiEntropyOperation(com.hazelcast.internal.partition.operation.PartitionBackupReplicaAntiEntropyOperation) AssignPartitions(com.hazelcast.internal.partition.operation.AssignPartitions) MigrationStateImpl(com.hazelcast.internal.partition.MigrationStateImpl) PartitionStateOperation(com.hazelcast.internal.partition.operation.PartitionStateOperation) FetchPartitionStateOperation(com.hazelcast.internal.partition.operation.FetchPartitionStateOperation) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) PartitionReplicaSyncRetryResponse(com.hazelcast.internal.partition.operation.PartitionReplicaSyncRetryResponse) PartitionRuntimeState(com.hazelcast.internal.partition.PartitionRuntimeState) ShutdownRequestOperation(com.hazelcast.internal.partition.operation.ShutdownRequestOperation) PartitionReplicaSyncResponse(com.hazelcast.internal.partition.operation.PartitionReplicaSyncResponse) FetchPartitionStateOperation(com.hazelcast.internal.partition.operation.FetchPartitionStateOperation) PartitionReplicaSyncRequest(com.hazelcast.internal.partition.operation.PartitionReplicaSyncRequest) MigrationOperation(com.hazelcast.internal.partition.operation.MigrationOperation) MigrationRequestOperation(com.hazelcast.internal.partition.operation.MigrationRequestOperation) PartitionReplicaSyncRequestOffloadable(com.hazelcast.internal.partition.operation.PartitionReplicaSyncRequestOffloadable) ConstructorFunction(com.hazelcast.internal.util.ConstructorFunction) MigrationCommitOperation(com.hazelcast.internal.partition.operation.MigrationCommitOperation) ReplicaFragmentMigrationState(com.hazelcast.internal.partition.ReplicaFragmentMigrationState) PromotionCommitOperation(com.hazelcast.internal.partition.operation.PromotionCommitOperation) SafeStateCheckOperation(com.hazelcast.internal.partition.operation.SafeStateCheckOperation) PublishCompletedMigrationsOperation(com.hazelcast.internal.partition.operation.PublishCompletedMigrationsOperation) PartitionStateCheckOperation(com.hazelcast.internal.partition.operation.PartitionStateCheckOperation) ReplicaMigrationEventImpl(com.hazelcast.internal.partition.ReplicaMigrationEventImpl) ArrayDataSerializableFactory(com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory) PartitionLostEventImpl(com.hazelcast.internal.partition.PartitionLostEventImpl)

Example 2 with MigrationStateImpl

use of com.hazelcast.internal.partition.MigrationStateImpl in project hazelcast by hazelcast.

the class PromotionCommitOperation method beforePromotion.

/**
 * Sends {@link BeforePromotionOperation}s for all promotions and register a callback on each operation to track when
 * operations are finished.
 */
private CallStatus beforePromotion() {
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    OperationServiceImpl operationService = nodeEngine.getOperationService();
    InternalPartitionServiceImpl partitionService = getService();
    if (!partitionService.getMigrationManager().acquirePromotionPermit()) {
        throw new RetryableHazelcastException("Another promotion is being run currently. " + "This is only expected when promotion is retried to an unresponsive destination.");
    }
    long partitionStateStamp;
    partitionStateStamp = partitionService.getPartitionStateStamp();
    if (partitionState.getStamp() == partitionStateStamp) {
        return alreadyAppliedAllPromotions();
    }
    filterAlreadyAppliedPromotions();
    if (promotions.isEmpty()) {
        return alreadyAppliedAllPromotions();
    }
    ILogger logger = getLogger();
    migrationState = new MigrationStateImpl(Clock.currentTimeMillis(), promotions.size(), 0, 0L);
    partitionService.getMigrationInterceptor().onPromotionStart(MigrationParticipant.DESTINATION, promotions);
    partitionService.getPartitionEventManager().sendMigrationProcessStartedEvent(migrationState);
    if (logger.isFineEnabled()) {
        logger.fine("Submitting BeforePromotionOperations for " + promotions.size() + " promotions. " + "Promotion partition state stamp: " + partitionState.getStamp() + ", current partition state stamp: " + partitionStateStamp);
    }
    PromotionOperationCallback beforePromotionsCallback = new BeforePromotionOperationCallback(this, promotions.size());
    for (MigrationInfo promotion : promotions) {
        if (logger.isFinestEnabled()) {
            logger.finest("Submitting BeforePromotionOperation for promotion: " + promotion);
        }
        Operation op = new BeforePromotionOperation(promotion, beforePromotionsCallback);
        op.setPartitionId(promotion.getPartitionId()).setNodeEngine(nodeEngine).setService(partitionService);
        operationService.execute(op);
    }
    return CallStatus.VOID;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) ILogger(com.hazelcast.logging.ILogger) MigrationStateImpl(com.hazelcast.internal.partition.MigrationStateImpl) Operation(com.hazelcast.spi.impl.operationservice.Operation) MigrationCycleOperation(com.hazelcast.internal.partition.MigrationCycleOperation) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Example 3 with MigrationStateImpl

use of com.hazelcast.internal.partition.MigrationStateImpl in project hazelcast by hazelcast.

the class PromotionCommitOperation method complete.

private void complete() {
    InternalPartitionServiceImpl service = getService();
    service.getMigrationInterceptor().onPromotionComplete(MigrationParticipant.DESTINATION, promotions, success);
    PartitionEventManager eventManager = service.getPartitionEventManager();
    MigrationStateImpl ms = migrationState;
    for (MigrationInfo promotion : promotions) {
        ms = ms.onComplete(1, 0L);
        eventManager.sendMigrationEvent(ms, promotion, 0L);
    }
    eventManager.sendMigrationProcessCompletedEvent(ms);
    service.getMigrationManager().releasePromotionPermit();
}
Also used : MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) PartitionEventManager(com.hazelcast.internal.partition.impl.PartitionEventManager) MigrationStateImpl(com.hazelcast.internal.partition.MigrationStateImpl)

Example 4 with MigrationStateImpl

use of com.hazelcast.internal.partition.MigrationStateImpl in project hazelcast by hazelcast.

the class MigrationListenerAdapterTest method test_migrationFailed.

@Test
public void test_migrationFailed() {
    MigrationState migrationSchedule = new MigrationStateImpl();
    ReplicaMigrationEvent event = new ReplicaMigrationEventImpl(migrationSchedule, 0, 0, null, null, false, 0L);
    adapter.onEvent(event);
    verify(listener, never()).migrationStarted(any(MigrationState.class));
    verify(listener, never()).migrationFinished(any(MigrationState.class));
    verify(listener, never()).replicaMigrationCompleted(any(ReplicaMigrationEvent.class));
    verify(listener).replicaMigrationFailed(event);
}
Also used : MigrationState(com.hazelcast.partition.MigrationState) ReplicaMigrationEventImpl(com.hazelcast.internal.partition.ReplicaMigrationEventImpl) MigrationStateImpl(com.hazelcast.internal.partition.MigrationStateImpl) ReplicaMigrationEvent(com.hazelcast.partition.ReplicaMigrationEvent) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with MigrationStateImpl

use of com.hazelcast.internal.partition.MigrationStateImpl in project hazelcast by hazelcast.

the class MigrationListenerAdapterTest method test_migrationProcessCompleted.

@Test
public void test_migrationProcessCompleted() {
    MigrationState migrationSchedule = new MigrationStateImpl();
    ReplicaMigrationEvent event = new ReplicaMigrationEventImpl(migrationSchedule, MIGRATION_FINISHED_PARTITION_ID, 0, null, null, true, 0L);
    adapter.onEvent(event);
    verify(listener, never()).migrationStarted(any(MigrationState.class));
    verify(listener).migrationFinished(migrationSchedule);
    verify(listener, never()).replicaMigrationCompleted(any(ReplicaMigrationEvent.class));
    verify(listener, never()).replicaMigrationFailed(any(ReplicaMigrationEvent.class));
}
Also used : MigrationState(com.hazelcast.partition.MigrationState) ReplicaMigrationEventImpl(com.hazelcast.internal.partition.ReplicaMigrationEventImpl) MigrationStateImpl(com.hazelcast.internal.partition.MigrationStateImpl) ReplicaMigrationEvent(com.hazelcast.partition.ReplicaMigrationEvent) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MigrationStateImpl (com.hazelcast.internal.partition.MigrationStateImpl)7 ReplicaMigrationEventImpl (com.hazelcast.internal.partition.ReplicaMigrationEventImpl)5 MigrationState (com.hazelcast.partition.MigrationState)4 ReplicaMigrationEvent (com.hazelcast.partition.ReplicaMigrationEvent)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 MigrationInfo (com.hazelcast.internal.partition.MigrationInfo)2 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)2 MigrationCycleOperation (com.hazelcast.internal.partition.MigrationCycleOperation)1 PartitionLostEventImpl (com.hazelcast.internal.partition.PartitionLostEventImpl)1 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)1 PartitionRuntimeState (com.hazelcast.internal.partition.PartitionRuntimeState)1 ReplicaFragmentMigrationState (com.hazelcast.internal.partition.ReplicaFragmentMigrationState)1 PartitionEventManager (com.hazelcast.internal.partition.impl.PartitionEventManager)1 AssignPartitions (com.hazelcast.internal.partition.operation.AssignPartitions)1 FetchPartitionStateOperation (com.hazelcast.internal.partition.operation.FetchPartitionStateOperation)1 HasOngoingMigration (com.hazelcast.internal.partition.operation.HasOngoingMigration)1 MigrationCommitOperation (com.hazelcast.internal.partition.operation.MigrationCommitOperation)1 MigrationOperation (com.hazelcast.internal.partition.operation.MigrationOperation)1