Search in sources :

Example 56 with CacheConfig

use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.

the class CachePartitionIteratorMigrationTest method getCacheProxy.

private <K, V> CacheProxy<K, V> getCacheProxy(CachingProvider cachingProvider) {
    String cacheName = randomString();
    CacheManager cacheManager = cachingProvider.getCacheManager();
    CacheConfig<K, V> config = new CacheConfig<K, V>();
    config.getEvictionConfig().setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.ENTRY_COUNT).setSize(10000000);
    return (CacheProxy<K, V>) cacheManager.createCache(cacheName, config);
}
Also used : CacheProxy(com.hazelcast.cache.impl.CacheProxy) CacheManager(javax.cache.CacheManager) CacheConfig(com.hazelcast.config.CacheConfig)

Example 57 with CacheConfig

use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.

the class CachePartitionIteratorTest method getCacheProxy.

private <K, V> CacheProxy<K, V> getCacheProxy() {
    String cacheName = randomString();
    CacheManager cacheManager = cachingProvider.getCacheManager();
    CacheConfig<K, V> config = new CacheConfig<K, V>();
    config.getEvictionConfig().setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.ENTRY_COUNT).setSize(10000000);
    return (CacheProxy<K, V>) cacheManager.createCache(cacheName, config);
}
Also used : CacheProxy(com.hazelcast.cache.impl.CacheProxy) CacheManager(javax.cache.CacheManager) CacheConfig(com.hazelcast.config.CacheConfig)

Example 58 with CacheConfig

use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.

the class CacheFromDifferentNodesTest method testCompletionTestByPuttingAndRemovingFromDifferentNodes.

// Issue https://github.com/hazelcast/hazelcast/issues/5865
@Test
public void testCompletionTestByPuttingAndRemovingFromDifferentNodes() throws InterruptedException {
    String cacheName = "simpleCache";
    CacheManager cacheManager1 = cachingProvider1.getCacheManager();
    CacheManager cacheManager2 = cachingProvider2.getCacheManager();
    CacheConfig<Integer, String> config = new CacheConfig<Integer, String>();
    final SimpleEntryListener<Integer, String> listener = new SimpleEntryListener<Integer, String>();
    MutableCacheEntryListenerConfiguration<Integer, String> listenerConfiguration = new MutableCacheEntryListenerConfiguration<Integer, String>(FactoryBuilder.factoryOf(listener), null, true, true);
    config.addCacheEntryListenerConfiguration(listenerConfiguration);
    Cache<Integer, String> cache1 = cacheManager1.createCache(cacheName, config);
    Cache<Integer, String> cache2 = cacheManager2.getCache(cacheName);
    assertNotNull(cache1);
    assertNotNull(cache2);
    Integer key1 = 1;
    String value1 = "value1";
    cache1.put(key1, value1);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(1, listener.created.get());
        }
    });
    Integer key2 = 2;
    String value2 = "value2";
    cache1.put(key2, value2);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(2, listener.created.get());
        }
    });
    Set<Integer> keys = new HashSet<Integer>();
    keys.add(key1);
    keys.add(key2);
    cache2.removeAll(keys);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(2, listener.removed.get());
        }
    });
}
Also used : MutableCacheEntryListenerConfiguration(javax.cache.configuration.MutableCacheEntryListenerConfiguration) CacheEntryListenerException(javax.cache.event.CacheEntryListenerException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CacheManager(javax.cache.CacheManager) AssertTask(com.hazelcast.test.AssertTask) CacheConfig(com.hazelcast.config.CacheConfig) HashSet(java.util.HashSet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 59 with CacheConfig

use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.

the class CacheIteratorAbstractTest method getCache.

private Cache<Integer, Integer> getCache() {
    String cacheName = randomString();
    CacheManager cacheManager = cachingProvider.getCacheManager();
    CacheConfig<Integer, Integer> config = new CacheConfig<Integer, Integer>();
    return cacheManager.createCache(cacheName, config);
}
Also used : CacheManager(javax.cache.CacheManager) CacheConfig(com.hazelcast.config.CacheConfig)

Example 60 with CacheConfig

use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.

the class BasicCacheLiteMemberTest method testCacheCreation.

private void testCacheCreation(final HazelcastServerCachingProvider providerToCreate, final HazelcastServerCachingProvider providerToValidate) {
    CacheManager cacheManager = providerToCreate.getCacheManager();
    assertNotNull(cacheManager);
    assertNull(cacheManager.getCache(cacheName));
    CacheConfig<Integer, String> config = new CacheConfig<Integer, String>();
    Cache<Integer, String> cache = cacheManager.createCache(cacheName, config);
    assertNotNull(cache);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            CacheManager cm2 = providerToValidate.getCacheManager();
            assertNotNull(cm2.getCache(cacheName));
        }
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CacheManager(javax.cache.CacheManager) AssertTask(com.hazelcast.test.AssertTask) CacheConfig(com.hazelcast.config.CacheConfig) CacheEntryListenerException(javax.cache.event.CacheEntryListenerException)

Aggregations

CacheConfig (com.hazelcast.config.CacheConfig)77 Test (org.junit.Test)30 CacheManager (javax.cache.CacheManager)28 QuickTest (com.hazelcast.test.annotation.QuickTest)27 ParallelTest (com.hazelcast.test.annotation.ParallelTest)25 CachingProvider (javax.cache.spi.CachingProvider)16 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)14 HazelcastInstance (com.hazelcast.core.HazelcastInstance)14 AssertTask (com.hazelcast.test.AssertTask)13 NearCacheConfig (com.hazelcast.config.NearCacheConfig)11 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 ICacheService (com.hazelcast.cache.impl.ICacheService)8 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)8 ICache (com.hazelcast.cache.ICache)5 ClientConfig (com.hazelcast.client.config.ClientConfig)5 Config (com.hazelcast.config.Config)5 Data (com.hazelcast.nio.serialization.Data)5 CacheService (com.hazelcast.cache.impl.CacheService)4 HazelcastServerCachingProvider.createCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider.createCachingProvider)4 Map (java.util.Map)4