Search in sources :

Example 71 with CacheSimpleConfig

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

the class CachePartitionLostListenerConfigTest method testCachePartitionLostListener_registeredViaImplementationInConfigObject.

@Test
public void testCachePartitionLostListener_registeredViaImplementationInConfigObject() {
    final String cacheName = "myCache";
    Config config = new Config();
    CacheSimpleConfig cacheConfig = config.getCacheConfig(cacheName);
    CachePartitionLostListener listener = mock(CachePartitionLostListener.class);
    cacheConfig.addCachePartitionLostListenerConfig(new CachePartitionLostListenerConfig(listener));
    cacheConfig.setBackupCount(0);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    HazelcastInstance instance = factory.newHazelcastInstance(config);
    HazelcastServerCachingProvider cachingProvider = createServerCachingProvider(instance);
    CacheManager cacheManager = cachingProvider.getCacheManager();
    cacheManager.getCache(cacheName);
    final EventService eventService = getNode(instance).getNodeEngine().getEventService();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            Collection<EventRegistration> registrations = eventService.getRegistrations(CacheService.SERVICE_NAME, cacheName);
            assertFalse(registrations.isEmpty());
        }
    });
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) EventCollectingCachePartitionLostListener(com.hazelcast.cache.CachePartitionLostListenerTest.EventCollectingCachePartitionLostListener) CachePartitionLostListener(com.hazelcast.cache.impl.event.CachePartitionLostListener) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) Config(com.hazelcast.config.Config) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) EventService(com.hazelcast.spi.impl.eventservice.EventService) IOException(java.io.IOException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) CacheManager(javax.cache.CacheManager) AssertTask(com.hazelcast.test.AssertTask) Collection(java.util.Collection) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 72 with CacheSimpleConfig

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

the class CacheConfigPropagationTest method getConfig.

@Override
protected Config getConfig() {
    Config config = super.getConfig();
    config.addCacheConfig(new CacheSimpleConfig().setName("declared-cache*"));
    return config;
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) Config(com.hazelcast.config.Config) CacheConfig(com.hazelcast.config.CacheConfig) MerkleTreeConfig(com.hazelcast.config.MerkleTreeConfig)

Example 73 with CacheSimpleConfig

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

the class CacheCreateUseDestroyTest method getConfig.

@Override
protected Config getConfig() {
    Config config = super.getConfig();
    CacheSimpleEntryListenerConfig entryListenerConfig = new CacheSimpleEntryListenerConfig();
    entryListenerConfig.setCacheEntryListenerFactory("com.hazelcast.cache.impl.CacheCreateUseDestroyTest$CacheEntryListenerFactory");
    entryListenerConfig.setOldValueRequired(true);
    entryListenerConfig.setSynchronous(true);
    CacheSimpleConfig cacheSimpleConfig = new CacheSimpleConfig().setName("cache*").setInMemoryFormat(inMemoryFormat).setStatisticsEnabled(true).setManagementEnabled(true).setCacheEntryListeners(Collections.singletonList(entryListenerConfig));
    if (inMemoryFormat == NATIVE) {
        EvictionConfig evictionConfig = new EvictionConfig().setSize(90).setMaxSizePolicy(USED_NATIVE_MEMORY_PERCENTAGE).setEvictionPolicy(LFU);
        cacheSimpleConfig.setEvictionConfig(evictionConfig);
        NativeMemoryConfig memoryConfig = new NativeMemoryConfig().setEnabled(true).setSize(NATIVE_MEMORY_SIZE).setAllocatorType(NativeMemoryConfig.MemoryAllocatorType.STANDARD);
        config.setNativeMemoryConfig(memoryConfig);
    }
    config.addCacheConfig(cacheSimpleConfig);
    return config;
}
Also used : NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) CacheConfig(com.hazelcast.config.CacheConfig) CacheSimpleEntryListenerConfig(com.hazelcast.config.CacheSimpleEntryListenerConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) Config(com.hazelcast.config.Config) EvictionConfig(com.hazelcast.config.EvictionConfig) CacheSimpleEntryListenerConfig(com.hazelcast.config.CacheSimpleEntryListenerConfig)

Example 74 with CacheSimpleConfig

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

the class CacheThroughHazelcastInstanceTest method createCacheSimpleConfig.

protected CacheSimpleConfig createCacheSimpleConfig(String cacheName) {
    CacheSimpleConfig cacheSimpleConfig = new CacheSimpleConfig();
    cacheSimpleConfig.setName(cacheName);
    return cacheSimpleConfig;
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig)

Example 75 with CacheSimpleConfig

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

the class CacheExpiryPolicyBackupTest method getCacheConfig.

protected CacheSimpleConfig getCacheConfig() {
    CacheSimpleConfig cacheConfig = new CacheSimpleConfig();
    cacheConfig.setName(cacheName);
    cacheConfig.setBackupCount(NINSTANCES - 1);
    return cacheConfig;
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig)

Aggregations

CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)84 Test (org.junit.Test)41 Config (com.hazelcast.config.Config)40 QuickTest (com.hazelcast.test.annotation.QuickTest)37 EvictionConfig (com.hazelcast.config.EvictionConfig)17 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)17 BeforeClass (org.junit.BeforeClass)16 CachePartitionLostListenerConfig (com.hazelcast.config.CachePartitionLostListenerConfig)15 MapConfig (com.hazelcast.config.MapConfig)11 ClientConfig (com.hazelcast.client.config.ClientConfig)10 EventJournalConfig (com.hazelcast.config.EventJournalConfig)10 MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)10 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 ExpiryPolicyFactoryConfig (com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig)9 QuorumConfig (com.hazelcast.config.QuorumConfig)9 CacheConfig (com.hazelcast.config.CacheConfig)8 TimedExpiryPolicyFactoryConfig (com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig)8 QueueConfig (com.hazelcast.config.QueueConfig)8 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)7 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)7