use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class MapFetchIndexOperationTest method testRangeComposite.
@Test
public void testRangeComposite() throws ExecutionException, InterruptedException {
PartitionIdSet partitions = getLocalPartitions(instance);
IndexIterationPointer[] pointers = new IndexIterationPointer[1];
pointers[0] = IndexIterationPointer.create(new CompositeValue(new Comparable[] { 30, CompositeValue.NEGATIVE_INFINITY }), true, new CompositeValue(new Comparable[] { CompositeValue.POSITIVE_INFINITY, CompositeValue.POSITIVE_INFINITY }), true, false, null);
MapOperationProvider operationProvider = getOperationProvider(map);
MapOperation operation = operationProvider.createFetchIndexOperation(mapName, compositeOrderedIndexName, 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("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)));
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class MapFetchIndexOperationTest method testOneSideRange.
@Test
public void testOneSideRange() throws ExecutionException, InterruptedException {
PartitionIdSet partitions = getLocalPartitions(instance);
IndexIterationPointer[] pointers = new IndexIterationPointer[1];
pointers[0] = IndexIterationPointer.create(null, 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.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class IndexStatsChangingNumberOfMembersTest method awaitStable.
protected void awaitStable(String mapName, HazelcastInstance... instances) {
// Await for migrations to complete.
waitAllForSafeState(instances);
// Make sure that all indexes contain expected partitions.
final Map<UUID, PartitionIdSet> memberToPartitions = toMemberToPartitionsMap(instances[0]);
assertTrueEventually(() -> {
for (HazelcastInstance instance : instances) {
InternalIndex index = ((MapProxyImpl<?, ?>) instance.getMap(mapName)).getService().getMapServiceContext().getMapContainer(mapName).getIndexes().getIndex(INDEX_NAME);
assertNotNull(index);
PartitionIdSet expectedPartitions = memberToPartitions.get(instance.getCluster().getLocalMember().getUuid());
// Double check: if we still see same partition distribution
assertEquals(memberToPartitions, toMemberToPartitionsMap(instances[0]));
assertEquals("MemberPartitions={size=" + expectedPartitions.size() + ", partitions=" + expectedPartitions + "}, " + index, expectedPartitions, index.getPartitionStamp().partitions);
}
});
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class IndexStatsChangingNumberOfMembersTest method toMemberToPartitionsMap.
private Map<UUID, PartitionIdSet> toMemberToPartitionsMap(HazelcastInstance instance1) {
Map<UUID, PartitionIdSet> memberToPartitions = new HashMap<>();
Set<Partition> partitions = instance1.getPartitionService().getPartitions();
for (Partition partition : partitions) {
UUID member = partition.getOwner().getUuid();
memberToPartitions.computeIfAbsent(member, (key) -> new PartitionIdSet(partitions.size())).add(partition.getPartitionId());
}
return memberToPartitions;
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class MapProjectionTest method projection_1Node_objectValue_withPartitionSet.
@Test
public void projection_1Node_objectValue_withPartitionSet() {
IMap<String, Person> map = getMapWithNodeCount(1);
populateMapWithPersons(map);
PartitionIdSet partitionSubset = new PartitionIdSet(3, asList(0, 1));
Collection<Double> result = ((MapProxyImpl<String, Person>) map).project(new ObjectValueIncrementingProjection(), Predicates.alwaysTrue(), partitionSubset);
assertThat(result, containsInAnyOrder(2.0d, 5.0d));
}
Aggregations