use of com.hazelcast.client.cache.impl.HazelcastClientCacheManager in project hazelcast by hazelcast.
the class ClientNearCacheInvalidationTest method setup.
@Before
public void setup() {
hazelcastFactory = new TestHazelcastFactory();
member = hazelcastFactory.newHazelcastInstance(getConfig());
if (MEMBER_COUNT > 1) {
HazelcastInstance[] allMembers = new HazelcastInstance[MEMBER_COUNT];
allMembers[0] = member;
for (int i = 1; i < MEMBER_COUNT; i++) {
allMembers[i] = hazelcastFactory.newHazelcastInstance(getConfig());
}
waitAllForSafeState(allMembers);
}
ClientConfig clientConfig = createClientConfig();
clientConfig.addNearCacheConfig(createNearCacheConfig(inMemoryFormat));
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
NearCacheManager nearCacheManager = client.client.getNearCacheManager();
CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
HazelcastServerCacheManager memberCacheManager = (HazelcastServerCacheManager) HazelcastServerCachingProvider.createCachingProvider(member).getCacheManager();
ICache<Object, String> cache = cacheManager.createCache(DEFAULT_CACHE_NAME, createCacheConfig(inMemoryFormat));
ICache<Object, String> memberCache = member.getCacheManager().getCache(CacheUtil.getPrefixedCacheName(DEFAULT_CACHE_NAME, null, null));
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheManager.getCacheNameWithPrefix(DEFAULT_CACHE_NAME));
testContext = new NearCacheTestContext(client, member, cacheManager, memberCacheManager, nearCacheManager, cache, memberCache, nearCache);
// make sure several partitions are populated with data
for (int i = 0; i < 1000; i++) {
testContext.memberCache.put(Integer.toString(i), Integer.toString(i));
}
}
use of com.hazelcast.client.cache.impl.HazelcastClientCacheManager in project hazelcast by hazelcast.
the class ClientCacheNearCacheBasicTest method createContext.
@Override
protected <K, V> com.hazelcast.internal.nearcache.NearCacheTestContext<K, V, Data, String> createContext() {
ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
CacheConfig<K, V> cacheConfig = createCacheConfig(nearCacheConfig);
HazelcastInstance member = hazelcastFactory.newHazelcastInstance(getConfig());
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.client.cache.impl.HazelcastClientCacheManager in project hazelcast by hazelcast.
the class ClientCacheNearCachePreloaderTest method createClientContext.
private <K, V> NearCacheTestContext<K, V, Data, String> createClientContext(CacheConfig<K, V> cacheConfig) {
ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
NearCacheManager nearCacheManager = client.client.getNearCacheManager();
CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
String cacheNameWithPrefix = cacheManager.getCacheNameWithPrefix(nearCacheConfig.getName());
ICache<K, V> clientCache = cacheManager.createCache(nearCacheConfig.getName(), cacheConfig);
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheNameWithPrefix);
return new com.hazelcast.internal.nearcache.NearCacheTestContext<K, V, Data, String>(client.getSerializationService(), client, null, new ICacheDataStructureAdapter<K, V>(clientCache), null, false, nearCache, nearCacheManager, cacheManager, null);
}
use of com.hazelcast.client.cache.impl.HazelcastClientCacheManager in project hazelcast by hazelcast.
the class ClientNearCacheTestSupport method createNearCacheTest.
protected NearCacheTestContext createNearCacheTest(String cacheName, NearCacheConfig nearCacheConfig, CacheConfig cacheConfig) {
ClientConfig clientConfig = createClientConfig();
clientConfig.addNearCacheConfig(nearCacheConfig);
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
NearCacheManager nearCacheManager = client.client.getNearCacheManager();
CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
//noinspection unchecked
ICache<Object, String> cache = cacheManager.createCache(cacheName, cacheConfig);
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheManager.getCacheNameWithPrefix(cacheName));
return new NearCacheTestContext(client, cacheManager, nearCacheManager, cache, nearCache);
}
use of com.hazelcast.client.cache.impl.HazelcastClientCacheManager in project hazelcast by hazelcast.
the class ClientCacheNearCacheStaleReadTest method setUp.
@Before
public void setUp() {
String cacheName = randomMapName();
TestHazelcastFactory factory = new TestHazelcastFactory();
Config config = getConfig().setProperty(CACHE_INVALIDATION_MESSAGE_BATCH_FREQUENCY_SECONDS.getName(), "2");
ClientConfig clientConfig = getClientConfig(cacheName).setProperty(MAX_TOLERATED_MISS_COUNT.getName(), "0");
member = factory.newHazelcastInstance(config);
client = factory.newHazelcastClient(clientConfig);
CachingProvider provider = createClientCachingProvider(client);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
CacheConfig<String, String> cacheConfig = createCacheConfig(cacheName);
cache = cacheManager.createCache(cacheName, cacheConfig);
}
Aggregations