Search in sources :

Example 86 with Operation

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

the class AbstractPartitionMessageTask method processInternal.

@Override
protected CompletableFuture<Object> processInternal() {
    Operation op = prepareOperation();
    if (ClientMessage.isFlagSet(clientMessage.getHeaderFlags(), ClientMessage.BACKUP_AWARE_FLAG)) {
        op.setClientCallId(clientMessage.getCorrelationId());
    }
    op.setCallerUuid(endpoint.getUuid());
    return nodeEngine.getOperationService().createInvocationBuilder(getServiceName(), op, getPartitionId()).setResultDeserialized(false).invoke();
}
Also used : Operation(com.hazelcast.spi.impl.operationservice.Operation)

Example 87 with Operation

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

the class XAClearRemoteTransactionMessageTask method call.

@Override
protected Object call() throws Exception {
    OperationServiceImpl operationService = nodeEngine.getOperationService();
    InternalPartitionService partitionService = nodeEngine.getPartitionService();
    Data xidData = serializationService.toData(parameters);
    Operation op = new ClearRemoteTransactionOperation(xidData);
    op.setCallerUuid(endpoint.getUuid());
    int partitionId = partitionService.getPartitionId(xidData);
    InvocationBuilder builder = operationService.createInvocationBuilder(getServiceName(), op, partitionId);
    builder.setTryCount(TRY_COUNT).setResultDeserialized(false);
    builder.invoke();
    return XATransactionClearRemoteCodec.encodeResponse();
}
Also used : ClearRemoteTransactionOperation(com.hazelcast.transaction.impl.xa.operations.ClearRemoteTransactionOperation) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) Data(com.hazelcast.internal.serialization.Data) ClearRemoteTransactionOperation(com.hazelcast.transaction.impl.xa.operations.ClearRemoteTransactionOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Example 88 with Operation

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

the class ScheduledExecutorShutdownMessageTask method prepareOperation.

@Override
protected Operation prepareOperation() {
    Operation op = new ShutdownOperation(parameters.schedulerName);
    op.setCallerUuid(endpoint.getUuid());
    return op;
}
Also used : ShutdownOperation(com.hazelcast.scheduledexecutor.impl.operations.ShutdownOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) ShutdownOperation(com.hazelcast.scheduledexecutor.impl.operations.ShutdownOperation)

Example 89 with Operation

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

the class RaftService method resetCPSubsystem.

InternalCompletableFuture<Void> resetCPSubsystem() {
    checkState(cpSubsystemEnabled, "CP Subsystem is not enabled!");
    InternalCompletableFuture<Void> future = newCompletableFuture();
    ClusterService clusterService = nodeEngine.getClusterService();
    Collection<Member> members = clusterService.getMembers(NON_LOCAL_MEMBER_SELECTOR);
    if (!clusterService.isMaster()) {
        return complete(future, new IllegalStateException("Only master can reset CP Subsystem!"));
    }
    if (config.getCPMemberCount() > members.size() + 1) {
        return complete(future, new IllegalStateException("Not enough cluster members to reset CP Subsystem! " + "Required: " + config.getCPMemberCount() + ", available: " + (members.size() + 1)));
    }
    BiConsumer<Void, Throwable> callback = new BiConsumer<Void, Throwable>() {

        final AtomicInteger latch = new AtomicInteger(members.size());

        volatile Throwable failure;

        @Override
        public void accept(Void aVoid, Throwable throwable) {
            if (throwable == null) {
                if (latch.decrementAndGet() == 0) {
                    if (failure == null) {
                        future.complete(null);
                    } else {
                        complete(future, failure);
                    }
                }
            } else {
                failure = throwable;
                if (latch.decrementAndGet() == 0) {
                    complete(future, throwable);
                }
            }
        }
    };
    long seed = newSeed();
    logger.warning("Resetting CP Subsystem with groupId seed: " + seed);
    resetLocal(seed);
    OperationServiceImpl operationService = nodeEngine.getOperationService();
    for (Member member : members) {
        Operation op = new ResetCPMemberOp(seed);
        operationService.<Void>invokeOnTarget(SERVICE_NAME, op, member.getAddress()).whenCompleteAsync(callback);
    }
    return future;
}
Also used : Operation(com.hazelcast.spi.impl.operationservice.Operation) ResetCPMemberOp(com.hazelcast.cp.internal.operation.ResetCPMemberOp) ClusterService(com.hazelcast.internal.cluster.ClusterService) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CPMember(com.hazelcast.cp.CPMember) Member(com.hazelcast.cluster.Member) BiConsumer(java.util.function.BiConsumer) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Example 90 with Operation

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

the class RaftService method completeFutures.

/**
 * Completes all futures registered with {@code indices}
 * in the CP group associated with {@code groupId}.
 *
 * @return {@code true} if the CP group exists, {@code false} otherwise.
 */
public boolean completeFutures(CPGroupId groupId, Collection<Entry<Long, Object>> results) {
    if (cpSubsystemEnabled) {
        RaftNodeImpl raftNode = (RaftNodeImpl) getRaftNode(groupId);
        if (raftNode == null) {
            return false;
        }
        for (Entry<Long, Object> result : results) {
            raftNode.completeFuture(result.getKey(), result.getValue());
        }
    } else {
        int partitionId = getCPGroupPartitionId(groupId);
        UnsafeModePartitionState unsafeModeState = unsafeModeStates[partitionId];
        for (Entry<Long, Object> result : results) {
            Operation op = unsafeModeState.removeWaitingOp(result.getKey());
            sendOperationResponse(op, result.getValue());
        }
    }
    return true;
}
Also used : RaftNodeImpl(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl) Operation(com.hazelcast.spi.impl.operationservice.Operation) MigrationEndpoint(com.hazelcast.internal.partition.MigrationEndpoint) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint)

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