Search in sources :

Example 6 with CachingProvider

use of javax.cache.spi.CachingProvider in project spring-boot by spring-projects.

the class JCacheCacheConfiguration method createCacheManager.

private CacheManager createCacheManager() throws IOException {
    CachingProvider cachingProvider = getCachingProvider(this.cacheProperties.getJcache().getProvider());
    Properties properties = createCacheManagerProperties();
    Resource configLocation = this.cacheProperties.resolveConfigLocation(this.cacheProperties.getJcache().getConfig());
    if (configLocation != null) {
        return cachingProvider.getCacheManager(configLocation.getURI(), cachingProvider.getDefaultClassLoader(), properties);
    }
    return cachingProvider.getCacheManager(null, null, properties);
}
Also used : Resource(org.springframework.core.io.Resource) Properties(java.util.Properties) CachingProvider(javax.cache.spi.CachingProvider)

Example 7 with CachingProvider

use of javax.cache.spi.CachingProvider in project caffeine by ben-manes.

the class AbstractJCacheTest method beforeClass.

@BeforeClass(alwaysRun = true)
public void beforeClass() {
    CachingProvider provider = Caching.getCachingProvider(CaffeineCachingProvider.class.getName());
    cacheManager = provider.getCacheManager(provider.getDefaultURI(), provider.getDefaultClassLoader());
}
Also used : CaffeineCachingProvider(com.github.benmanes.caffeine.jcache.spi.CaffeineCachingProvider) CaffeineCachingProvider(com.github.benmanes.caffeine.jcache.spi.CaffeineCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with CachingProvider

use of javax.cache.spi.CachingProvider in project caffeine by ben-manes.

the class CacheManagerTest method beforeClass.

@BeforeClass
public void beforeClass() {
    CachingProvider provider = Caching.getCachingProvider(PROVIDER_NAME);
    cacheManager = provider.getCacheManager(provider.getDefaultURI(), provider.getDefaultClassLoader());
}
Also used : CaffeineCachingProvider(com.github.benmanes.caffeine.jcache.spi.CaffeineCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) BeforeClass(org.testng.annotations.BeforeClass)

Example 9 with CachingProvider

use of javax.cache.spi.CachingProvider in project hazelcast by hazelcast.

the class ClientCacheNearCacheStaleReadTest method setUp.

@Before
public void setUp() throws Exception {
    TestHazelcastFactory factory = new TestHazelcastFactory();
    valuePut = new AtomicInteger(0);
    stop = new AtomicBoolean(false);
    failed = new AtomicBoolean(false);
    assertionViolationCount = new AtomicInteger(0);
    Config config = new Config();
    config.setProperty(GroupProperty.CACHE_INVALIDATION_MESSAGE_BATCH_FREQUENCY_SECONDS.getName(), "2");
    member = factory.newHazelcastInstance(config);
    ClientConfig clientConfig = getClientConfig(CACHE_NAME);
    clientConfig.setProperty("hazelcast.invalidation.max.tolerated.miss.count", "0");
    client = factory.newHazelcastClient(clientConfig);
    CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
    HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
    cache = cacheManager.createCache(CACHE_NAME, createCacheConfig(inMemoryFormat));
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) CacheConfig(com.hazelcast.config.CacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) ClientConfig(com.hazelcast.client.config.ClientConfig) CachingProvider(javax.cache.spi.CachingProvider) HazelcastClientCachingProvider(com.hazelcast.client.cache.impl.HazelcastClientCachingProvider) HazelcastClientCacheManager(com.hazelcast.client.cache.impl.HazelcastClientCacheManager) Before(org.junit.Before)

Example 10 with CachingProvider

use of javax.cache.spi.CachingProvider in project hazelcast by hazelcast.

the class ClientCacheRecordStateStressTest method all_records_are_readable_state_in_the_end.

@Test
public void all_records_are_readable_state_in_the_end() throws Exception {
    HazelcastInstance member = factory.newHazelcastInstance();
    CachingProvider provider = HazelcastServerCachingProvider.createCachingProvider(member);
    final CacheManager serverCacheManager = provider.getCacheManager();
    factory.newHazelcastInstance();
    factory.newHazelcastInstance();
    // populated from member.
    CacheConfig cacheConfig = new CacheConfig();
    cacheConfig.getEvictionConfig().setMaximumSizePolicy(ENTRY_COUNT).setSize(MAX_VALUE);
    final Cache memberCache = serverCacheManager.createCache(cacheName, cacheConfig);
    for (int i = 0; i < KEY_SPACE; i++) {
        memberCache.put(i, i);
    }
    ClientConfig clientConfig = new ClientConfig();
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setInvalidateOnChange(true).setLocalUpdatePolicy(localUpdatePolicy).getEvictionConfig().setMaximumSizePolicy(ENTRY_COUNT).setSize(MAX_VALUE);
    clientConfig.addNearCacheConfig(nearCacheConfig);
    List<Thread> threads = new ArrayList<Thread>();
    // member
    for (int i = 0; i < PUT_THREAD_COUNT; i++) {
        Put put = new Put(memberCache);
        threads.add(put);
    }
    // client
    HazelcastClientProxy client = (HazelcastClientProxy) factory.newHazelcastClient(clientConfig);
    CachingProvider clientCachingProvider = HazelcastClientCachingProvider.createCachingProvider(client);
    CacheManager cacheManager = clientCachingProvider.getCacheManager();
    final Cache clientCache = cacheManager.createCache(cacheName, cacheConfig);
    for (int i = 0; i < GET_ALL_THREAD_COUNT; i++) {
        GetAll getAll = new GetAll(clientCache);
        threads.add(getAll);
    }
    for (int i = 0; i < PUT_ALL_THREAD_COUNT; i++) {
        PutAll putAll = new PutAll(clientCache);
        threads.add(putAll);
    }
    for (int i = 0; i < PUT_IF_ABSENT_THREAD_COUNT; i++) {
        PutIfAbsent putIfAbsent = new PutIfAbsent(clientCache);
        threads.add(putIfAbsent);
    }
    for (int i = 0; i < GET_THREAD_COUNT; i++) {
        Get get = new Get(clientCache);
        threads.add(get);
    }
    for (int i = 0; i < REMOVE_THREAD_COUNT; i++) {
        Remove remove = new Remove(clientCache);
        threads.add(remove);
    }
    for (int i = 0; i < CLEAR_THREAD_COUNT; i++) {
        Clear clear = new Clear(clientCache);
        threads.add(clear);
    }
    // start threads
    for (Thread thread : threads) {
        thread.start();
    }
    // stress for a while
    sleepSeconds(TEST_RUN_SECONDS);
    // stop threads
    stop.set(true);
    for (Thread thread : threads) {
        thread.join();
    }
    assertFinalRecordStateIsReadPermitted(clientCache, member);
}
Also used : ArrayList(java.util.ArrayList) NearCacheConfig(com.hazelcast.config.NearCacheConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) CacheManager(javax.cache.CacheManager) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.HazelcastClientProxy) CacheConfig(com.hazelcast.config.CacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) HazelcastClientCachingProvider(com.hazelcast.client.cache.impl.HazelcastClientCachingProvider) DefaultNearCache(com.hazelcast.internal.nearcache.impl.DefaultNearCache) Cache(javax.cache.Cache) NearCache(com.hazelcast.internal.nearcache.NearCache) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Aggregations

CachingProvider (javax.cache.spi.CachingProvider)66 CacheManager (javax.cache.CacheManager)48 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)42 Test (org.junit.Test)33 QuickTest (com.hazelcast.test.annotation.QuickTest)28 HazelcastInstance (com.hazelcast.core.HazelcastInstance)24 ParallelTest (com.hazelcast.test.annotation.ParallelTest)24 CacheConfig (com.hazelcast.config.CacheConfig)21 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)18 ClientConfig (com.hazelcast.client.config.ClientConfig)14 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 MutableConfiguration (javax.cache.configuration.MutableConfiguration)12 ICache (com.hazelcast.cache.ICache)10 HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)10 Cache (javax.cache.Cache)10 HazelcastCachingProvider (com.hazelcast.cache.HazelcastCachingProvider)9 Config (com.hazelcast.config.Config)8 Data (com.hazelcast.nio.serialization.Data)8 Before (org.junit.Before)8 HazelcastCacheManager (com.hazelcast.cache.HazelcastCacheManager)7