Search in sources :

Example 1 with WanBatchPublisherConfig

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());
}
Also used : WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) AdvancedNetworkConfig(com.hazelcast.config.AdvancedNetworkConfig) MemberAddressProviderConfig(com.hazelcast.config.MemberAddressProviderConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) Config(com.hazelcast.config.Config) EndpointConfig(com.hazelcast.config.EndpointConfig) ServerSocketEndpointConfig(com.hazelcast.config.ServerSocketEndpointConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) RestServerEndpointConfig(com.hazelcast.config.RestServerEndpointConfig) AdvancedNetworkConfig(com.hazelcast.config.AdvancedNetworkConfig) MemberAddressProviderConfig(com.hazelcast.config.MemberAddressProviderConfig) ServerSocketEndpointConfig(com.hazelcast.config.ServerSocketEndpointConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) RestServerEndpointConfig(com.hazelcast.config.RestServerEndpointConfig) EndpointConfig(com.hazelcast.config.EndpointConfig) ServerSocketEndpointConfig(com.hazelcast.config.ServerSocketEndpointConfig) RestServerEndpointConfig(com.hazelcast.config.RestServerEndpointConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with WanBatchPublisherConfig

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());
}
Also used : WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) WanSyncConfig(com.hazelcast.config.WanSyncConfig) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) HashMap(java.util.HashMap) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 3 with WanBatchPublisherConfig

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();
    }
}
Also used : WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig)

Example 4 with WanBatchPublisherConfig

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;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 5 with WanBatchPublisherConfig

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()));
                }
            }
        }
    }
}
Also used : WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) ProtocolType(com.hazelcast.instance.ProtocolType) MutableInteger(com.hazelcast.internal.util.MutableInteger) EndpointQualifier(com.hazelcast.instance.EndpointQualifier) ServerSocketEndpointConfig(com.hazelcast.config.ServerSocketEndpointConfig) EnumMap(java.util.EnumMap) EndpointConfig(com.hazelcast.config.EndpointConfig) ServerSocketEndpointConfig(com.hazelcast.config.ServerSocketEndpointConfig) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Aggregations

WanBatchPublisherConfig (com.hazelcast.config.WanBatchPublisherConfig)18 WanReplicationConfig (com.hazelcast.config.WanReplicationConfig)11 WanCustomPublisherConfig (com.hazelcast.config.WanCustomPublisherConfig)8 Test (org.junit.Test)8 WanConsumerConfig (com.hazelcast.config.WanConsumerConfig)7 QuickTest (com.hazelcast.test.annotation.QuickTest)7 AwsConfig (com.hazelcast.config.AwsConfig)4 WanSyncConfig (com.hazelcast.config.WanSyncConfig)4 AzureConfig (com.hazelcast.config.AzureConfig)3 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)3 EurekaConfig (com.hazelcast.config.EurekaConfig)3 GcpConfig (com.hazelcast.config.GcpConfig)3 KubernetesConfig (com.hazelcast.config.KubernetesConfig)3 HashMap (java.util.HashMap)3 AttributeConfig (com.hazelcast.config.AttributeConfig)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