Search in sources :

Example 1 with PartitionStateOperation

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

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

the class InternalPartitionServiceImpl method sendPartitionRuntimeState.

void sendPartitionRuntimeState(Address target) {
    if (!isLocalMemberMaster()) {
        return;
    }
    assert partitionStateManager.isInitialized();
    PartitionRuntimeState partitionState = createPartitionStateInternal();
    assert partitionState != null;
    if (logger.isFineEnabled()) {
        logger.fine("Sending partition state, stamp: " + partitionState.getStamp() + ", to " + target);
    }
    OperationService operationService = nodeEngine.getOperationService();
    PartitionStateOperation op = new PartitionStateOperation(partitionState, true);
    operationService.invokeOnTarget(SERVICE_NAME, op, target);
}
Also used : PartitionRuntimeState(com.hazelcast.internal.partition.PartitionRuntimeState) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) FetchPartitionStateOperation(com.hazelcast.internal.partition.operation.FetchPartitionStateOperation) PartitionStateOperation(com.hazelcast.internal.partition.operation.PartitionStateOperation)

Example 3 with PartitionStateOperation

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

the class InternalPartitionServiceImpl method firePartitionStateOperation.

private List<Future<Boolean>> firePartitionStateOperation(Collection<MemberImpl> members, PartitionRuntimeState partitionState, OperationService operationService) {
    final ClusterServiceImpl clusterService = node.clusterService;
    List<Future<Boolean>> calls = new ArrayList<Future<Boolean>>(members.size());
    for (MemberImpl member : members) {
        if (!(member.localMember() || clusterService.isMemberRemovedWhileClusterIsNotActive(member.getAddress()))) {
            try {
                Address address = member.getAddress();
                PartitionStateOperation operation = new PartitionStateOperation(partitionState, true);
                Future<Boolean> f = operationService.invokeOnTarget(SERVICE_NAME, operation, address);
                calls.add(f);
            } catch (Exception e) {
                logger.finest(e);
            }
        }
    }
    return calls;
}
Also used : Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FetchPartitionStateOperation(com.hazelcast.internal.partition.operation.FetchPartitionStateOperation) PartitionStateOperation(com.hazelcast.internal.partition.operation.PartitionStateOperation) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) MemberLeftException(com.hazelcast.core.MemberLeftException) ExecutionException(java.util.concurrent.ExecutionException)

Example 4 with PartitionStateOperation

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

the class InternalPartitionServiceImpl method publishPartitionRuntimeState.

/**
 * Called on the master node to publish the current partition state to all cluster nodes. It will not publish the partition
 * state if the partitions have not yet been initialized, there is ongoing repartitioning or a node is joining the cluster.
 */
@SuppressWarnings("checkstyle:npathcomplexity")
void publishPartitionRuntimeState() {
    if (!partitionStateManager.isInitialized()) {
        // do not send partition state until initialized!
        return;
    }
    if (!isLocalMemberMaster()) {
        return;
    }
    if (!areMigrationTasksAllowed()) {
        // migration is disabled because of a member leave, wait till enabled!
        return;
    }
    PartitionRuntimeState partitionState = createPartitionStateInternal();
    if (partitionState == null) {
        return;
    }
    if (logger.isFineEnabled()) {
        logger.fine("Publishing partition state, stamp: " + partitionState.getStamp());
    }
    PartitionStateOperation op = new PartitionStateOperation(partitionState, false);
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Member> members = node.clusterService.getMembers();
    for (Member member : members) {
        if (!member.localMember()) {
            try {
                operationService.send(op, member.getAddress());
            } catch (Exception e) {
                logger.finest(e);
            }
        }
    }
}
Also used : PartitionRuntimeState(com.hazelcast.internal.partition.PartitionRuntimeState) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) FetchPartitionStateOperation(com.hazelcast.internal.partition.operation.FetchPartitionStateOperation) PartitionStateOperation(com.hazelcast.internal.partition.operation.PartitionStateOperation) Member(com.hazelcast.cluster.Member) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) TimeoutException(java.util.concurrent.TimeoutException) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) MemberLeftException(com.hazelcast.core.MemberLeftException)

Aggregations

FetchPartitionStateOperation (com.hazelcast.internal.partition.operation.FetchPartitionStateOperation)4 PartitionStateOperation (com.hazelcast.internal.partition.operation.PartitionStateOperation)4 PartitionRuntimeState (com.hazelcast.internal.partition.PartitionRuntimeState)3 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)2 MemberLeftException (com.hazelcast.core.MemberLeftException)2 NoDataMemberInClusterException (com.hazelcast.partition.NoDataMemberInClusterException)2 TargetNotMemberException (com.hazelcast.spi.exception.TargetNotMemberException)2 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)2 Member (com.hazelcast.cluster.Member)1 MemberImpl (com.hazelcast.instance.MemberImpl)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 MigrationStateImpl (com.hazelcast.internal.partition.MigrationStateImpl)1 PartitionLostEventImpl (com.hazelcast.internal.partition.PartitionLostEventImpl)1 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)1 ReplicaFragmentMigrationState (com.hazelcast.internal.partition.ReplicaFragmentMigrationState)1 ReplicaMigrationEventImpl (com.hazelcast.internal.partition.ReplicaMigrationEventImpl)1 AssignPartitions (com.hazelcast.internal.partition.operation.AssignPartitions)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