Search in sources :

Example 1 with OperationService

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

the class PartitionCorrectnessTestSupport method fillData.

void fillData(HazelcastInstance hz) {
    NodeEngine nodeEngine = getNode(hz).nodeEngine;
    OperationService operationService = nodeEngine.getOperationService();
    for (int i = 0; i < partitionCount; i++) {
        operationService.invokeOnPartition(null, new TestIncrementOperation(), i);
        for (String name : NAMESPACES) {
            operationService.invokeOnPartition(null, new TestFragmentIncrementOperation(name), i);
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) TestIncrementOperation(com.hazelcast.internal.partition.service.TestIncrementOperation) TestFragmentIncrementOperation(com.hazelcast.internal.partition.service.fragment.TestFragmentIncrementOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 2 with OperationService

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

the class AbstractGracefulShutdownCorrectnessTest method testPartitionData_whenNodesStartedShutdown_whileOperationsOngoing.

@Test(timeout = 6000 * 10 * 10)
public void testPartitionData_whenNodesStartedShutdown_whileOperationsOngoing() throws InterruptedException {
    final Config config = getConfig(true, false);
    Future future = spawn(() -> {
        LinkedList<HazelcastInstance> instances = new LinkedList<>(Arrays.asList(factory.newInstances(config, nodeCount)));
        try {
            for (int i = 0; i < 3; i++) {
                shutdownNodes(instances, shutdownNodeCount);
                Collection<HazelcastInstance> startedInstances = startNodes(config, shutdownNodeCount);
                instances.addAll(startedInstances);
            }
            shutdownNodes(instances, shutdownNodeCount);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    });
    HazelcastInstance hz = factory.newHazelcastInstance(config);
    NodeEngine nodeEngine = getNodeEngineImpl(hz);
    while (!nodeEngine.getClusterService().isJoined()) {
        TimeUnit.MILLISECONDS.sleep(100);
    }
    OperationService operationService = nodeEngine.getOperationService();
    int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
    int value = 0;
    do {
        value++;
        for (int p = 0; p < partitionCount; p++) {
            operationService.invokeOnPartition(null, new TestPutOperation(value), p).join();
        }
    } while (!future.isDone());
    for (int p = 0; p < partitionCount; p++) {
        Integer actual = (Integer) operationService.invokeOnPartition(null, new TestGetOperation(), p).join();
        assertNotNull(actual);
        assertEquals(value, actual.intValue());
    }
}
Also used : TestPutOperation(com.hazelcast.internal.partition.service.TestPutOperation) TestGetOperation(com.hazelcast.internal.partition.service.TestGetOperation) Config(com.hazelcast.config.Config) LinkedList(java.util.LinkedList) NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Test(org.junit.Test)

Example 3 with OperationService

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

the class InternalPartitionServiceStackOverflowTest method test.

public void test(int partitionId) {
    HazelcastInstance hz = createHazelcastInstance();
    OperationService opService = getNode(hz).nodeEngine.getOperationService();
    int iterations = 2000;
    final CountDownLatch latch = new CountDownLatch(iterations);
    for (int k = 0; k < iterations; k++) {
        Operation op;
        if (partitionId >= 0) {
            op = new SlowPartitionAwareSystemOperation(latch, partitionId);
        } else {
            op = new SlowPartitionUnawareSystemOperation(latch);
        }
        op.setOperationResponseHandler(OperationResponseHandlerFactory.createEmptyResponseHandler());
        opService.execute(op);
    }
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertEquals(0, latch.getCount());
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) PartitionAwareOperation(com.hazelcast.spi.impl.operationservice.PartitionAwareOperation) UrgentSystemOperation(com.hazelcast.spi.impl.operationservice.UrgentSystemOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 4 with OperationService

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

the class MapIndexLifecycleTest method numberOfPartitionQueryResults.

private int numberOfPartitionQueryResults(HazelcastInstance instance, int partitionId, String attribute, Comparable value) {
    OperationService operationService = getOperationService(instance);
    Query query = Query.of().mapName(mapName).iterationType(IterationType.KEY).predicate(Predicates.equal(attribute, value)).build();
    Operation queryOperation = getMapOperationProvider(instance, mapName).createQueryPartitionOperation(query);
    InternalCompletableFuture<QueryResult> future = operationService.invokeOnPartition(MapService.SERVICE_NAME, queryOperation, partitionId);
    return future.join().size();
}
Also used : QueryResult(com.hazelcast.map.impl.query.QueryResult) Query(com.hazelcast.map.impl.query.Query) Accessors.getOperationService(com.hazelcast.test.Accessors.getOperationService) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation)

Example 5 with OperationService

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

the class RingbufferProxy method readManyAsync.

@Override
public CompletionStage<ReadResultSet<E>> readManyAsync(long startSequence, int minCount, int maxCount, @Nullable IFunction<E, Boolean> filter) {
    checkSequence(startSequence);
    checkNotNegative(minCount, "minCount can't be smaller than 0");
    checkTrue(maxCount >= minCount, "maxCount should be equal or larger than minCount");
    checkTrue(maxCount <= config.getCapacity(), "the maxCount should be smaller than or equal to the capacity");
    checkTrue(maxCount <= MAX_BATCH_SIZE, "maxCount can't be larger than " + MAX_BATCH_SIZE);
    Operation op = new ReadManyOperation<>(name, startSequence, minCount, maxCount, filter).setPartitionId(partitionId);
    OperationService operationService = getOperationService();
    return operationService.createInvocationBuilder(null, op, partitionId).setCallTimeout(Long.MAX_VALUE).invoke();
}
Also used : AddAllOperation(com.hazelcast.ringbuffer.impl.operations.AddAllOperation) GenericOperation(com.hazelcast.ringbuffer.impl.operations.GenericOperation) ReadOneOperation(com.hazelcast.ringbuffer.impl.operations.ReadOneOperation) ReadManyOperation(com.hazelcast.ringbuffer.impl.operations.ReadManyOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) AddOperation(com.hazelcast.ringbuffer.impl.operations.AddOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Aggregations

OperationService (com.hazelcast.spi.impl.operationservice.OperationService)140 Operation (com.hazelcast.spi.impl.operationservice.Operation)55 Test (org.junit.Test)54 HazelcastInstance (com.hazelcast.core.HazelcastInstance)46 QuickTest (com.hazelcast.test.annotation.QuickTest)41 Accessors.getOperationService (com.hazelcast.test.Accessors.getOperationService)40 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)40 Address (com.hazelcast.cluster.Address)31 NodeEngine (com.hazelcast.spi.impl.NodeEngine)31 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)24 Future (java.util.concurrent.Future)24 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)23 Config (com.hazelcast.config.Config)22 Member (com.hazelcast.cluster.Member)21 Data (com.hazelcast.internal.serialization.Data)12 SlowTest (com.hazelcast.test.annotation.SlowTest)12 ClusterService (com.hazelcast.internal.cluster.ClusterService)9 ILogger (com.hazelcast.logging.ILogger)7 ArrayList (java.util.ArrayList)7 IPartitionService (com.hazelcast.internal.partition.IPartitionService)6