use of com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl in project hazelcast by hazelcast.
the class MapFetchIndexOperationTest method testRangeReverse.
@Test
public void testRangeReverse() throws ExecutionException, InterruptedException {
PartitionIdSet partitions = getLocalPartitions(instance);
IndexIterationPointer[] pointers = new IndexIterationPointer[1];
pointers[0] = IndexIterationPointer.create(30, true, 60, false, true, null);
MapOperationProvider operationProvider = getOperationProvider(map);
MapOperation operation = operationProvider.createFetchIndexOperation(mapName, orderedIndexName, 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();
assertResultSorted(result, Arrays.asList(new Person("person11", 45, "Dep5"), new Person("person10", 45, "Dep4"), new Person("person9", 45, "Dep3"), new Person("person4", 45, "Dep2"), new Person("person1", 45, "Dep1"), new Person("person5", 43, "Dep2"), new Person("person2", 39, "Dep1")));
}
use of com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl in project hazelcast by hazelcast.
the class MapFetchIndexOperationTest method whenSizeLimitIsSmall_thenFetchInMultipleCalls_reverse.
@Test
public void whenSizeLimitIsSmall_thenFetchInMultipleCalls_reverse() throws ExecutionException, InterruptedException {
PartitionIdSet partitions = getLocalPartitions(instance);
IndexIterationPointer[] pointers = new IndexIterationPointer[2];
pointers[0] = IndexIterationPointer.create(50, true, 60, true, true, null);
pointers[1] = IndexIterationPointer.create(30, true, 50, false, true, 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("person3", 60, "Dep1"), new Person("person11", 45, "Dep5"), new Person("person10", 45, "Dep4"), new Person("person9", 45, "Dep3"), new Person("person4", 45, "Dep2")));
// First pointer is done in reverse case
assertEquals(1, 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("person1", 45, "Dep1"), new Person("person5", 43, "Dep2"), new Person("person2", 39, "Dep1")));
assertEquals(0, result.getPointers().length);
}
use of com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl in project hazelcast by hazelcast.
the class MapFetchIndexOperationTest method testMigration.
// This test has different requirements, therefore depends on local variables.
// Before and After actions are dismissed.
@Test
public void testMigration() {
HazelcastInstance instance = new CustomTestInstanceFactory().newHazelcastInstance(config);
PartitionIdSet partitions = getLocalPartitions(instance);
List<Person> people = new ArrayList<>(Arrays.asList(new Person("person1", 45, null), new Person("person2", 39, null), new Person("person3", 60, null), new Person("person4", 45, null), new Person("person5", 43, null)));
IMap<String, Person> map = instance.getMap(mapName);
map.addIndex(new IndexConfig(IndexType.SORTED, "age").setName(orderedIndexName));
insertIntoMap(map, people);
IndexIterationPointer[] pointers = new IndexIterationPointer[1];
pointers[0] = IndexIterationPointer.create(10, true, 100, true, false, null);
MapOperationProvider operationProvider = getOperationProvider(map);
MapOperation operation = operationProvider.createFetchIndexOperation(mapName, orderedIndexName, pointers, partitions, 10);
Address address = instance.getCluster().getLocalMember().getAddress();
OperationServiceImpl operationService = getOperationService(instance);
try {
InvocationFuture<MapFetchIndexOperationResult> future = operationService.createInvocationBuilder(MapService.SERVICE_NAME, operation, address).invoke();
future.get();
} catch (Exception e) {
assertInstanceOf(MissingPartitionException.class, e.getCause());
} finally {
instance.shutdown();
}
}
use of com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl in project hazelcast by hazelcast.
the class ContainsValueOperationTest method executeOperation.
private InternalCompletableFuture<Object> executeOperation(Map map, String key, int value) {
int partitionId = getNode(member1).getPartitionService().getPartitionId(key);
MapProxyImpl mapProxy = (MapProxyImpl) map;
MapServiceContext mapServiceContext = ((MapService) mapProxy.getService()).getMapServiceContext();
MapOperationProvider operationProvider = mapServiceContext.getMapOperationProvider(mapProxy.getName());
OperationFactory operationFactory = operationProvider.createContainsValueOperationFactory(mapProxy.getName(), mapServiceContext.toData(value));
Operation operation = operationFactory.createOperation();
OperationServiceImpl operationService = getOperationService(member1);
return operationService.createInvocationBuilder(MapService.SERVICE_NAME, operation, partitionId).invoke();
}
use of com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl in project hazelcast by hazelcast.
the class MapFetchIndexOperationTest method testFullScan.
@Test
public void testFullScan() throws ExecutionException, InterruptedException {
PartitionIdSet partitions = getLocalPartitions(instance);
IndexIterationPointer[] pointers = new IndexIterationPointer[1];
pointers[0] = IndexIterationPointer.create(null, true, null, true, false, null);
MapOperationProvider operationProvider = getOperationProvider(map);
MapOperation operation = operationProvider.createFetchIndexOperation(mapName, orderedIndexName, pointers, partitions, 20);
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("person6", null, "Dep1"), new Person("person7", null, null), 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"), new Person("person3", 60, "Dep1"), new Person("person8", 79, null)));
}
Aggregations