Search in sources :

Example 11 with InternalOperationService

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

the class AbstractAllPartitionsMessageTask method processMessage.

@Override
protected void processMessage() throws Exception {
    ClientEndpoint endpoint = getEndpoint();
    OperationFactory operationFactory = new OperationFactoryWrapper(createOperationFactory(), endpoint.getUuid());
    final InternalOperationService operationService = nodeEngine.getOperationService();
    Map<Integer, Object> map = operationService.invokeOnAllPartitions(getServiceName(), operationFactory);
    sendResponse(reduce(map));
}
Also used : OperationFactoryWrapper(com.hazelcast.client.impl.operations.OperationFactoryWrapper) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) ClientEndpoint(com.hazelcast.client.ClientEndpoint) OperationFactory(com.hazelcast.spi.OperationFactory)

Example 12 with InternalOperationService

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

the class ExecutorServiceCancelOnAddressMessageTask method createInvocationBuilder.

@Override
protected InvocationBuilder createInvocationBuilder() throws UnknownHostException {
    final InternalOperationService operationService = nodeEngine.getOperationService();
    final String serviceName = DistributedExecutorService.SERVICE_NAME;
    CancellationOperation op = new CancellationOperation(parameters.uuid, parameters.interrupt);
    return operationService.createInvocationBuilder(serviceName, op, parameters.address);
}
Also used : CancellationOperation(com.hazelcast.executor.impl.operations.CancellationOperation) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService)

Example 13 with InternalOperationService

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

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

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

the class AdvancedClusterStateTest method partitionInvocation_shouldFail_whenPartitionsNotAssigned_inFrozenState.

@Test(expected = IllegalStateException.class)
public void partitionInvocation_shouldFail_whenPartitionsNotAssigned_inFrozenState() throws InterruptedException {
    Config config = new Config();
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
    HazelcastInstance[] instances = factory.newInstances(config);
    HazelcastInstance hz1 = instances[0];
    HazelcastInstance hz2 = instances[1];
    HazelcastInstance hz3 = instances[2];
    hz2.getCluster().changeClusterState(ClusterState.FROZEN);
    InternalOperationService operationService = getNode(hz3).getNodeEngine().getOperationService();
    Operation op = new AddAndGetOperation(randomName(), 1);
    Future<Long> future = operationService.invokeOnPartition(AtomicLongService.SERVICE_NAME, op, 1);
    try {
        future.get();
        fail("Partition invocation must fail, because partitions cannot be assigned!");
    } catch (ExecutionException e) {
        // IllegalStateException should be cause of ExecutionException.
        throw ExceptionUtil.rethrow(e);
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AddAndGetOperation(com.hazelcast.concurrent.atomiclong.operations.AddAndGetOperation) Config(com.hazelcast.config.Config) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) Operation(com.hazelcast.spi.Operation) AddAndGetOperation(com.hazelcast.concurrent.atomiclong.operations.AddAndGetOperation) ExecutionException(java.util.concurrent.ExecutionException) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)20 ParallelTest (com.hazelcast.test.annotation.ParallelTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 ClientEndpoint (com.hazelcast.client.ClientEndpoint)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 Address (com.hazelcast.nio.Address)4 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)4 Data (com.hazelcast.nio.serialization.Data)3 InvocationBuilder (com.hazelcast.spi.InvocationBuilder)3 Operation (com.hazelcast.spi.Operation)3 OperationFactory (com.hazelcast.spi.OperationFactory)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 OperationFactoryWrapper (com.hazelcast.client.impl.operations.OperationFactoryWrapper)2 AddAndGetOperation (com.hazelcast.concurrent.atomiclong.operations.AddAndGetOperation)2 Config (com.hazelcast.config.Config)2 CancellationOperation (com.hazelcast.executor.impl.operations.CancellationOperation)2 MemberImpl (com.hazelcast.instance.MemberImpl)2 Future (java.util.concurrent.Future)2 AuthenticationCustomCredentialsMessageTask (com.hazelcast.client.impl.protocol.task.AuthenticationCustomCredentialsMessageTask)1