use of javax.cache.spi.CachingProvider in project hazelcast by hazelcast.
the class CallbackAwareClientDelegatingFutureTest method createCache.
private Cache createCache(int blockMilis, boolean throwError) {
CachingProvider cachingProvider = HazelcastClientCachingProvider.createCachingProvider(client);
CacheManager cacheManager = cachingProvider.getCacheManager();
CacheConfiguration cacheConfig = new CacheConfig().setReadThrough(true).setCacheLoaderFactory(new BlockableCacheLoaderFactory(blockMilis, throwError));
return cacheManager.createCache(CACHE_NAME, cacheConfig);
}
use of javax.cache.spi.CachingProvider 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 javax.cache.spi.CachingProvider in project hazelcast by hazelcast.
the class ClientCacheConfigTest method testGetPreConfiguredCache.
@Test
public void testGetPreConfiguredCache() {
ClientConfig config = new ClientConfig();
config.getGroupConfig().setName("cluster1");
config.getGroupConfig().setPassword("cluster1pass");
for (int i = 0; i < 4; i++) {
HazelcastInstance client = HazelcastClient.newHazelcastClient(config);
CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
CacheManager cacheManager = provider.getCacheManager();
Cache<Object, Object> cache = cacheManager.getCache(simpleConfig.getName());
Assert.assertNotNull("Cache cannot be retrieved on client: " + i, cache);
}
}
use of javax.cache.spi.CachingProvider 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 javax.cache.spi.CachingProvider in project hazelcast by hazelcast.
the class CacheEntryProcessorTest method removeRecordWithEntryProcessor.
@Test
public void removeRecordWithEntryProcessor() {
final int ENTRY_COUNT = 10;
CachingProvider cachingProvider = HazelcastServerCachingProvider.createCachingProvider(node1);
CacheManager cacheManager = cachingProvider.getCacheManager();
CompleteConfiguration<Integer, String> cacheConfig = new MutableConfiguration<Integer, String>().setTypes(Integer.class, String.class);
ICache<Integer, String> cache = cacheManager.createCache("MyCache", cacheConfig).unwrap(ICache.class);
for (int i = 0; i < ENTRY_COUNT; i++) {
cache.put(i * 1000, "Value-" + (i * 1000));
}
assertEquals(ENTRY_COUNT, cache.size());
for (int i = 0; i < ENTRY_COUNT; i++) {
if (i % 2 == 0) {
cache.invoke(i * 1000, new RemoveRecordEntryProcessor());
}
}
assertEquals(ENTRY_COUNT / 2, cache.size());
}
Aggregations