Search in sources :

Example 11 with CachePartitionLostListenerConfig

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

the class AddCacheConfigMessageTask method getConfig.

@Override
protected IdentifiedDataSerializable getConfig() {
    CacheSimpleConfig config = new CacheSimpleConfig();
    config.setAsyncBackupCount(parameters.asyncBackupCount);
    config.setBackupCount(parameters.backupCount);
    config.setCacheEntryListeners(parameters.cacheEntryListeners);
    config.setCacheLoader(parameters.cacheLoader);
    config.setCacheLoaderFactory(parameters.cacheLoaderFactory);
    config.setCacheWriter(parameters.cacheWriter);
    config.setCacheWriterFactory(parameters.cacheWriterFactory);
    config.setDisablePerEntryInvalidationEvents(parameters.disablePerEntryInvalidationEvents);
    config.setEvictionConfig(parameters.evictionConfig.asEvictionConfig(serializationService));
    if (parameters.expiryPolicyFactoryClassName != null) {
        config.setExpiryPolicyFactory(parameters.expiryPolicyFactoryClassName);
    } else if (parameters.timedExpiryPolicyFactoryConfig != null) {
        ExpiryPolicyFactoryConfig expiryPolicyFactoryConfig = new ExpiryPolicyFactoryConfig(parameters.timedExpiryPolicyFactoryConfig);
        config.setExpiryPolicyFactoryConfig(expiryPolicyFactoryConfig);
    }
    config.setEventJournalConfig(parameters.eventJournalConfig);
    config.setHotRestartConfig(parameters.hotRestartConfig);
    config.setInMemoryFormat(InMemoryFormat.valueOf(parameters.inMemoryFormat));
    config.setKeyType(parameters.keyType);
    config.setManagementEnabled(parameters.managementEnabled);
    config.setMergePolicyConfig(mergePolicyConfig(parameters.mergePolicy, parameters.mergeBatchSize));
    config.setName(parameters.name);
    if (parameters.partitionLostListenerConfigs != null && !parameters.partitionLostListenerConfigs.isEmpty()) {
        List<CachePartitionLostListenerConfig> listenerConfigs = (List<CachePartitionLostListenerConfig>) adaptListenerConfigs(parameters.partitionLostListenerConfigs);
        config.setPartitionLostListenerConfigs(listenerConfigs);
    } else {
        config.setPartitionLostListenerConfigs(new ArrayList<>());
    }
    config.setSplitBrainProtectionName(parameters.splitBrainProtectionName);
    config.setReadThrough(parameters.readThrough);
    config.setStatisticsEnabled(parameters.statisticsEnabled);
    config.setValueType(parameters.valueType);
    config.setWanReplicationRef(parameters.wanReplicationRef);
    config.setWriteThrough(parameters.writeThrough);
    if (parameters.isMerkleTreeConfigExists) {
        config.setMerkleTreeConfig(parameters.merkleTreeConfig);
    }
    return config;
}
Also used : ExpiryPolicyFactoryConfig(com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) List(java.util.List) ArrayList(java.util.ArrayList)

Example 12 with CachePartitionLostListenerConfig

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

the class AbstractDynamicConfigGeneratorTest method testCacheAttributes.

