Search in sources :

Example 6 with WanCustomPublisherConfig

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

the class AbstractDynamicConfigGeneratorTest method testWanConfig.

// WAN REPLICATION
@Test
public void testWanConfig() {
    @SuppressWarnings("rawtypes") HashMap<String, Comparable> props = new HashMap<>();
    props.put("prop1", "val1");
    props.put("prop2", "val2");
    props.put("prop3", "val3");
    WanReplicationConfig wanReplicationConfig = new WanReplicationConfig().setName("testName").setConsumerConfig(new WanConsumerConfig().setClassName("dummyClass").setProperties(props));
    WanBatchPublisherConfig batchPublisher = new WanBatchPublisherConfig().setClusterName("dummyGroup").setPublisherId("dummyPublisherId").setSnapshotEnabled(false).setInitialPublisherState(WanPublisherState.STOPPED).setQueueCapacity(1000).setBatchSize(500).setBatchMaxDelayMillis(1000).setResponseTimeoutMillis(60000).setQueueFullBehavior(WanQueueFullBehavior.DISCARD_AFTER_MUTATION).setAcknowledgeType(WanAcknowledgeType.ACK_ON_OPERATION_COMPLETE).setDiscoveryPeriodSeconds(20).setMaxTargetEndpoints(100).setMaxConcurrentInvocations(500).setUseEndpointPrivateAddress(true).setIdleMinParkNs(100).setIdleMaxParkNs(1000).setTargetEndpoints("a,b,c,d").setAwsConfig(getDummyAwsConfig()).setDiscoveryConfig(getDummyDiscoveryConfig()).setEndpoint("WAN").setProperties(props);
    batchPublisher.getSyncConfig().setConsistencyCheckStrategy(ConsistencyCheckStrategy.MERKLE_TREES);
    WanCustomPublisherConfig customPublisher = new WanCustomPublisherConfig().setPublisherId("dummyPublisherId").setClassName("className").setProperties(props);
    WanConsumerConfig wanConsumerConfig = new WanConsumerConfig().setClassName("dummyClass").setProperties(props).setPersistWanReplicatedData(false);
    wanReplicationConfig.setConsumerConfig(wanConsumerConfig).addBatchReplicationPublisherConfig(batchPublisher).addCustomPublisherConfig(customPublisher);
    Config config = new Config().addWanReplicationConfig(wanReplicationConfig);
    Config decConfig = getNewConfigViaGenerator(config);
    ConfigCompatibilityChecker.checkWanConfigs(config.getWanReplicationConfigs(), decConfig.getWanReplicationConfigs());
}
Also used : WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) HashMap(java.util.HashMap) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) 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) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) Test(org.junit.Test)

Example 7 with WanCustomPublisherConfig

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

the class WanReplicationConfigDTOTest method testSerialization.

@Test
public void testSerialization() {
    WanReplicationConfig expected = new WanReplicationConfig().setName("myName").setConsumerConfig(new WanConsumerConfig()).addBatchReplicationPublisherConfig(new WanBatchPublisherConfig().setClusterName("group1")).addCustomPublisherConfig(new WanCustomPublisherConfig().setPublisherId("group2").setClassName("className"));
    WanReplicationConfig actual = cloneThroughJson(expected);
    assertTrue("Expected: " + expected + ", got:" + actual, WAN_REPLICATION_CONFIG_CHECKER.check(expected, actual));
}
Also used : WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with WanCustomPublisherConfig

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

the class WanReplicationServiceImpl method createPublishers.

private ConcurrentMap<String, WanPublisher> createPublishers(WanReplicationConfig wanReplicationConfig) {
    List<WanCustomPublisherConfig> customPublisherConfigs = wanReplicationConfig.getCustomPublisherConfigs();
    int publisherCount = customPublisherConfigs.size();
    if (publisherCount == 0) {
        return createConcurrentHashMap(1);
    }
    ConcurrentMap<String, WanPublisher> publishers = createConcurrentHashMap(publisherCount);
    Map<String, AbstractWanPublisherConfig> publisherConfigs = createHashMap(publisherCount);
    customPublisherConfigs.forEach(publisherConfig -> {
        String publisherId = getWanPublisherId(publisherConfig);
        if (publishers.containsKey(publisherId)) {
            throw new InvalidConfigurationException("Detected duplicate publisher ID '" + publisherId + "' for a single WAN replication config");
        }
        WanPublisher publisher = createPublisher(publisherConfig);
        publishers.put(publisherId, publisher);
        publisherConfigs.put(publisherId, publisherConfig);
    });
    for (Entry<String, WanPublisher> publisherEntry : publishers.entrySet()) {
        String publisherId = publisherEntry.getKey();
        WanPublisher publisher = publisherEntry.getValue();
        ManagedContext managedContext = node.getSerializationService().getManagedContext();
        publisher = (WanPublisher) managedContext.initialize(publisher);
        publisher.init(wanReplicationConfig, publisherConfigs.get(publisherId));
    }
    return publishers;
}
Also used : WanPublisher(com.hazelcast.wan.WanPublisher) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) AbstractWanPublisherConfig(com.hazelcast.config.AbstractWanPublisherConfig) ManagedContext(com.hazelcast.core.ManagedContext) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 9 with WanCustomPublisherConfig

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

