use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class ClientCacheNearCacheSerializationCountTest method createContext.
@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
Config config = getConfig();
prepareSerializationConfig(config.getSerializationConfig());
ClientConfig clientConfig = getClientConfig();
if (nearCacheConfig != null) {
clientConfig.addNearCacheConfig(nearCacheConfig);
}
prepareSerializationConfig(clientConfig.getSerializationConfig());
CacheConfig<K, V> cacheConfig = createCacheConfig(cacheInMemoryFormat);
HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
CachingProvider memberProvider = HazelcastServerCachingProvider.createCachingProvider(member);
HazelcastServerCacheManager memberCacheManager = (HazelcastServerCacheManager) memberProvider.getCacheManager();
NearCacheManager nearCacheManager = client.client.getNearCacheManager();
CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
String cacheNameWithPrefix = cacheManager.getCacheNameWithPrefix(DEFAULT_NEAR_CACHE_NAME);
ICache<K, V> clientCache = cacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
ICache<K, V> memberCache = memberCacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheNameWithPrefix);
return new NearCacheTestContext<K, V, Data, String>(client.getSerializationService(), client, member, new ICacheDataStructureAdapter<K, V>(clientCache), new ICacheDataStructureAdapter<K, V>(memberCache), false, nearCache, nearCacheManager, cacheManager, memberCacheManager);
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class ClientCacheStatsTest method testNearCacheStatsWhenNearCacheEnabled.
@Test
public void testNearCacheStatsWhenNearCacheEnabled() {
String cacheName = randomName();
CacheConfig cacheConfig = createCacheConfig();
cacheConfig.setName(cacheName);
ClientConfig clientConfig = ((HazelcastClientProxy) client).getClientConfig();
clientConfig.addNearCacheConfig(new NearCacheConfig().setName(cacheName));
ICache<Integer, String> cache = createCache(cacheName, cacheConfig);
CacheStatistics stats = cache.getLocalCacheStatistics();
assertNotNull(stats.getNearCacheStatistics());
}
Aggregations