use of javax.cache.configuration.MutableConfiguration in project hazelcast by hazelcast.
the class ClientCacheCreationTest method createSingleCache_whenMemberBounce.
@Test
public void createSingleCache_whenMemberBounce() throws InterruptedException {
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.getConnectionStrategyConfig().getConnectionRetryConfig().setClusterConnectTimeoutMillis(Long.MAX_VALUE);
HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
HazelcastClientCachingProvider cachingProvider = createClientCachingProvider(client);
final CacheManager cacheManager = cachingProvider.getCacheManager();
hazelcastInstance.shutdown();
final CountDownLatch cacheCreated = new CountDownLatch(1);
new Thread(new Runnable() {
@Override
public void run() {
MutableConfiguration configuration = new MutableConfiguration();
cacheManager.createCache("xmlCache", configuration);
cacheCreated.countDown();
}
}).start();
// leave some gap to let create cache to start and retry
Thread.sleep(2000);
Hazelcast.newHazelcastInstance();
assertOpenEventually(cacheCreated);
}
use of javax.cache.configuration.MutableConfiguration in project ignite by apache.
the class CacheStopAndDestroySelfTest method testTckStyleCreateDestroyClose.
/**
* Tests start -> destroy -> start -> close using CacheManager.
*/
@Test
public void testTckStyleCreateDestroyClose() throws Exception {
startGridsMultiThreaded(gridCount());
CacheManager mgr = Caching.getCachingProvider().getCacheManager();
String cacheName = "cache";
mgr.createCache(cacheName, new MutableConfiguration<Integer, String>().setTypes(Integer.class, String.class));
mgr.destroyCache(cacheName);
Cache<Integer, String> cache = mgr.createCache(cacheName, new MutableConfiguration<Integer, String>().setTypes(Integer.class, String.class));
cache.close();
// Check second close succeeds without exception.
cache.close();
try {
cache.get(1);
fail();
} catch (IllegalStateException ignored) {
// No-op;
}
}
use of javax.cache.configuration.MutableConfiguration in project wcomponents by BorderTech.
the class PlainTextRendererImpl method getCache.
/**
* @return the cache instance
*/
protected synchronized Cache<String, String> getCache() {
Cache<String, String> cache = Caching.getCache(CACHE_NAME, String.class, String.class);
if (cache == null) {
final CacheManager mgr = Caching.getCachingProvider().getCacheManager();
MutableConfiguration<String, String> config = new MutableConfiguration<>();
config.setTypes(String.class, String.class);
config.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new Duration(TimeUnit.HOURS, 12)));
// No need to serialize the result
config.setStoreByValue(false);
cache = mgr.createCache(CACHE_NAME, config);
}
return cache;
}
use of javax.cache.configuration.MutableConfiguration in project wcomponents by BorderTech.
the class VelocityCacheImpl method getCache.
/**
* @return the cache instance
*/
protected synchronized Cache<Object, Resource> getCache() {
Cache<Object, Resource> cache = Caching.getCache(CACHE_NAME, Object.class, Resource.class);
if (cache == null) {
final CacheManager mgr = Caching.getCachingProvider().getCacheManager();
MutableConfiguration<Object, Resource> config = new MutableConfiguration<>();
config.setTypes(Object.class, Resource.class);
config.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new Duration(TimeUnit.HOURS, 12)));
// Velocity template classes are not serializable so use by ref.
config.setStoreByValue(false);
cache = mgr.createCache(CACHE_NAME, config);
}
return cache;
}
use of javax.cache.configuration.MutableConfiguration in project Payara by payara.
the class PayaraCacheResolverFactory method getExceptionCacheResolver.
@Override
public CacheResolver getExceptionCacheResolver(CacheMethodDetails<CacheResult> cmd) {
CacheResult result = cmd.getCacheAnnotation();
String cacheName = result.exceptionCacheName();
Cache cache = cacheManager.getCache(cacheName);
if ((cache == null)) {
cache = cacheManager.createCache(cacheName, new MutableConfiguration<Object, Object>());
}
return new PayaraCacheResolver(cache);
}
Aggregations