use of com.hazelcast.config.WanBatchPublisherConfig in project hazelcast by hazelcast.
the class TestAdvancedNetworkApplicationContext method testAdvancedNetworkConfig.
@Test
public void testAdvancedNetworkConfig() {
Config config = instance.getConfig();
AdvancedNetworkConfig advancedNetworkConfig = config.getAdvancedNetworkConfig();
assertTrue(advancedNetworkConfig.isEnabled());
TcpIpConfig tcpIpConfig = advancedNetworkConfig.getJoin().getTcpIpConfig();
assertTrue(tcpIpConfig.isEnabled());
assertEquals("127.0.0.1:5700", tcpIpConfig.getRequiredMember());
assertFalse(advancedNetworkConfig.getJoin().getMulticastConfig().isEnabled());
assertFalse(advancedNetworkConfig.getJoin().getAutoDetectionConfig().isEnabled());
MemberAddressProviderConfig addressProviderConfig = advancedNetworkConfig.getMemberAddressProviderConfig();
assertFalse(addressProviderConfig.isEnabled());
ServerSocketEndpointConfig memberEndpointConfig = (ServerSocketEndpointConfig) advancedNetworkConfig.getEndpointConfigs().get(EndpointQualifier.MEMBER);
assertEquals(5700, memberEndpointConfig.getPort());
assertEquals(99, memberEndpointConfig.getPortCount());
assertFalse(memberEndpointConfig.isPortAutoIncrement());
assertTrue(memberEndpointConfig.getInterfaces().isEnabled());
assertContains(memberEndpointConfig.getInterfaces().getInterfaces(), "127.0.0.1");
assertTrue(memberEndpointConfig.isReuseAddress());
assertTrue(memberEndpointConfig.getSocketInterceptorConfig().isEnabled());
assertEquals("com.hazelcast.SocketInterceptor", memberEndpointConfig.getSocketInterceptorConfig().getClassName());
assertTrue(memberEndpointConfig.isSocketBufferDirect());
assertTrue(memberEndpointConfig.isSocketKeepAlive());
assertFalse(memberEndpointConfig.isSocketTcpNoDelay());
EndpointConfig wanConfig = advancedNetworkConfig.getEndpointConfigs().get(EndpointQualifier.resolve(ProtocolType.WAN, "wan-tokyo"));
assertFalse(wanConfig.getInterfaces().isEnabled());
assertTrue(wanConfig.getSymmetricEncryptionConfig().isEnabled());
assertEquals("PBEWithMD5AndDES", wanConfig.getSymmetricEncryptionConfig().getAlgorithm());
assertEquals("thesalt", wanConfig.getSymmetricEncryptionConfig().getSalt());
assertEquals("thepass", wanConfig.getSymmetricEncryptionConfig().getPassword());
assertEquals(19, wanConfig.getSymmetricEncryptionConfig().getIterationCount());
ServerSocketEndpointConfig clientEndpointConfig = (ServerSocketEndpointConfig) advancedNetworkConfig.getEndpointConfigs().get(EndpointQualifier.CLIENT);
assertEquals(9919, clientEndpointConfig.getPort());
assertEquals(10, clientEndpointConfig.getPortCount());
assertFalse(clientEndpointConfig.isPortAutoIncrement());
assertTrue(clientEndpointConfig.isReuseAddress());
RestServerEndpointConfig restServerEndpointConfig = advancedNetworkConfig.getRestEndpointConfig();
assertEquals(9999, restServerEndpointConfig.getPort());
assertTrue(restServerEndpointConfig.isPortAutoIncrement());
assertContainsAll(restServerEndpointConfig.getEnabledGroups(), Arrays.asList(HEALTH_CHECK, CLUSTER_READ));
WanReplicationConfig testWan = config.getWanReplicationConfig("testWan");
WanBatchPublisherConfig tokyoWanPublisherConfig = testWan.getBatchPublisherConfigs().stream().filter(pc -> pc.getPublisherId().equals("tokyoPublisherId")).findFirst().get();
assertNotNull(tokyoWanPublisherConfig);
assertEquals("wan-tokyo", tokyoWanPublisherConfig.getEndpoint());
}
use of com.hazelcast.config.WanBatchPublisherConfig in project hazelcast by hazelcast.
the class TestFullApplicationContext method testWanReplicationSyncConfig.
@Test
public void testWanReplicationSyncConfig() {
final WanReplicationConfig wcfg = config.getWanReplicationConfig("testWan2");
final WanConsumerConfig consumerConfig = wcfg.getConsumerConfig();
final Map<String, Comparable> consumerProps = new HashMap<>();
consumerProps.put("custom.prop.consumer", "prop.consumer");
consumerConfig.setProperties(consumerProps);
assertInstanceOf(DummyWanConsumer.class, consumerConfig.getImplementation());
assertEquals("prop.consumer", consumerConfig.getProperties().get("custom.prop.consumer"));
assertFalse(consumerConfig.isPersistWanReplicatedData());
final List<WanBatchPublisherConfig> publisherConfigs = wcfg.getBatchPublisherConfigs();
assertNotNull(publisherConfigs);
assertEquals(1, publisherConfigs.size());
final WanBatchPublisherConfig pc = publisherConfigs.get(0);
assertEquals("tokyo", pc.getClusterName());
final WanSyncConfig wanSyncConfig = pc.getSyncConfig();
assertNotNull(wanSyncConfig);
assertEquals(ConsistencyCheckStrategy.MERKLE_TREES, wanSyncConfig.getConsistencyCheckStrategy());
}
use of com.hazelcast.config.WanBatchPublisherConfig in project hazelcast by hazelcast.
the class DynamicConfigXmlGenerator method wanReplicationXmlGenerator.
public static void wanReplicationXmlGenerator(ConfigXmlGenerator.XmlGenerator gen, Config config) {
for (WanReplicationConfig wan : config.getWanReplicationConfigs().values()) {
gen.open("wan-replication", "name", wan.getName());
for (WanBatchPublisherConfig p : wan.getBatchPublisherConfigs()) {
wanBatchReplicationPublisherXmlGenerator(gen, p);
}
for (WanCustomPublisherConfig p : wan.getCustomPublisherConfigs()) {
wanCustomPublisherXmlGenerator(gen, p);
}
WanConsumerConfig consumerConfig = wan.getConsumerConfig();
if (consumerConfig != null) {
wanReplicationConsumerGenerator(gen, consumerConfig);
}
gen.close();
}
}
use of com.hazelcast.config.WanBatchPublisherConfig in project hazelcast by hazelcast.
the class WanReplicationConfigDTO method toJson.
@Override
public JsonObject toJson() {
JsonObject root = new JsonObject();
if (config.getName() != null) {
root.add("name", config.getName());
}
JsonArray batchPublishers = new JsonArray();
JsonArray customPublishers = new JsonArray();
for (WanBatchPublisherConfig publisherConfig : config.getBatchPublisherConfigs()) {
batchPublishers.add(new WanBatchPublisherConfigDTO(publisherConfig).toJson());
}
for (WanCustomPublisherConfig publisherConfig : config.getCustomPublisherConfigs()) {
customPublishers.add(new CustomWanPublisherConfigDTO(publisherConfig).toJson());
}
root.add("batchPublishers", batchPublishers);
root.add("customPublishers", customPublishers);
WanConsumerConfig consumerConfig = config.getConsumerConfig();
if (consumerConfig != null) {
root.add("consumer", new WanConsumerConfigDTO(consumerConfig).toJson());
}
return root;
}
use of com.hazelcast.config.WanBatchPublisherConfig in project hazelcast by hazelcast.
the class ConfigValidator method checkAdvancedNetworkConfig.
@SuppressWarnings({ "checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity", "checkstyle:booleanexpressioncomplexity" })
public static void checkAdvancedNetworkConfig(Config config) {
if (!config.getAdvancedNetworkConfig().isEnabled()) {
return;
}
EnumMap<ProtocolType, MutableInteger> serverSocketsPerProtocolType = new EnumMap<>(ProtocolType.class);
for (ProtocolType protocolType : ProtocolType.values()) {
serverSocketsPerProtocolType.put(protocolType, new MutableInteger());
}
Map<EndpointQualifier, EndpointConfig> endpointConfigs = config.getAdvancedNetworkConfig().getEndpointConfigs();
for (EndpointConfig endpointConfig : endpointConfigs.values()) {
if (endpointConfig instanceof ServerSocketEndpointConfig) {
serverSocketsPerProtocolType.get(endpointConfig.getProtocolType()).getAndInc();
}
}
for (ProtocolType protocolType : ProtocolType.values()) {
int serverSocketCount = serverSocketsPerProtocolType.get(protocolType).value;
if (serverSocketCount > protocolType.getServerSocketCardinality()) {
throw new InvalidConfigurationException(format("Protocol type %s allows definition " + "of up to %d server sockets but %d were configured", protocolType, protocolType.getServerSocketCardinality(), serverSocketCount));
}
}
// ensure there is 1 MEMBER type server socket
if (serverSocketsPerProtocolType.get(MEMBER).value != 1) {
throw new InvalidConfigurationException("A member-server-socket-endpoint" + " configuration is required for the cluster to form.");
}
// endpoint qualifiers referenced by WAN publishers must exist
for (WanReplicationConfig wanReplicationConfig : config.getWanReplicationConfigs().values()) {
for (WanBatchPublisherConfig wanPublisherConfig : wanReplicationConfig.getBatchPublisherConfigs()) {
if (wanPublisherConfig.getEndpoint() != null) {
EndpointQualifier qualifier = EndpointQualifier.resolve(WAN, wanPublisherConfig.getEndpoint());
if (endpointConfigs.get(qualifier) == null) {
throw new InvalidConfigurationException(format("WAN publisher config for cluster name '%s' requires an wan-endpoint " + "config with identifier '%s' but none was found", wanPublisherConfig.getClusterName(), wanPublisherConfig.getEndpoint()));
}
}
}
}
}
Aggregations