use of com.hazelcast.client.cache.impl.HazelcastClientCacheManager in project hazelcast by hazelcast.
the class ClientCacheNearCacheCacheOnUpdateTest method newNearCachedCache.
private ICache<Integer, Integer> newNearCachedCache(NearCacheConfig.LocalUpdatePolicy localUpdatePolicy) {
NearCacheConfig nearCacheConfig = getNearCacheConfig(localUpdatePolicy);
ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
CachingProvider provider = new HazelcastClientCachingProvider(client);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
return cacheManager.createCache(DEFAULT_CACHE_NAME, newCacheConfig(InMemoryFormat.BINARY));
}
use of com.hazelcast.client.cache.impl.HazelcastClientCacheManager in project hazelcast by hazelcast.
the class ClientCacheNearCacheInvalidationTest method setup.
@Before
public void setup() {
hazelcastFactory = new TestHazelcastFactory();
HazelcastInstance[] allMembers = new HazelcastInstance[MEMBER_COUNT];
for (int i = 0; i < MEMBER_COUNT; i++) {
// every instance should have its own getConfig() call because an existing EE test relies on this
Config config = getConfig().setProperty(CACHE_INVALIDATION_MESSAGE_BATCH_ENABLED.getName(), "false");
allMembers[i] = hazelcastFactory.newHazelcastInstance(config);
}
waitAllForSafeState(allMembers);
NearCacheConfig nearCacheConfig = getNearCacheConfig(inMemoryFormat);
ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
CachingProvider provider = createClientCachingProvider(client);
HazelcastServerCachingProvider memberProvider = createServerCachingProvider(allMembers[0]);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
HazelcastServerCacheManager memberCacheManager = (HazelcastServerCacheManager) memberProvider.getCacheManager();
CacheConfig<Integer, String> cacheConfig = getCacheConfig(inMemoryFormat);
ICache<Integer, String> cache = cacheManager.createCache(DEFAULT_CACHE_NAME, cacheConfig);
ICache<Integer, String> memberCache = memberCacheManager.getCache(getPrefixedCacheName(DEFAULT_CACHE_NAME, null, null));
NearCacheManager nearCacheManager = ((ClientCacheProxy) cache).getContext().getNearCacheManager(cache.getServiceName());
NearCache<Object, String> nearCache = nearCacheManager.getNearCache(cacheManager.getCacheNameWithPrefix(DEFAULT_CACHE_NAME));
SerializationService serializationService = client.getSerializationService();
invalidationListener = createInvalidationEventHandler(cache);
NearCacheTestContextBuilder<Integer, String, Object, String> builder = new NearCacheTestContextBuilder<>(nearCacheConfig, serializationService);
testContext = builder.setDataInstance(allMembers[0]).setNearCacheInstance(client).setDataAdapter(new ICacheDataStructureAdapter<>(memberCache)).setNearCacheAdapter(new ICacheDataStructureAdapter<>(cache)).setMemberCacheManager(memberCacheManager).setCacheManager(cacheManager).setNearCacheManager(nearCacheManager).setNearCache(nearCache).build();
}
use of com.hazelcast.client.cache.impl.HazelcastClientCacheManager in project hazelcast by hazelcast.
the class ClientCacheNearCacheLeakTest method createNearCacheContextBuilder.
private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder(CacheConfig<K, V> cacheConfig) {
ClientConfig clientConfig = getClientConfig();
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
CachingProvider provider = createClientCachingProvider(client);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
ICache<K, V> clientCache = cacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
NearCacheManager nearCacheManager = ((ClientCacheProxy) clientCache).getContext().getNearCacheManager(clientCache.getServiceName());
String cacheNameWithPrefix = cacheManager.getCacheNameWithPrefix(DEFAULT_NEAR_CACHE_NAME);
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheNameWithPrefix);
ClientContext clientContext = ((ClientProxy) clientCache).getContext();
RepairingTask repairingTask = clientContext.getRepairingTask(CacheService.SERVICE_NAME);
return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new ICacheDataStructureAdapter<K, V>(clientCache)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setCacheManager(cacheManager).setRepairingTask(repairingTask);
}
use of com.hazelcast.client.cache.impl.HazelcastClientCacheManager 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.client.cache.impl.HazelcastClientCacheManager in project hazelcast by hazelcast.
the class ClientCacheConfigTest method cacheCacheManagerByLocationJarFileTest.
@Test
public void cacheCacheManagerByLocationJarFileTest() throws Exception {
File jcacheConfigFile = File.createTempFile("jcache_config_", ".jar");
JarUtil.createJarFile("src/test/resources/", newArrayList("hazelcast-client-c1.xml"), jcacheConfigFile.getAbsolutePath());
URI uri = new URI("jar:" + jcacheConfigFile.toURI() + "!/hazelcast-client-c1.xml");
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(uri, null, new Properties());
assertThat(cacheManager).isNotNull();
HazelcastClientCacheManager clientCacheManager = cacheManager.unwrap(HazelcastClientCacheManager.class);
assertThat(clientCacheManager.getHazelcastInstance().getName()).isEqualTo("client-cluster1");
}
Aggregations