use of com.hazelcast.core.IMap in project cas by apereo.
the class HazelcastMonitor method getStatistics.
@Override
protected CacheStatistics[] getStatistics() {
final List<CacheStatistics> statsList = new ArrayList<>();
final HazelcastProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
LOGGER.debug("Locating hazelcast instance [{}]...", hz.getCluster().getInstanceName());
final HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(hz.getCluster().getInstanceName());
instance.getConfig().getMapConfigs().keySet().forEach(key -> {
final IMap map = instance.getMap(key);
LOGGER.debug("Starting to collect hazelcast statistics for map [{}] identified by key [{}]...", map, key);
statsList.add(new HazelcastStatistics(map, hz.getCluster().getMembers().size()));
});
return statsList.toArray(new CacheStatistics[statsList.size()]);
}
use of com.hazelcast.core.IMap in project spring-boot by spring-projects.
the class HazelcastCacheStatisticsProvider method getCacheStatistics.
@Override
public CacheStatistics getCacheStatistics(CacheManager cacheManager, HazelcastCache cache) {
DefaultCacheStatistics statistics = new DefaultCacheStatistics();
LocalMapStats mapStatistics = ((IMap<?, ?>) cache.getNativeCache()).getLocalMapStats();
statistics.setSize(mapStatistics.getOwnedEntryCount());
statistics.setGetCacheCounts(mapStatistics.getHits(), mapStatistics.getGetOperationCount() - mapStatistics.getHits());
return statistics;
}
use of com.hazelcast.core.IMap in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testOperationRedo.
@Test(timeout = 60000)
public void testOperationRedo() throws Exception {
final HazelcastInstance hz1 = hazelcastFactory.newHazelcastInstance();
hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setRedoOperation(true);
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
final Thread thread = new Thread() {
public void run() {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
hz1.getLifecycleService().shutdown();
}
};
final IMap map = client.getMap("m");
thread.start();
int expected = 1000;
for (int i = 0; i < expected; i++) {
map.put(i, "item" + i);
}
thread.join();
assertEquals(expected, map.size());
}
use of com.hazelcast.core.IMap in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testMemberAddedWithListeners_thenCheckOperationsNotHanging.
@Test(timeout = 120000)
public void testMemberAddedWithListeners_thenCheckOperationsNotHanging() throws Exception {
hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.setProperty(ClientExecutionServiceImpl.INTERNAL_EXECUTOR_POOL_SIZE.getName(), "1");
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
IMap map = client.getMap("map");
map.addEntryListener(mock(MapListener.class), true);
HazelcastInstance h2 = hazelcastFactory.newHazelcastInstance();
String key = generateKeyOwnedBy(h2);
map.get(key);
}
use of com.hazelcast.core.IMap in project hazelcast by hazelcast.
the class ClientMaxAllowedInvocationTest method testMaxAllowed_withUnfinishedCallback.
@Test(expected = HazelcastOverloadException.class)
public void testMaxAllowed_withUnfinishedCallback() throws ExecutionException, InterruptedException {
int MAX_ALLOWED = 10;
hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.setProperty(ClientProperty.MAX_CONCURRENT_INVOCATIONS.getName(), String.valueOf(MAX_ALLOWED));
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
String name = randomString();
IMap map = client.getMap(name);
IExecutorService executorService = client.getExecutorService(randomString());
for (int i = 0; i < MAX_ALLOWED - 1; i++) {
executorService.submit(new SleepyProcessor(Integer.MAX_VALUE));
}
ClientDelegatingFuture future = (ClientDelegatingFuture) executorService.submit(new SleepyProcessor(2000));
CountDownLatch countDownLatch = new CountDownLatch(1);
future.andThenInternal(new SleepyCallback(countDownLatch), false);
future.get();
try {
map.get(1);
} catch (HazelcastOverloadException e) {
throw e;
} finally {
countDownLatch.countDown();
}
}
Aggregations