Search in sources :

Example 66 with OperationServiceImpl

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

the class MapFetchIndexOperationTest method whenSizeLimitIsSmall_thenFetchInMultipleCalls.

@Test
public void whenSizeLimitIsSmall_thenFetchInMultipleCalls() throws ExecutionException, InterruptedException {
    PartitionIdSet partitions = getLocalPartitions(instance);
    IndexIterationPointer[] pointers = new IndexIterationPointer[2];
    pointers[0] = IndexIterationPointer.create(30, true, 50, false, false, null);
    pointers[1] = IndexIterationPointer.create(50, true, 60, true, false, null);
    MapOperationProvider operationProvider = getOperationProvider(map);
    MapOperation operation = operationProvider.createFetchIndexOperation(mapName, orderedIndexName, pointers, partitions, 5);
    Address address = instance.getCluster().getLocalMember().getAddress();
    OperationServiceImpl operationService = getOperationService(instance);
    MapFetchIndexOperationResult result = operationService.createInvocationBuilder(MapService.SERVICE_NAME, operation, address).<MapFetchIndexOperationResult>invoke().get();
    assertResultSorted(result, Arrays.asList(new Person("person2", 39, "Dep1"), new Person("person5", 43, "Dep2"), new Person("person1", 45, "Dep1"), new Person("person4", 45, "Dep2"), new Person("person9", 45, "Dep3")));
    // First pointer is not done yet
    assertEquals(2, result.getPointers().length);
    operation = operationProvider.createFetchIndexOperation(mapName, orderedIndexName, result.getPointers(), partitions, 5);
    result = operationService.createInvocationBuilder(MapService.SERVICE_NAME, operation, address).<MapFetchIndexOperationResult>invoke().get();
    assertResultSorted(result, Arrays.asList(new Person("person10", 45, "Dep4"), new Person("person11", 45, "Dep5"), new Person("person3", 60, "Dep1")));
    assertEquals(0, result.getPointers().length);
}
Also used : Address(com.hazelcast.cluster.Address) IndexIterationPointer(com.hazelcast.internal.iteration.IndexIterationPointer) PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) MapFetchIndexOperationResult(com.hazelcast.map.impl.operation.MapFetchIndexOperation.MapFetchIndexOperationResult) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 67 with OperationServiceImpl

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

the class MapFetchIndexOperationTest method testRange.

@Test
public void testRange() throws ExecutionException, InterruptedException {
    PartitionIdSet partitions = getLocalPartitions(instance);
    IndexIterationPointer[] pointers = new IndexIterationPointer[1];
    pointers[0] = IndexIterationPointer.create(30, true, 60, false, false, null);
    MapOperationProvider operationProvider = getOperationProvider(map);
    MapOperation operation = operationProvider.createFetchIndexOperation(mapName, orderedIndexName, pointers, partitions, 7);
    Address address = instance.getCluster().getLocalMember().getAddress();
    OperationServiceImpl operationService = getOperationService(instance);
    MapFetchIndexOperationResult result = operationService.createInvocationBuilder(MapService.SERVICE_NAME, operation, address).<MapFetchIndexOperationResult>invoke().get();
    assertResultSorted(result, Arrays.asList(new Person("person2", 39, "Dep1"), new Person("person5", 43, "Dep2"), new Person("person1", 45, "Dep1"), new Person("person4", 45, "Dep2"), new Person("person9", 45, "Dep3"), new Person("person10", 45, "Dep4"), new Person("person11", 45, "Dep5")));
}
Also used : Address(com.hazelcast.cluster.Address) IndexIterationPointer(com.hazelcast.internal.iteration.IndexIterationPointer) PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) MapFetchIndexOperationResult(com.hazelcast.map.impl.operation.MapFetchIndexOperation.MapFetchIndexOperationResult) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 68 with OperationServiceImpl

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

the class MapFetchIndexOperationTest method testMultipleLookups.

