use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class OverloadedConnectionsPluginTest method test.
@Test
public void test() {
spawn(new Runnable() {
@Override
public void run() {
IMap<String, String> map = local.getMap("foo");
while (!stop) {
map.getAsync(remoteKey);
}
}
});
assertTrueEventually(new AssertTask() {
@Override
public void run() {
plugin.run(logWriter);
assertContains(GetOperation.class.getSimpleName() + " sampleCount=");
}
});
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class MapExpirationManagerTest method restarts_running_backgroundClearTask_when_lifecycleState_turns_to_MERGED.
@Test
public void restarts_running_backgroundClearTask_when_lifecycleState_turns_to_MERGED() {
Config config = getConfig();
config.setProperty(taskPeriodSecondsPropName(), "1");
HazelcastInstance node = createHazelcastInstance(config);
final AtomicInteger expirationCounter = new AtomicInteger();
IMap<Integer, Integer> map = node.getMap("test");
map.addEntryListener((EntryExpiredListener) event -> expirationCounter.incrementAndGet(), true);
map.put(1, 1, 3, TimeUnit.SECONDS);
((LifecycleServiceImpl) node.getLifecycleService()).fireLifecycleEvent(MERGING);
((LifecycleServiceImpl) node.getLifecycleService()).fireLifecycleEvent(MERGED);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
int expirationCount = expirationCounter.get();
assertEquals(format("Expecting 1 expiration but found:%d", expirationCount), 1, expirationCount);
}
});
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class MBeanDestroyTest method testMap.
@Test
public void testMap() throws Exception {
IMap map = holder.getHz().getMap("map");
map.size();
holder.assertMBeanExistEventually("IMap", map.getName());
destroyObjectAndAssert(map, "IMap");
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class MBeanTest method testMap.
@Test
public void testMap() throws Exception {
IMap map = holder.getHz().getMap("map");
map.size();
holder.assertMBeanExistEventually("IMap", map.getName());
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ReadMetricsOperationTest method testMetricsPresent_map.
@Test
public void testMetricsPresent_map() {
Config config = new Config();
HazelcastInstance hzInstance = createHazelcastInstance(config);
IMap<Object, Object> map = hzInstance.getMap("map");
map.put("key", "value");
NodeEngineImpl nodeEngine = getNode(hzInstance).getNodeEngine();
OperationServiceImpl operationService = nodeEngine.getOperationService();
AtomicLong nextSequence = new AtomicLong();
assertTrueEventually(() -> {
long sequence = nextSequence.get();
ReadMetricsOperation readMetricsOperation = new ReadMetricsOperation(sequence);
InternalCompletableFuture<RingbufferSlice<Map.Entry<Long, byte[]>>> future = operationService.invokeOnTarget(MetricsService.SERVICE_NAME, readMetricsOperation, nodeEngine.getThisAddress());
RingbufferSlice<Map.Entry<Long, byte[]>> ringbufferSlice = future.get();
MetricsResultSet metricsResultSet = new MetricsResultSet(ringbufferSlice.nextSequence(), ringbufferSlice.elements());
nextSequence.set(metricsResultSet.nextSequence());
boolean mapMetric = false;
List<Map.Entry<Long, byte[]>> collections = metricsResultSet.collections();
MetricKeyConsumer metricConsumer = new MetricKeyConsumer();
for (Map.Entry<Long, byte[]> entry : collections) {
MetricsCompressor.extractMetrics(entry.getValue(), metricConsumer);
}
assertTrue(metricConsumer.mapMetric);
});
}
Aggregations