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());
}
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));
}
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;
}
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;
}
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());
}
Aggregations