@Test
public void testMultipleLookups() throws ExecutionException, InterruptedException {
    PartitionIdSet partitions = getLocalPartitions(instance);
    IndexIterationPointer[] pointers = new IndexIterationPointer[3];
    pointers[0] = IndexIterationPointer.create(30, true, 30, true, false, null);
    pointers[1] = IndexIterationPointer.create(39, true, 39, true, false, null);
    pointers[2] = IndexIterationPointer.create(45, true, 45, true, false, null);
    MapOperationProvider operationProvider = getOperationProvider(map);
    MapOperation operation = operationProvider.createFetchIndexOperation(mapName, hashIndexName, pointers, partitions, 10);
    Address address = instance.getCluster().getLocalMember().getAddress();
    OperationServiceImpl operationService = getOperationService(instance);
    MapFetchIndexOperationResult result = operationService.createInvocationBuilder(MapService.SERVICE_NAME, operation, address).<MapFetchIndexOperationResult>invoke().get();
    assertResult(result, Arrays.asList(new Person("person2", 39, "Dep1"), new Person("person1", 45, "Dep1"), new Person("person4", 45, "Dep2"), new Person("person9", 45, "Dep3"), new Person("person10", 45, "Dep4"), new Person("person11", 45, "Dep5")));
}
Also used : Address(com.hazelcast.cluster.Address) IndexIterationPointer(com.hazelcast.internal.iteration.IndexIterationPointer) PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) MapFetchIndexOperationResult(com.hazelcast.map.impl.operation.MapFetchIndexOperation.MapFetchIndexOperationResult) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 69 with OperationServiceImpl

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

the class MapFetchIndexOperationTest method testMultipleRanges.

@Test
public void testMultipleRanges() throws ExecutionException, InterruptedException {
    PartitionIdSet partitions = getLocalPartitions(instance);
    IndexIterationPointer[] pointers = new IndexIterationPointer[2];
    pointers[0] = IndexIterationPointer.create(30, true, 40, true, false, null);
    pointers[1] = IndexIterationPointer.create(50, true, 60, true, false, null);
    MapOperationProvider operationProvider = getOperationProvider(map);
    MapOperation operation = operationProvider.createFetchIndexOperation(mapName, orderedIndexName, pointers, partitions, 5);
    Address address = instance.getCluster().getLocalMember().getAddress();
    OperationServiceImpl operationService = getOperationService(instance);
    MapFetchIndexOperationResult result = operationService.createInvocationBuilder(MapService.SERVICE_NAME, operation, address).<MapFetchIndexOperationResult>invoke().get();
    assertResultSorted(result, Arrays.asList(new Person("person2", 39, "Dep1"), new Person("person3", 60, "Dep1")));
}
Also used : Address(com.hazelcast.cluster.Address) IndexIterationPointer(com.hazelcast.internal.iteration.IndexIterationPointer) PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) MapFetchIndexOperationResult(com.hazelcast.map.impl.operation.MapFetchIndexOperation.MapFetchIndexOperationResult) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 70 with OperationServiceImpl

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

the class AbstractWanCustomPublisherMapTest method runMergeOpForWAN.

private void runMergeOpForWAN(boolean enableWANReplicationEvent) {
    // init hazelcast instances
    String mapName = "merge_operation_generates_wan_replication_event";
    initInstancesAndMap(mapName);
    // get internal services to use in this test
    HazelcastInstance node = instance1;
    NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(node);
    InternalPartitionService partitionService = nodeEngineImpl.getPartitionService();
    OperationServiceImpl operationService = nodeEngineImpl.getOperationService();
    SerializationService serializationService = nodeEngineImpl.getSerializationService();
    MapService mapService = nodeEngineImpl.getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapOperationProvider operationProvider = mapServiceContext.getMapOperationProvider(mapName);
    // prepare and send one merge operation
    Data data = serializationService.toData(1);
    MapOperation op;
    SimpleEntryView<Data, Data> entryView = new SimpleEntryView<Data, Data>().withKey(data).withValue(data);
    MapMergeTypes<Object, Object> mergingEntry = createMergingEntry(serializationService, entryView);
    SplitBrainMergePolicy<Object, MapMergeTypes<Object, Object>, Object> mergePolicy = new com.hazelcast.spi.merge.PassThroughMergePolicy<>();
    op = operationProvider.createMergeOperation(mapName, mergingEntry, mergePolicy, !enableWANReplicationEvent);
    operationService.createInvocationBuilder(MapService.SERVICE_NAME, op, partitionService.getPartitionId(data)).invoke();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) MapMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes) MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapOperation(com.hazelcast.map.impl.operation.MapOperation) HazelcastInstance(com.hazelcast.core.HazelcastInstance) SimpleEntryView(com.hazelcast.map.impl.SimpleEntryView) MapService(com.hazelcast.map.impl.MapService) 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