Search in sources :

Example 1 with IcmpFailureDetectorConfig

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

the class ClusterHeartbeatManager method createIcmpFailureDetectorIfNeeded.

private PingFailureDetector createIcmpFailureDetectorIfNeeded() {
    IcmpFailureDetectorConfig icmpFailureDetectorConfig = getActiveMemberNetworkConfig(node.config).getIcmpFailureDetectorConfig();
    boolean icmpEchoFailFast = icmpFailureDetectorConfig == null || icmpFailureDetectorConfig.isFailFastOnStartup();
    if (icmpParallelMode) {
        if (icmpEchoFailFast) {
            logger.info("Checking that ICMP failure-detector is permitted. Attempting to create a raw-socket using JNI.");
            if (!ICMPHelper.isRawSocketPermitted()) {
                throw new IllegalStateException("ICMP failure-detector can't be used in this environment. " + "Check Hazelcast Documentation Chapter on the Ping Failure Detector for supported platforms " + "and how to enable this capability for your operating system");
            }
            logger.info("ICMP failure-detector is supported, enabling.");
        }
        return new PingFailureDetector(icmpMaxAttempts);
    }
    return null;
}
Also used : IcmpFailureDetectorConfig(com.hazelcast.config.IcmpFailureDetectorConfig) PingFailureDetector(com.hazelcast.internal.cluster.fd.PingFailureDetector)

Example 2 with IcmpFailureDetectorConfig

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

the class AbstractPingAwareSplitBrainProtectionFunction method setHazelcastInstance.

@Override
public void setHazelcastInstance(HazelcastInstance hazelcastInstance) {
    Config config = hazelcastInstance.getConfig();
    IcmpFailureDetectorConfig icmpFailureDetectorConfig = getActiveMemberNetworkConfig(config).getIcmpFailureDetectorConfig();
    boolean icmpEnabled = icmpFailureDetectorConfig != null && icmpFailureDetectorConfig.isEnabled();
    boolean icmpParallelMode = icmpEnabled && icmpFailureDetectorConfig.isParallelMode();
    // only take into account ping information if ICMP parallel mode is enabled
    if (!icmpEnabled || !icmpParallelMode) {
        return;
    }
    int icmpMaxAttempts = icmpFailureDetectorConfig.getMaxAttempts();
    this.pingFailureDetector = new PingFailureDetector<>(icmpMaxAttempts);
    this.pingFDEnabled = true;
}
Also used : IcmpFailureDetectorConfig(com.hazelcast.config.IcmpFailureDetectorConfig) Config(com.hazelcast.config.Config) ConfigAccessor.getActiveMemberNetworkConfig(com.hazelcast.config.ConfigAccessor.getActiveMemberNetworkConfig) IcmpFailureDetectorConfig(com.hazelcast.config.IcmpFailureDetectorConfig)

Example 3 with IcmpFailureDetectorConfig

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

the class TestFullApplicationContext method testNetworkConfig.

