Search in sources :

Example 11 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class ClusterStateManager method lockClusterStateOnAllMembers.

private void lockClusterStateOnAllMembers(ClusterStateChange stateChange, NodeEngineImpl nodeEngine, long leaseTime, UUID txnId, Collection<MemberImpl> members, int memberListVersion, long partitionStateStamp) {
    Collection<Future> futures = new ArrayList<>(members.size());
    final Address thisAddress = node.getThisAddress();
    for (Member member : members) {
        Operation op = new LockClusterStateOp(stateChange, thisAddress, txnId, leaseTime, memberListVersion, partitionStateStamp);
        Future future = nodeEngine.getOperationService().invokeOnTarget(SERVICE_NAME, op, member.getAddress());
        futures.add(future);
    }
    StateManagerExceptionHandler exceptionHandler = new StateManagerExceptionHandler(logger);
    waitWithDeadline(futures, leaseTime, TimeUnit.MILLISECONDS, exceptionHandler);
    exceptionHandler.rethrowIfFailed();
}
Also used : Address(com.hazelcast.cluster.Address) LockClusterStateOp(com.hazelcast.internal.cluster.impl.operations.LockClusterStateOp) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) Operation(com.hazelcast.spi.impl.operationservice.Operation) Member(com.hazelcast.cluster.Member)

Example 12 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class MigrationRequestOperation method createNonFragmentedReplicaFragmentMigrationState.

private ReplicaFragmentMigrationState createNonFragmentedReplicaFragmentMigrationState() {
    PartitionReplicationEvent event = getPartitionReplicationEvent();
    Collection<Operation> operations = createNonFragmentedReplicationOperations(event);
    Collection<ServiceNamespace> namespaces = Collections.singleton(NonFragmentedServiceNamespace.INSTANCE);
    return createReplicaFragmentMigrationState(namespaces, operations, emptyList(), maxTotalChunkedDataInBytes);
}
Also used : NonFragmentedServiceNamespace(com.hazelcast.internal.partition.NonFragmentedServiceNamespace) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) UrgentSystemOperation(com.hazelcast.spi.impl.operationservice.UrgentSystemOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) PartitionReplicationEvent(com.hazelcast.internal.partition.PartitionReplicationEvent)

Example 13 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class PartitionReplicaManager method sendSyncReplicaRequest.

/**
 * Send the sync request to {@code target} if the max number of parallel sync requests has not been made and the target
 * was not removed while the cluster was not active. Also cancel any currently scheduled sync requests for the given
 * partition and schedule a new sync request that is to be run in the case of timeout
 */
