use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class NearCacheManagerTestSupport method doDestroyNearCacheAndDestroyAllNearCaches.
void doDestroyNearCacheAndDestroyAllNearCaches() {
NearCacheManager nearCacheManager = createNearCacheManager();
for (int i = 0; i < DEFAULT_NEAR_CACHE_COUNT; i++) {
createNearCache(nearCacheManager, DEFAULT_NEAR_CACHE_NAME + "-" + i);
}
Collection<NearCache> nearCaches1 = nearCacheManager.listAllNearCaches();
assertEquals(DEFAULT_NEAR_CACHE_COUNT, nearCaches1.size());
for (int i = 0; i < DEFAULT_NEAR_CACHE_COUNT; i++) {
assertTrue(nearCacheManager.destroyNearCache(DEFAULT_NEAR_CACHE_NAME + "-" + i));
}
Collection<NearCache> nearCaches2 = nearCacheManager.listAllNearCaches();
// destroy also removes Near Cache
assertEquals(0, nearCaches2.size());
assertFalse(nearCacheManager.clearNearCache(DEFAULT_NEAR_CACHE_NAME + "-" + DEFAULT_NEAR_CACHE_COUNT));
for (int i = 0; i < DEFAULT_NEAR_CACHE_COUNT; i++) {
createNearCache(nearCacheManager, DEFAULT_NEAR_CACHE_NAME + "-" + i);
}
Collection<NearCache> nearCaches3 = nearCacheManager.listAllNearCaches();
assertEquals(DEFAULT_NEAR_CACHE_COUNT, nearCaches3.size());
nearCacheManager.destroyAllNearCaches();
Collection<NearCache> nearCaches4 = nearCacheManager.listAllNearCaches();
// destroy all also removes Near Caches
assertEquals(0, nearCaches4.size());
}
use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class ClientMapNearCacheSerializationCountTest method createNearCacheContextBuilder.
private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
ClientConfig clientConfig = getClientConfig();
if (nearCacheConfig != null) {
clientConfig.addNearCacheConfig(nearCacheConfig);
}
prepareSerializationConfig(clientConfig.getSerializationConfig());
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
IMap<K, V> clientMap = client.getMap(DEFAULT_NEAR_CACHE_NAME);
NearCacheManager nearCacheManager = ((ClientMapProxy) clientMap).getContext().getNearCacheManager(clientMap.getServiceName());
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(clientMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager);
}
use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class ClientMapNearCacheLeakTest method createNearCacheContextBuilder.
private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
ClientConfig clientConfig = getClientConfig();
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
IMap<K, V> clientMap = client.getMap(DEFAULT_NEAR_CACHE_NAME);
NearCacheManager nearCacheManager = ((ClientMapProxy) clientMap).getContext().getNearCacheManager(clientMap.getServiceName());
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
ClientContext clientContext = ((ClientProxy) clientMap).getContext();
RepairingTask repairingTask = clientContext.getRepairingTask(MapService.SERVICE_NAME);
return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(clientMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setRepairingTask(repairingTask);
}
use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class LiteMemberClientMapNearCacheBasicTest method createNearCacheContextBuilder.
private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder(IMapMapStore mapStore) {
Config configWithNearCache = getConfig(mapStore, true);
HazelcastInstance liteMember = hazelcastFactory.newHazelcastInstance(configWithNearCache);
IMap<K, V> liteMemberMap = liteMember.getMap(DEFAULT_NEAR_CACHE_NAME);
NearCacheManager nearCacheManager = getMapNearCacheManager(liteMember);
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, getSerializationService(liteMember)).setNearCacheInstance(liteMember).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(liteMemberMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setLoader(mapStore);
}
use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class ClientMapNearCachePreloaderTest method createClientContext.
@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createClientContext() {
ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
IMap<K, V> clientMap = client.getMap(nearCacheConfig.getName());
NearCacheManager nearCacheManager = client.client.getNearCacheManager();
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(nearCacheConfig.getName());
return new NearCacheTestContext<K, V, Data, String>(client.getSerializationService(), client, null, new IMapDataStructureAdapter<K, V>(clientMap), null, false, nearCache, nearCacheManager);
}
Aggregations