Search in sources :

Example 16 with OperationServiceImpl

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

the class MapPublisherCreateWithValueMessageTask method createPublishersAndGetSnapshotOf.

private List<Future> createPublishersAndGetSnapshotOf(Collection<MemberImpl> members) {
    List<Future> futures = new ArrayList<Future>(members.size());
    OperationServiceImpl operationService = nodeEngine.getOperationService();
    for (MemberImpl member : members) {
        Predicate predicate = serializationService.toObject(parameters.predicate);
        AccumulatorInfo accumulatorInfo = AccumulatorInfo.toAccumulatorInfo(parameters.mapName, parameters.cacheName, predicate, parameters.batchSize, parameters.bufferSize, parameters.delaySeconds, true, parameters.populate, parameters.coalesce);
        PublisherCreateOperation operation = new PublisherCreateOperation(accumulatorInfo);
        operation.setCallerUuid(endpoint.getUuid());
        Address address = member.getAddress();
        InvocationBuilder invocationBuilder = operationService.createInvocationBuilder(SERVICE_NAME, operation, address);
        Future future = invocationBuilder.invoke();
        futures.add(future);
    }
    return futures;
}
Also used : Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder) PublisherCreateOperation(com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) Predicate(com.hazelcast.query.Predicate)

Example 17 with OperationServiceImpl

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

the class AbstractMultiTargetMessageTask method processInternal.

@Override
protected CompletableFuture<Object> processInternal() {
    Supplier<Operation> operationSupplier = createOperationSupplier();
    Collection<Member> targets = getTargets();
    CompletableFuture<Object> finalResult = new CompletableFuture<>();
    if (targets.isEmpty()) {
        finalResult.complete(EMPTY_MAP);
        return finalResult;
    }
    final OperationServiceImpl operationService = nodeEngine.getOperationService();
    MultiTargetCallback callback = new MultiTargetCallback(targets, finalResult);
    for (Member target : targets) {
        Operation op = operationSupplier.get();
        op.setCallerUuid(endpoint.getUuid());
        InvocationBuilder builder = operationService.createInvocationBuilder(getServiceName(), op, target.getAddress()).setResultDeserialized(false);
        InvocationFuture<Object> invocationFuture = builder.invoke();
        invocationFuture.whenCompleteAsync(new SingleTargetCallback(target, callback), CALLER_RUNS);
    }
    return finalResult;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Operation(com.hazelcast.spi.impl.operationservice.Operation) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder) Member(com.hazelcast.cluster.Member) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Example 18 with OperationServiceImpl

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

the class AbstractMultiPartitionMessageTask method processInternal.

@Override
protected CompletableFuture<Map<Integer, Object>> processInternal() {
    OperationFactory operationFactory = new OperationFactoryWrapper(createOperationFactory(), endpoint.getUuid());
    OperationServiceImpl operationService = nodeEngine.getOperationService();
    return operationService.invokeOnPartitionsAsync(getServiceName(), operationFactory, getPartitions());
}
Also used : OperationFactoryWrapper(com.hazelcast.client.impl.operations.OperationFactoryWrapper) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) OperationFactory(com.hazelcast.spi.impl.operationservice.OperationFactory)

Example 19 with OperationServiceImpl

use of com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl 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 20 with OperationServiceImpl

use of com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl 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)

Aggregations

OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)70 Test (org.junit.Test)29 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)26 QuickTest (com.hazelcast.test.annotation.QuickTest)25 Address (com.hazelcast.cluster.Address)22 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)16 HazelcastInstance (com.hazelcast.core.HazelcastInstance)15 Operation (com.hazelcast.spi.impl.operationservice.Operation)12 PartitionIdSet (com.hazelcast.internal.util.collection.PartitionIdSet)11 IndexIterationPointer (com.hazelcast.internal.iteration.IndexIterationPointer)10 MapFetchIndexOperationResult (com.hazelcast.map.impl.operation.MapFetchIndexOperation.MapFetchIndexOperationResult)10 Config (com.hazelcast.config.Config)9 ExecutionException (java.util.concurrent.ExecutionException)9 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)8 AssertTask (com.hazelcast.test.AssertTask)7 CountDownLatch (java.util.concurrent.CountDownLatch)7 Member (com.hazelcast.cluster.Member)5 Data (com.hazelcast.internal.serialization.Data)5 MapService (com.hazelcast.map.impl.MapService)5 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)5