@Test
public void testNetworkConfig() {
    NetworkConfig networkConfig = config.getNetworkConfig();
    assertNotNull(networkConfig);
    assertEquals(5700, networkConfig.getPort());
    assertTrue(networkConfig.isPortAutoIncrement());
    Collection<String> allowedPorts = networkConfig.getOutboundPortDefinitions();
    assertEquals(2, allowedPorts.size());
    Iterator portIter = allowedPorts.iterator();
    assertEquals("35000-35100", portIter.next());
    assertEquals("36000,36100", portIter.next());
    assertFalse(networkConfig.getJoin().getAutoDetectionConfig().isEnabled());
    assertFalse(networkConfig.getJoin().getMulticastConfig().isEnabled());
    assertEquals(networkConfig.getJoin().getMulticastConfig().getMulticastTimeoutSeconds(), 8);
    assertEquals(networkConfig.getJoin().getMulticastConfig().getMulticastTimeToLive(), 16);
    assertEquals(Boolean.FALSE, networkConfig.getJoin().getMulticastConfig().getLoopbackModeEnabled());
    Set<String> tis = networkConfig.getJoin().getMulticastConfig().getTrustedInterfaces();
    assertEquals(1, tis.size());
    assertEquals("10.10.10.*", tis.iterator().next());
    assertFalse(networkConfig.getInterfaces().isEnabled());
    assertEquals(1, networkConfig.getInterfaces().getInterfaces().size());
    assertEquals("10.10.1.*", networkConfig.getInterfaces().getInterfaces().iterator().next());
    TcpIpConfig tcp = networkConfig.getJoin().getTcpIpConfig();
    assertNotNull(tcp);
    assertFalse(tcp.isEnabled());
    SymmetricEncryptionConfig symmetricEncryptionConfig = networkConfig.getSymmetricEncryptionConfig();
    assertFalse(symmetricEncryptionConfig.isEnabled());
    assertEquals("PBEWithMD5AndDES", symmetricEncryptionConfig.getAlgorithm());
    assertEquals("thesalt", symmetricEncryptionConfig.getSalt());
    assertEquals("thepass", symmetricEncryptionConfig.getPassword());
    assertEquals(19, symmetricEncryptionConfig.getIterationCount());
    List<String> members = tcp.getMembers();
    assertEquals(members.toString(), 2, members.size());
    assertEquals("127.0.0.1:5700", members.get(0));
    assertEquals("127.0.0.1:5701", members.get(1));
    assertEquals("127.0.0.1:5700", tcp.getRequiredMember());
    assertAwsConfig(networkConfig.getJoin().getAwsConfig());
    assertGcpConfig(networkConfig.getJoin().getGcpConfig());
    assertAzureConfig(networkConfig.getJoin().getAzureConfig());
    assertKubernetesConfig(networkConfig.getJoin().getKubernetesConfig());
    assertEurekaConfig(networkConfig.getJoin().getEurekaConfig());
    assertTrue("reuse-address", networkConfig.isReuseAddress());
    MemberAddressProviderConfig memberAddressProviderConfig = networkConfig.getMemberAddressProviderConfig();
    assertFalse(memberAddressProviderConfig.isEnabled());
    assertEquals("com.hazelcast.spring.DummyMemberAddressProvider", memberAddressProviderConfig.getClassName());
    assertFalse(memberAddressProviderConfig.getProperties().isEmpty());
    assertEquals("value", memberAddressProviderConfig.getProperties().getProperty("dummy.property"));
    assertEquals("value2", memberAddressProviderConfig.getProperties().getProperty("dummy.property.2"));
    IcmpFailureDetectorConfig icmpFailureDetectorConfig = networkConfig.getIcmpFailureDetectorConfig();
    assertFalse(icmpFailureDetectorConfig.isEnabled());
    assertTrue(icmpFailureDetectorConfig.isParallelMode());
    assertTrue(icmpFailureDetectorConfig.isFailFastOnStartup());
    assertEquals(500, icmpFailureDetectorConfig.getTimeoutMilliseconds());
    assertEquals(1002, icmpFailureDetectorConfig.getIntervalMilliseconds());
    assertEquals(2, icmpFailureDetectorConfig.getMaxAttempts());
    assertEquals(1, icmpFailureDetectorConfig.getTtl());
}
Also used : MemberAddressProviderConfig(com.hazelcast.config.MemberAddressProviderConfig) IcmpFailureDetectorConfig(com.hazelcast.config.IcmpFailureDetectorConfig) NetworkConfig(com.hazelcast.config.NetworkConfig) Iterator(java.util.Iterator) TcpIpConfig(com.hazelcast.config.TcpIpConfig) SymmetricEncryptionConfig(com.hazelcast.config.SymmetricEncryptionConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 4 with IcmpFailureDetectorConfig

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

the class MemberDomConfigProcessor method handleFailureDetector.

@SuppressWarnings("checkstyle:npathcomplexity")
private void handleFailureDetector(Node node, boolean advancedNetworkConfig) {
    if (!node.hasChildNodes()) {
        return;
    }
    for (Node child : childElements(node)) {
        // icmp only
        if (!matches(cleanNodeName(child), "icmp")) {
            throw new IllegalStateException("Unsupported child under failure-detector");
        }
        Node enabledNode = getNamedItemNode(child, "enabled");
        boolean enabled = enabledNode != null && getBooleanValue(getTextContent(enabledNode));
        IcmpFailureDetectorConfig icmpFailureDetectorConfig = new IcmpFailureDetectorConfig();
        icmpFailureDetectorConfig.setEnabled(enabled);
        for (Node n : childElements(child)) {
            String nodeName = cleanNodeName(n);
            if (matches(nodeName, "ttl")) {
                int ttl = parseInt(getTextContent(n));
                icmpFailureDetectorConfig.setTtl(ttl);
            } else if (matches(nodeName, "timeout-milliseconds")) {
                int timeout = parseInt(getTextContent(n));
                icmpFailureDetectorConfig.setTimeoutMilliseconds(timeout);
            } else if (matches(nodeName, "parallel-mode")) {
                boolean mode = parseBoolean(getTextContent(n));
                icmpFailureDetectorConfig.setParallelMode(mode);
            } else if (matches(nodeName, "fail-fast-on-startup")) {
                boolean failOnStartup = parseBoolean(getTextContent(n));
                icmpFailureDetectorConfig.setFailFastOnStartup(failOnStartup);
            } else if (matches(nodeName, "max-attempts")) {
                int attempts = parseInt(getTextContent(n));
                icmpFailureDetectorConfig.setMaxAttempts(attempts);
            } else if (matches(nodeName, "interval-milliseconds")) {
                int interval = parseInt(getTextContent(n));
                icmpFailureDetectorConfig.setIntervalMilliseconds(interval);
            }
        }
        if (advancedNetworkConfig) {
            config.getAdvancedNetworkConfig().setIcmpFailureDetectorConfig(icmpFailureDetectorConfig);
        } else {
            config.getNetworkConfig().setIcmpFailureDetectorConfig(icmpFailureDetectorConfig);
        }
    }
}
Also used : IcmpFailureDetectorConfig(com.hazelcast.config.IcmpFailureDetectorConfig) Node(org.w3c.dom.Node)

Example 5 with IcmpFailureDetectorConfig

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

the class AbstractSplitBrainProtectionFunctionTest method getIcmpFDEnabledConfig.

protected Config getIcmpFDEnabledConfig() {
    Config config = new Config();
    IcmpFailureDetectorConfig icmpFDConfig = new IcmpFailureDetectorConfig();
    icmpFDConfig.setEnabled(true).setFailFastOnStartup(false).setIntervalMilliseconds(1000).setMaxAttempts(3).setParallelMode(true);
    config.getNetworkConfig().setIcmpFailureDetectorConfig(icmpFDConfig);
    return config;
}
Also used : IcmpFailureDetectorConfig(com.hazelcast.config.IcmpFailureDetectorConfig) IcmpFailureDetectorConfig(com.hazelcast.config.IcmpFailureDetectorConfig) Config(com.hazelcast.config.Config)

Aggregations

IcmpFailureDetectorConfig (com.hazelcast.config.IcmpFailureDetectorConfig)5 Config (com.hazelcast.config.Config)2 ConfigAccessor.getActiveMemberNetworkConfig (com.hazelcast.config.ConfigAccessor.getActiveMemberNetworkConfig)1 MemberAddressProviderConfig (com.hazelcast.config.MemberAddressProviderConfig)1 NetworkConfig (com.hazelcast.config.NetworkConfig)1 SymmetricEncryptionConfig (com.hazelcast.config.SymmetricEncryptionConfig)1 TcpIpConfig (com.hazelcast.config.TcpIpConfig)1 PingFailureDetector (com.hazelcast.internal.cluster.fd.PingFailureDetector)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Iterator (java.util.Iterator)1 Test (org.junit.Test)1 Node (org.w3c.dom.Node)1