private void sendSyncReplicaRequest(int partitionId, Collection<ServiceNamespace> requestedNamespaces, int replicaIndex, PartitionReplica target) {
    if (node.clusterService.isMissingMember(target.address(), target.uuid())) {
        return;
    }
    int permits = tryAcquireReplicaSyncPermits(requestedNamespaces.size());
    if (permits == 0) {
        if (logger.isFinestEnabled()) {
            logger.finest("Cannot send sync replica request for partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + ", namespaces=" + requestedNamespaces + ". No permits available!");
        }
        return;
    }
    // Select only permitted number of namespaces
    Collection<ServiceNamespace> namespaces = registerSyncInfoForNamespaces(partitionId, requestedNamespaces, replicaIndex, target, permits);
    // release unused permits
    if (namespaces.size() != permits) {
        releaseReplicaSyncPermits(permits - namespaces.size());
    }
    if (namespaces.isEmpty()) {
        return;
    }
    if (logger.isFinestEnabled()) {
        logger.finest("Sending sync replica request for partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + ", namespaces=" + namespaces);
    }
    replicaSyncRequestsCounter.inc();
    Operation syncRequest = ALLOW_OFFLOAD ? new PartitionReplicaSyncRequestOffloadable(namespaces, partitionId, replicaIndex) : new PartitionReplicaSyncRequest(namespaces, partitionId, replicaIndex);
    nodeEngine.getOperationService().send(syncRequest, target.address());
}
Also used : PartitionReplicaSyncRequest(com.hazelcast.internal.partition.operation.PartitionReplicaSyncRequest) NonFragmentedServiceNamespace(com.hazelcast.internal.partition.NonFragmentedServiceNamespace) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) PartitionReplicaSyncRequestOffloadable(com.hazelcast.internal.partition.operation.PartitionReplicaSyncRequestOffloadable) Operation(com.hazelcast.spi.impl.operationservice.Operation)

Example 14 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class PartitionReplicaSyncResponse method nodeNotOwnsBackup.

/**
 * Fail all replication operations with the exception that this node is no longer the replica with the sent index
 */
private void nodeNotOwnsBackup(InternalPartitionImpl partition) {
    int partitionId = getPartitionId();
    int replicaIndex = getReplicaIndex();
    NodeEngine nodeEngine = getNodeEngine();
    ILogger logger = getLogger();
    if (logger.isFinestEnabled()) {
        int currentReplicaIndex = partition.getReplicaIndex(PartitionReplica.from(nodeEngine.getLocalMember()));
        logger.finest("This node is not backup replica of partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + " anymore. current replicaIndex=" + currentReplicaIndex);
    }
    if (operations != null) {
        PartitionReplica replica = partition.getReplica(replicaIndex);
        Member targetMember = null;
        if (replica != null) {
            ClusterServiceImpl clusterService = (ClusterServiceImpl) nodeEngine.getClusterService();
            targetMember = clusterService.getMember(replica.address(), replica.uuid());
        }
        Throwable throwable = new WrongTargetException(nodeEngine.getLocalMember(), targetMember, partitionId, replicaIndex, getClass().getName());
        for (Operation op : operations) {
            prepareOperation(op);
            onOperationFailure(op, throwable);
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger) Operation(com.hazelcast.spi.impl.operationservice.Operation) PartitionAwareOperation(com.hazelcast.spi.impl.operationservice.PartitionAwareOperation) UrgentSystemOperation(com.hazelcast.spi.impl.operationservice.UrgentSystemOperation) BackupOperation(com.hazelcast.spi.impl.operationservice.BackupOperation) Member(com.hazelcast.cluster.Member) WrongTargetException(com.hazelcast.spi.exception.WrongTargetException)

Example 15 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class MigrationRequestOperation method createAllReplicaFragmentsMigrationState.

private ReplicaFragmentMigrationState createAllReplicaFragmentsMigrationState() {
    PartitionReplicationEvent event = getPartitionReplicationEvent();
    Collection<Operation> operations = createAllReplicationOperations(event);
    return createReplicaFragmentMigrationState(namespacesContext.allNamespaces, operations, emptyList(), maxTotalChunkedDataInBytes);
}
Also used : UrgentSystemOperation(com.hazelcast.spi.impl.operationservice.UrgentSystemOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) PartitionReplicationEvent(com.hazelcast.internal.partition.PartitionReplicationEvent)

Aggregations

Operation (com.hazelcast.spi.impl.operationservice.Operation)271 Test (org.junit.Test)80 QuickTest (com.hazelcast.test.annotation.QuickTest)79 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)59 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)56 Address (com.hazelcast.cluster.Address)31 HazelcastInstance (com.hazelcast.core.HazelcastInstance)25 Data (com.hazelcast.internal.serialization.Data)24 Future (java.util.concurrent.Future)24 Member (com.hazelcast.cluster.Member)22 ArrayList (java.util.ArrayList)21 NodeEngine (com.hazelcast.spi.impl.NodeEngine)18 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)17 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)17 AssertTask (com.hazelcast.test.AssertTask)15 ILogger (com.hazelcast.logging.ILogger)14 UrgentSystemOperation (com.hazelcast.spi.impl.operationservice.UrgentSystemOperation)13 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 Config (com.hazelcast.config.Config)12 CompletableFuture (java.util.concurrent.CompletableFuture)12