Search in sources :

Example 1 with PublishCompletedMigrationsOperation

use of com.hazelcast.internal.partition.operation.PublishCompletedMigrationsOperation 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 PublishCompletedMigrationsOperation

use of com.hazelcast.internal.partition.operation.PublishCompletedMigrationsOperation in project hazelcast by hazelcast.

the class MigrationManager method publishCompletedMigrations.

private void publishCompletedMigrations() {
    if (!partitionService.isLocalMemberMaster()) {
        return;
    }
    assert partitionStateManager.isInitialized();
    final List<MigrationInfo> migrations = getCompletedMigrationsCopy();
    if (logger.isFineEnabled()) {
        logger.fine("Publishing completed migrations [" + migrations.size() + "]: " + migrations);
    }
    OperationService operationService = nodeEngine.getOperationService();
    ClusterServiceImpl clusterService = node.clusterService;
    final Collection<Member> members = clusterService.getMembers();
    final AtomicInteger latch = new AtomicInteger(members.size() - 1);
    for (Member member : members) {
        if ((member.localMember())) {
            continue;
        }
        Operation operation = new PublishCompletedMigrationsOperation(migrations);
        InternalCompletableFuture<Boolean> f = operationService.invokeOnTarget(SERVICE_NAME, operation, member.getAddress());
        f.whenCompleteAsync((response, t) -> {
            if (t == null) {
                if (!Boolean.TRUE.equals(response)) {
                    logger.fine(member + " rejected completed migrations with response " + response);
                    partitionService.sendPartitionRuntimeState(member.getAddress());
                    return;
                }
                if (latch.decrementAndGet() == 0) {
                    logger.fine("Evicting " + migrations.size() + " completed migrations.");
                    evictCompletedMigrations(migrations);
                }
            } else {
                logger.fine("Failure while publishing completed migrations to " + member, t);
                partitionService.sendPartitionRuntimeState(member.getAddress());
            }
        }, asyncExecutor);
    }
}
Also used : MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) PublishCompletedMigrationsOperation(com.hazelcast.internal.partition.operation.PublishCompletedMigrationsOperation) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) ShutdownResponseOperation(com.hazelcast.internal.partition.operation.ShutdownResponseOperation) MigrationCommitOperation(com.hazelcast.internal.partition.operation.MigrationCommitOperation) MigrationRequestOperation(com.hazelcast.internal.partition.operation.MigrationRequestOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) FinalizeMigrationOperation(com.hazelcast.internal.partition.operation.FinalizeMigrationOperation) PartitionStateOperation(com.hazelcast.internal.partition.operation.PartitionStateOperation) PromotionCommitOperation(com.hazelcast.internal.partition.operation.PromotionCommitOperation) PublishCompletedMigrationsOperation(com.hazelcast.internal.partition.operation.PublishCompletedMigrationsOperation) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Member(com.hazelcast.cluster.Member)

Aggregations

MigrationCommitOperation (com.hazelcast.internal.partition.operation.MigrationCommitOperation)2 MigrationRequestOperation (com.hazelcast.internal.partition.operation.MigrationRequestOperation)2 PartitionStateOperation (com.hazelcast.internal.partition.operation.PartitionStateOperation)2 PromotionCommitOperation (com.hazelcast.internal.partition.operation.PromotionCommitOperation)2 PublishCompletedMigrationsOperation (com.hazelcast.internal.partition.operation.PublishCompletedMigrationsOperation)2 ShutdownResponseOperation (com.hazelcast.internal.partition.operation.ShutdownResponseOperation)2 Member (com.hazelcast.cluster.Member)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 MigrationInfo (com.hazelcast.internal.partition.MigrationInfo)1 MigrationStateImpl (com.hazelcast.internal.partition.MigrationStateImpl)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 ReplicaMigrationEventImpl (com.hazelcast.internal.partition.ReplicaMigrationEventImpl)1 AssignPartitions (com.hazelcast.internal.partition.operation.AssignPartitions)1 FetchPartitionStateOperation (com.hazelcast.internal.partition.operation.FetchPartitionStateOperation)1 FinalizeMigrationOperation (com.hazelcast.internal.partition.operation.FinalizeMigrationOperation)1 HasOngoingMigration (com.hazelcast.internal.partition.operation.HasOngoingMigration)1 MigrationOperation (com.hazelcast.internal.partition.operation.MigrationOperation)1