use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class MapLoaderFuturesTest method zero_remaining_loading_future_after_multiple_loadAll.
@Test
public void zero_remaining_loading_future_after_multiple_loadAll() {
String mapName = "load-futures";
int keyCountToLoad = 10;
MapStoreConfig mapStoreConfig = new MapStoreConfig().setImplementation(new SimpleMapLoader(keyCountToLoad, false));
Config config = getConfig();
MapConfig mapConfig = config.getMapConfig(mapName);
mapConfig.setMapStoreConfig(mapStoreConfig);
HazelcastInstance node = createHazelcastInstance(config);
IMap map = node.getMap(mapName);
for (int i = 0; i < 3; i++) {
map.loadAll(true);
}
assertEquals(keyCountToLoad, map.size());
assertEquals(0, loadingFutureCount(mapName, node));
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class MapStoreWithPredicateTest method testKeySetWithPredicate_checksMapStoreLoad.
@Test
public void testKeySetWithPredicate_checksMapStoreLoad() {
EventBasedMapStore<String, Integer> testMapStore = new EventBasedMapStore<String, Integer>();
Map<String, Integer> mapForStore = new HashMap<String, Integer>();
mapForStore.put("key1", 17);
mapForStore.put("key2", 37);
mapForStore.put("key3", 47);
testMapStore.getStore().putAll(mapForStore);
Config config = newConfig(testMapStore, 0);
HazelcastInstance instance = createHazelcastInstance(config);
final IMap map = instance.getMap("default");
assertTrueEventually(new AssertTask() {
@Override
public void run() {
Set expected = map.keySet(Predicates.greaterThan("value", 1));
assertEquals(3, expected.size());
assertContains(expected, "key1");
assertContains(expected, "key2");
assertContains(expected, "key3");
}
});
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class MapStoreWithPredicateTest method testValuesWithPredicate_checksMapStoreLoad.
@Test
public void testValuesWithPredicate_checksMapStoreLoad() {
EventBasedMapStore<String, Integer> testMapStore = new EventBasedMapStore<String, Integer>();
Map<String, Integer> mapForStore = new HashMap<String, Integer>();
mapForStore.put("key1", 17);
mapForStore.put("key2", 37);
mapForStore.put("key3", 47);
testMapStore.getStore().putAll(mapForStore);
Config config = newConfig(testMapStore, 0);
HazelcastInstance instance = createHazelcastInstance(config);
final IMap map = instance.getMap("default");
assertTrueEventually(new AssertTask() {
@Override
public void run() {
final Collection values = map.values(Predicates.greaterThan("value", 1));
assertEquals(3, values.size());
assertContains(values, 17);
assertContains(values, 37);
assertContains(values, 47);
}
});
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class PartitionIndexingTest method assertPartitionsIndexedCorrectly.
private static void assertPartitionsIndexedCorrectly(int expectedPartitions, IMap... maps) {
Map<String, BitSet> indexToPartitions = new HashMap<String, BitSet>();
for (IMap map : maps) {
for (Indexes indexes : getAllIndexes(map)) {
for (InternalIndex index : indexes.getIndexes()) {
String indexName = index.getName();
BitSet indexPartitions = indexToPartitions.get(indexName);
if (indexPartitions == null) {
indexPartitions = new BitSet();
indexToPartitions.put(indexName, indexPartitions);
}
for (int partition = 0; partition < expectedPartitions; ++partition) {
if (index.hasPartitionIndexed(partition)) {
assertFalse("partition #" + partition + " is already indexed by " + indexName, indexPartitions.get(partition));
indexPartitions.set(partition);
}
}
}
}
}
for (Map.Entry<String, BitSet> indexEntry : indexToPartitions.entrySet()) {
String indexName = indexEntry.getKey();
BitSet indexPartitions = indexEntry.getValue();
int actualPartitions = indexPartitions.cardinality();
assertEquals(indexName + " is missing " + (expectedPartitions - actualPartitions) + " partitions", expectedPartitions, actualPartitions);
}
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class HazelcastConnectorTest method test_writeMapWithNearCache.
@Test
public void test_writeMapWithNearCache() {
List<Integer> items = range(0, ENTRY_COUNT).boxed().collect(toList());
sinkName = "nearCache-" + randomName();
DAG dag = new DAG();
Vertex src = dag.newVertex("src", () -> new TestProcessors.ListSource(items)).localParallelism(1);
Vertex sink = dag.newVertex("sink", SinkProcessors.writeMapP(sinkName, i -> i, i -> i));
dag.edge(between(src, sink));
instance().getJet().newJob(dag).join();
IMap<Object, Object> sinkMap = instance().getMap(sinkName);
assertInstanceOf(NearCachedMapProxyImpl.class, sinkMap);
assertEquals(ENTRY_COUNT, sinkMap.size());
}
Aggregations