// CACHE
@Test
public void testCacheAttributes() {
    CacheSimpleConfig expectedConfig = new CacheSimpleConfig().setName("testCache").setEvictionConfig(evictionConfig()).setInMemoryFormat(InMemoryFormat.OBJECT).setBackupCount(2).setAsyncBackupCount(3).setCacheLoader("cacheLoader").setCacheWriter("cacheWriter").setExpiryPolicyFactoryConfig(new CacheSimpleConfig.ExpiryPolicyFactoryConfig("expiryPolicyFactory")).setManagementEnabled(true).setStatisticsEnabled(true).setKeyType("keyType").setValueType("valueType").setReadThrough(true).setDataPersistenceConfig(dataPersistenceConfig()).setEventJournalConfig(eventJournalConfig()).setCacheEntryListeners(singletonList(cacheSimpleEntryListenerConfig())).setWriteThrough(true).setPartitionLostListenerConfigs(singletonList(new CachePartitionLostListenerConfig("partitionLostListener"))).setSplitBrainProtectionName("testSplitBrainProtection");
    expectedConfig.getMergePolicyConfig().setPolicy("HigherHitsMergePolicy").setBatchSize(99);
    expectedConfig.setDisablePerEntryInvalidationEvents(true);
    expectedConfig.setWanReplicationRef(wanReplicationRef());
    Config config = new Config().addCacheConfig(expectedConfig);
    Config decConfig = getNewConfigViaGenerator(config);
    CacheSimpleConfig actualConfig = decConfig.getCacheConfig("testCache");
    assertEquals(expectedConfig, actualConfig);
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) ListConfig(com.hazelcast.config.ListConfig) EventJournalConfig(com.hazelcast.config.EventJournalConfig) AwsConfig(com.hazelcast.config.AwsConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) MapConfig(com.hazelcast.config.MapConfig) PredicateConfig(com.hazelcast.config.PredicateConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) PartitioningStrategyConfig(com.hazelcast.config.PartitioningStrategyConfig) ExecutorConfig(com.hazelcast.config.ExecutorConfig) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) DiskTierConfig(com.hazelcast.config.DiskTierConfig) IndexConfig(com.hazelcast.config.IndexConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) CacheSimpleEntryListenerConfig(com.hazelcast.config.CacheSimpleEntryListenerConfig) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) AttributeConfig(com.hazelcast.config.AttributeConfig) SetConfig(com.hazelcast.config.SetConfig) PNCounterConfig(com.hazelcast.config.PNCounterConfig) QueueConfig(com.hazelcast.config.QueueConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) CardinalityEstimatorConfig(com.hazelcast.config.CardinalityEstimatorConfig) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) TieredStoreConfig(com.hazelcast.config.TieredStoreConfig) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) TopicConfig(com.hazelcast.config.TopicConfig) Config(com.hazelcast.config.Config) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) DataPersistenceConfig(com.hazelcast.config.DataPersistenceConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) MapPartitionLostListenerConfig(com.hazelcast.config.MapPartitionLostListenerConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig) MerkleTreeConfig(com.hazelcast.config.MerkleTreeConfig) MemoryTierConfig(com.hazelcast.config.MemoryTierConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) Test(org.junit.Test)

Example 13 with CachePartitionLostListenerConfig

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

the class DynamicConfigTest method testCacheConfig_withPartitionLostListenerByImplementation.

@Test
public void testCacheConfig_withPartitionLostListenerByImplementation() {
    CacheSimpleConfig config = getCacheConfig().addCachePartitionLostListenerConfig(new CachePartitionLostListenerConfig(new SampleCachePartitionLostListener()));
    driver.getConfig().addCacheConfig(config);
    assertConfigurationsEqualOnAllMembers(config);
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 14 with CachePartitionLostListenerConfig

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

the class DynamicConfigTest method testCacheConfig_withPartitionLostListenerByClassName.

@Test
public void testCacheConfig_withPartitionLostListenerByClassName() {
    CacheSimpleConfig config = getCacheConfig().addCachePartitionLostListenerConfig(new CachePartitionLostListenerConfig("partitionLostListener"));
    driver.getConfig().addCacheConfig(config);
    assertConfigurationsEqualOnAllMembers(config);
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 15 with CachePartitionLostListenerConfig

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

the class CachePartitionLostListenerConfigTest method testGetImplementation.

@Test
public void testGetImplementation() {
    CachePartitionLostListener listener = new EventCollectingCachePartitionLostListener(0);
    CachePartitionLostListenerConfig listenerConfig = new CachePartitionLostListenerConfig(listener);
    assertEquals(listener, listenerConfig.getImplementation());
}
Also used : EventCollectingCachePartitionLostListener(com.hazelcast.cache.CachePartitionLostListenerTest.EventCollectingCachePartitionLostListener) CachePartitionLostListener(com.hazelcast.cache.impl.event.CachePartitionLostListener) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) EventCollectingCachePartitionLostListener(com.hazelcast.cache.CachePartitionLostListenerTest.EventCollectingCachePartitionLostListener) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

CachePartitionLostListenerConfig (com.hazelcast.config.CachePartitionLostListenerConfig)20 Test (org.junit.Test)14 QuickTest (com.hazelcast.test.annotation.QuickTest)12 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)9 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)9 CachePartitionLostListener (com.hazelcast.cache.impl.event.CachePartitionLostListener)6 EventCollectingCachePartitionLostListener (com.hazelcast.cache.CachePartitionLostListenerTest.EventCollectingCachePartitionLostListener)5 Config (com.hazelcast.config.Config)5 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)4 EvictionConfig (com.hazelcast.config.EvictionConfig)4 ItemListenerConfig (com.hazelcast.config.ItemListenerConfig)4 ListenerConfig (com.hazelcast.config.ListenerConfig)4 MapPartitionLostListenerConfig (com.hazelcast.config.MapPartitionLostListenerConfig)4 MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)4 AttributeConfig (com.hazelcast.config.AttributeConfig)3 AwsConfig (com.hazelcast.config.AwsConfig)3 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)3 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)3 DataPersistenceConfig (com.hazelcast.config.DataPersistenceConfig)3 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)3