use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class MapAggregationJsonTest method testValueIsOmitted_whenObjectIsEmpty.
@Test
public void testValueIsOmitted_whenObjectIsEmpty() {
IMap<Integer, HazelcastJsonValue> map = getPreloadedMap();
map.put(OBJECT_COUNT, new HazelcastJsonValue(Json.object().toString()));
long maxLongValue = map.aggregate(Aggregators.<Map.Entry<Integer, HazelcastJsonValue>>longMax("longValue"));
assertEquals(OBJECT_COUNT - 1, maxLongValue);
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class MapAggregationJsonTest method testValueIsOmitted_whenValueIsNotAnObject.
@Test
public void testValueIsOmitted_whenValueIsNotAnObject() {
IMap<Integer, HazelcastJsonValue> map = getPreloadedMap();
map.put(OBJECT_COUNT, new HazelcastJsonValue(Json.value(5).toString()));
long maxLongValue = map.aggregate(Aggregators.<Map.Entry<Integer, HazelcastJsonValue>>longMax("longValue"));
assertEquals(OBJECT_COUNT - 1, maxLongValue);
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class MapAggregationJsonTest method testValueIsOmitted_whenAttributePathIsNotTerminal_count.
@Test
public void testValueIsOmitted_whenAttributePathIsNotTerminal_count() {
IMap<Integer, HazelcastJsonValue> map = getPreloadedMap();
map.put(OBJECT_COUNT, new HazelcastJsonValue(Json.object().add("longValue", Json.object()).toString()));
long count = map.aggregate(Aggregators.<Map.Entry<Integer, HazelcastJsonValue>>count("longValue"));
assertEquals(OBJECT_COUNT, count);
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class MapAggregationJsonTest method testValueIsOmitted_whenAttributePathDoesNotExist.
@Test
public void testValueIsOmitted_whenAttributePathDoesNotExist() {
IMap<Integer, HazelcastJsonValue> map = getPreloadedMap();
map.put(OBJECT_COUNT, new HazelcastJsonValue(Json.object().add("someField", "someValue").toString()));
long maxLongValue = map.aggregate(Aggregators.<Map.Entry<Integer, HazelcastJsonValue>>longMax("longValue"));
assertEquals(OBJECT_COUNT - 1, maxLongValue);
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class MapStoreDataLoadingContinuesWhenNodeJoins method testLoadingFinishes_whenMemberJoinsWhileLoading.
@Test(timeout = 600000)
public void testLoadingFinishes_whenMemberJoinsWhileLoading() throws Exception {
assumeThat("With LAZY InMemoryModel this test may fail due to a known issue reported in OS #11544 and #12384", initialLoadMode, not(LAZY));
final Config config = createConfigWithDelayingMapStore();
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
final CountDownLatch node1MapLoadingAboutToStart = new CountDownLatch(1);
final CountDownLatch node1FinishedLoading = new CountDownLatch(1);
final AtomicInteger mapSizeOnNode2 = new AtomicInteger();
// thread 1: start a single node and trigger loading the data
Thread thread1 = new Thread(new Runnable() {
@Override
public void run() {
HazelcastInstance instance = factory.newHazelcastInstance(config);
instances.set(0, instance);
// get map and trigger loading the data
IMap<String, String> map = instance.getMap(MAP_NAME);
node1MapLoadingAboutToStart.countDown();
LOGGER.info("Getting the size of the map on node1 -> load is triggered");
int sizeOnNode1 = map.size();
LOGGER.info("Map loading has been completed by now");
LOGGER.info("Map size on node 1: " + sizeOnNode1);
node1FinishedLoading.countDown();
}
}, "Thread 1");
thread1.start();
node1MapLoadingAboutToStart.await();
// thread 2: second member joins the cluster while loading is in progress
Thread thread2 = new Thread(new Runnable() {
@Override
public void run() {
HazelcastInstance instance = factory.newHazelcastInstance(config);
instances.set(1, instance);
try {
LOGGER.info("Getting the map " + MAP_NAME);
IMap map = instance.getMap(MAP_NAME);
final int loadTimeMillis = MS_PER_LOAD * PRELOAD_SIZE;
boolean node1FinishedLoadingInTime = node1FinishedLoading.await(loadTimeMillis, TimeUnit.MILLISECONDS);
// if node1 doesn't finish in time (unlikely because of the 5min timeout), we may execute GetSizeOperation
// again on a not fully loaded map -> map size may not match to the expected value
LOGGER.info("Node1 finished loading in time: " + node1FinishedLoadingInTime);
LOGGER.info("Getting the size of the map on node2");
mapSizeOnNode2.set(map.size());
LOGGER.info("Map size on node 2: " + mapSizeOnNode2.get());
} catch (InterruptedException e) {
ignore(e);
}
}
}, "Thread 2");
thread2.start();
// join threads
thread1.join();
thread2.join();
assertEquals(PRELOAD_SIZE, mapSizeOnNode2.get());
}
Aggregations