Search in sources :

Example 6 with InvocationBuilder

use of com.hazelcast.spi.InvocationBuilder in project hazelcast by hazelcast.

the class MapPublisherCreateWithValueMessageTask method createInvocations.

private void createInvocations(Collection<MemberImpl> members, List<Future> futures) {
    final InternalOperationService operationService = nodeEngine.getOperationService();
    final ClientEndpoint endpoint = getEndpoint();
    for (MemberImpl member : members) {
        Predicate predicate = serializationService.toObject(parameters.predicate);
        AccumulatorInfo accumulatorInfo = AccumulatorInfo.createAccumulatorInfo(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);
    }
}
Also used : Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) Future(java.util.concurrent.Future) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) InvocationBuilder(com.hazelcast.spi.InvocationBuilder) ClientEndpoint(com.hazelcast.client.ClientEndpoint) PublisherCreateOperation(com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation) Predicate(com.hazelcast.query.Predicate)

Example 7 with InvocationBuilder

use of com.hazelcast.spi.InvocationBuilder in project hazelcast by hazelcast.

the class MapDestroyCacheMessageTask method createInvocations.

private void createInvocations(Collection<MemberImpl> members, List<Future<Boolean>> futures) {
    InternalOperationService operationService = nodeEngine.getOperationService();
    for (MemberImpl member : members) {
        DestroyQueryCacheOperation operation = new DestroyQueryCacheOperation(parameters.mapName, parameters.cacheName);
        operation.setCallerUuid(endpoint.getUuid());
        Address address = member.getAddress();
        InvocationBuilder invocationBuilder = operationService.createInvocationBuilder(SERVICE_NAME, operation, address);
        Future future = invocationBuilder.invoke();
        futures.add(future);
    }
}
Also used : Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) DestroyQueryCacheOperation(com.hazelcast.map.impl.querycache.subscriber.operation.DestroyQueryCacheOperation) Future(java.util.concurrent.Future) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) InvocationBuilder(com.hazelcast.spi.InvocationBuilder)

Example 8 with InvocationBuilder

use of com.hazelcast.spi.InvocationBuilder in project hazelcast by hazelcast.

the class MapReduceService method processRequest.

public <R> R processRequest(Address address, ProcessingOperation processingOperation) throws ExecutionException, InterruptedException {
    InvocationBuilder invocation = nodeEngine.getOperationService().createInvocationBuilder(SERVICE_NAME, processingOperation, address);
    Future<R> future = invocation.invoke();
    return future.get();
}
Also used : InvocationBuilder(com.hazelcast.spi.InvocationBuilder)

Example 9 with InvocationBuilder

use of com.hazelcast.spi.InvocationBuilder in project hazelcast by hazelcast.

the class MapReduceUtil method executeOperation.

public static <V> V executeOperation(Operation operation, Address address, MapReduceService mapReduceService, NodeEngine nodeEngine) {
    ClusterService cs = nodeEngine.getClusterService();
    OperationService os = nodeEngine.getOperationService();
    boolean returnsResponse = operation.returnsResponse();
    try {
        if (cs.getThisAddress().equals(address)) {
            // Locally we can call the operation directly
            operation.setNodeEngine(nodeEngine);
            operation.setCallerUuid(nodeEngine.getLocalMember().getUuid());
            operation.setService(mapReduceService);
            operation.run();
            if (returnsResponse) {
                return (V) operation.getResponse();
            }
        } else {
            if (returnsResponse) {
                InvocationBuilder ib = os.createInvocationBuilder(SERVICE_NAME, operation, address);
                return (V) ib.invoke().get();
            } else {
                os.send(operation, address);
            }
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return null;
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) OperationService(com.hazelcast.spi.OperationService) InvocationBuilder(com.hazelcast.spi.InvocationBuilder) RemoteMapReduceException(com.hazelcast.mapreduce.RemoteMapReduceException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

InvocationBuilder (com.hazelcast.spi.InvocationBuilder)9 Operation (com.hazelcast.spi.Operation)4 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)3 ClientEndpoint (com.hazelcast.client.ClientEndpoint)2 Member (com.hazelcast.core.Member)2 MemberImpl (com.hazelcast.instance.MemberImpl)2 RemoteMapReduceException (com.hazelcast.mapreduce.RemoteMapReduceException)2 Address (com.hazelcast.nio.Address)2 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)2 OperationService (com.hazelcast.spi.OperationService)2 Future (java.util.concurrent.Future)2 TimeoutException (java.util.concurrent.TimeoutException)2 ClusterService (com.hazelcast.internal.cluster.ClusterService)1 JoinSubmittedJobOperation (com.hazelcast.jet.impl.operation.JoinSubmittedJobOperation)1 AccumulatorInfo (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo)1 DestroyQueryCacheOperation (com.hazelcast.map.impl.querycache.subscriber.operation.DestroyQueryCacheOperation)1 PublisherCreateOperation (com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation)1 NotifyRemoteExceptionOperation (com.hazelcast.mapreduce.impl.operation.NotifyRemoteExceptionOperation)1 Predicate (com.hazelcast.query.Predicate)1 ArrayList (java.util.ArrayList)1