the class ClientMapWANExceptionTest method getWanPublisherConfig.

private WanCustomPublisherConfig getWanPublisherConfig() {
    WanCustomPublisherConfig pc = new WanCustomPublisherConfig();
    pc.setPublisherId("customPublisherId").setClassName(WanFullQueuePublisher.class.getName());
    return pc;
}
Also used : WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) WanFullQueuePublisher(com.hazelcast.wan.impl.WanFullQueuePublisher)

Example 10 with WanCustomPublisherConfig

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

the class TestFullApplicationContext method testWanReplicationConfig.

@Test
public void testWanReplicationConfig() {
    WanReplicationConfig wcfg = config.getWanReplicationConfig("testWan");
    assertNotNull(wcfg);
    WanBatchPublisherConfig pc = wcfg.getBatchPublisherConfigs().get(0);
    assertEquals("tokyo", pc.getClusterName());
    assertEquals("tokyoPublisherId", pc.getPublisherId());
    assertEquals("com.hazelcast.enterprise.wan.impl.replication.WanBatchPublisher", pc.getClassName());
    assertEquals(WanQueueFullBehavior.THROW_EXCEPTION, pc.getQueueFullBehavior());
    assertEquals(WanPublisherState.STOPPED, pc.getInitialPublisherState());
    assertEquals(1000, pc.getQueueCapacity());
    assertEquals(50, pc.getBatchSize());
    assertEquals(3000, pc.getBatchMaxDelayMillis());
    assertTrue(pc.isSnapshotEnabled());
    assertEquals(5000, pc.getResponseTimeoutMillis());
    assertEquals(5, pc.getMaxTargetEndpoints());
    assertEquals(5, pc.getDiscoveryPeriodSeconds());
    assertTrue(pc.isUseEndpointPrivateAddress());
    assertEquals(5, pc.getIdleMinParkNs());
    assertEquals(5, pc.getIdleMaxParkNs());
    assertEquals(5, pc.getMaxConcurrentInvocations());
    assertEquals(WanAcknowledgeType.ACK_ON_RECEIPT, pc.getAcknowledgeType());
    assertEquals(5, pc.getDiscoveryPeriodSeconds());
    assertEquals(5, pc.getMaxTargetEndpoints());
    assertAwsConfig(pc.getAwsConfig());
    assertGcpConfig(pc.getGcpConfig());
    assertAzureConfig(pc.getAzureConfig());
    assertKubernetesConfig(pc.getKubernetesConfig());
    assertEurekaConfig(pc.getEurekaConfig());
    WanCustomPublisherConfig customPublisher = wcfg.getCustomPublisherConfigs().get(0);
    assertEquals("istanbulPublisherId", customPublisher.getPublisherId());
    assertEquals("com.hazelcast.wan.custom.CustomPublisher", customPublisher.getClassName());
    Map<String, Comparable> customPublisherProps = customPublisher.getProperties();
    assertEquals("prop.publisher", customPublisherProps.get("custom.prop.publisher"));
    WanBatchPublisherConfig publisherPlaceHolderConfig = wcfg.getBatchPublisherConfigs().get(1);
    assertEquals(5000, publisherPlaceHolderConfig.getQueueCapacity());
    WanConsumerConfig consumerConfig = wcfg.getConsumerConfig();
    assertEquals("com.hazelcast.wan.custom.WanConsumer", consumerConfig.getClassName());
    Map<String, Comparable> consumerProps = consumerConfig.getProperties();
    assertEquals("prop.consumer", consumerProps.get("custom.prop.consumer"));
    assertTrue(consumerConfig.isPersistWanReplicatedData());
}
Also used : WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Aggregations

WanCustomPublisherConfig (com.hazelcast.config.WanCustomPublisherConfig)17 WanBatchPublisherConfig (com.hazelcast.config.WanBatchPublisherConfig)8 WanReplicationConfig (com.hazelcast.config.WanReplicationConfig)7 WanConsumerConfig (com.hazelcast.config.WanConsumerConfig)6 Test (org.junit.Test)6 MapConfig (com.hazelcast.config.MapConfig)4 QuickTest (com.hazelcast.test.annotation.QuickTest)3 AttributeConfig (com.hazelcast.config.AttributeConfig)2 AwsConfig (com.hazelcast.config.AwsConfig)2 CachePartitionLostListenerConfig (com.hazelcast.config.CachePartitionLostListenerConfig)2 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)2 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)2 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)2 Config (com.hazelcast.config.Config)2 DataPersistenceConfig (com.hazelcast.config.DataPersistenceConfig)2 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)2 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)2 DiskTierConfig (com.hazelcast.config.DiskTierConfig)2 DurableExecutorConfig (com.hazelcast.config.DurableExecutorConfig)2 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)2