Search in sources :

Example 1 with SplitBrainProtectionConfigBuilder

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

the class MemberDomConfigProcessor method handleProbabilisticSplitBrainProtection.

private SplitBrainProtectionConfigBuilder handleProbabilisticSplitBrainProtection(String name, Node node, int splitBrainProtectionSize) {
    SplitBrainProtectionConfigBuilder splitBrainProtectionConfigBuilder;
    long acceptableHeartPause = getLongValue("acceptable-heartbeat-pause-millis", getAttribute(node, "acceptable-heartbeat-pause-millis"), ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_HEARTBEAT_PAUSE_MILLIS);
    double threshold = getDoubleValue("suspicion-threshold", getAttribute(node, "suspicion-threshold"), ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_PHI_THRESHOLD);
    int maxSampleSize = getIntegerValue("max-sample-size", getAttribute(node, "max-sample-size"), ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_SAMPLE_SIZE);
    long minStdDeviation = getLongValue("min-std-deviation-millis", getAttribute(node, "min-std-deviation-millis"), ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_MIN_STD_DEVIATION);
    long heartbeatIntervalMillis = getLongValue("heartbeat-interval-millis", getAttribute(node, "heartbeat-interval-millis"), ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_HEARTBEAT_INTERVAL_MILLIS);
    splitBrainProtectionConfigBuilder = SplitBrainProtectionConfig.newProbabilisticSplitBrainProtectionConfigBuilder(name, splitBrainProtectionSize).withAcceptableHeartbeatPauseMillis(acceptableHeartPause).withSuspicionThreshold(threshold).withHeartbeatIntervalMillis(heartbeatIntervalMillis).withMinStdDeviationMillis(minStdDeviation).withMaxSampleSize(maxSampleSize);
    return splitBrainProtectionConfigBuilder;
}
Also used : SplitBrainProtectionConfigBuilder(com.hazelcast.config.SplitBrainProtectionConfigBuilder) RecentlyActiveSplitBrainProtectionConfigBuilder(com.hazelcast.config.RecentlyActiveSplitBrainProtectionConfigBuilder) ProbabilisticSplitBrainProtectionConfigBuilder(com.hazelcast.config.ProbabilisticSplitBrainProtectionConfigBuilder)

Example 2 with SplitBrainProtectionConfigBuilder

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

the class MemberDomConfigProcessor method handleRecentlyActiveSplitBrainProtection.

private SplitBrainProtectionConfigBuilder handleRecentlyActiveSplitBrainProtection(String name, Node node, int splitBrainProtectionSize) {
    SplitBrainProtectionConfigBuilder splitBrainProtectionConfigBuilder;
    int heartbeatToleranceMillis = getIntegerValue("heartbeat-tolerance-millis", getAttribute(node, "heartbeat-tolerance-millis"), RecentlyActiveSplitBrainProtectionConfigBuilder.DEFAULT_HEARTBEAT_TOLERANCE_MILLIS);
    splitBrainProtectionConfigBuilder = SplitBrainProtectionConfig.newRecentlyActiveSplitBrainProtectionConfigBuilder(name, splitBrainProtectionSize, heartbeatToleranceMillis);
    return splitBrainProtectionConfigBuilder;
}
Also used : SplitBrainProtectionConfigBuilder(com.hazelcast.config.SplitBrainProtectionConfigBuilder) RecentlyActiveSplitBrainProtectionConfigBuilder(com.hazelcast.config.RecentlyActiveSplitBrainProtectionConfigBuilder) ProbabilisticSplitBrainProtectionConfigBuilder(com.hazelcast.config.ProbabilisticSplitBrainProtectionConfigBuilder)

Example 3 with SplitBrainProtectionConfigBuilder

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

the class MemberDomConfigProcessor method handleSplitBrainProtectionNode.

protected void handleSplitBrainProtectionNode(Node node, SplitBrainProtectionConfig splitBrainProtectionConfig, String name) {
    Node attrEnabled = getNamedItemNode(node, "enabled");
    boolean enabled = attrEnabled != null && getBooleanValue(getTextContent(attrEnabled));
    // probabilistic-split-brain-protection and recently-active-split-brain-protection
    // configs are constructed via SplitBrainProtectionConfigBuilder
    SplitBrainProtectionConfigBuilder splitBrainProtectionConfigBuilder = null;
    splitBrainProtectionConfig.setEnabled(enabled);
    for (Node n : childElements(node)) {
        String nodeName = cleanNodeName(n);
        if (matches("minimum-cluster-size", nodeName)) {
            splitBrainProtectionConfig.setMinimumClusterSize(getIntegerValue("minimum-cluster-size", getTextContent(n)));
        } else if (matches("listeners", nodeName)) {
            handleSplitBrainProtectionListeners(splitBrainProtectionConfig, n);
        } else if (matches("protect-on", nodeName)) {
            splitBrainProtectionConfig.setProtectOn(SplitBrainProtectionOn.valueOf(upperCaseInternal(getTextContent(n))));
        } else if (matches("function-class-name", nodeName)) {
            splitBrainProtectionConfig.setFunctionClassName(getTextContent(n));
        } else if (matches("recently-active-split-brain-protection", nodeName)) {
            splitBrainProtectionConfigBuilder = handleRecentlyActiveSplitBrainProtection(name, n, splitBrainProtectionConfig.getMinimumClusterSize());
        } else if (matches("probabilistic-split-brain-protection", nodeName)) {
            splitBrainProtectionConfigBuilder = handleProbabilisticSplitBrainProtection(name, n, splitBrainProtectionConfig.getMinimumClusterSize());
        }
    }
    if (splitBrainProtectionConfigBuilder != null) {
        boolean splitBrainProtectionFunctionDefinedByClassName = !isNullOrEmpty(splitBrainProtectionConfig.getFunctionClassName());
        if (splitBrainProtectionFunctionDefinedByClassName) {
            throw new InvalidConfigurationException("A split brain protection cannot simultaneously" + " define probabilistic-split-brain-protectionm or " + "recently-active-split-brain-protection and a split brain protection function class name.");
        }
        // ensure parsed attributes are reflected in constructed split brain protection config
        SplitBrainProtectionConfig constructedConfig = splitBrainProtectionConfigBuilder.build();
        constructedConfig.setMinimumClusterSize(splitBrainProtectionConfig.getMinimumClusterSize());
        constructedConfig.setProtectOn(splitBrainProtectionConfig.getProtectOn());
        constructedConfig.setListenerConfigs(splitBrainProtectionConfig.getListenerConfigs());
        splitBrainProtectionConfig = constructedConfig;
    }
    config.addSplitBrainProtectionConfig(splitBrainProtectionConfig);
}
Also used : Node(org.w3c.dom.Node) SplitBrainProtectionConfigBuilder(com.hazelcast.config.SplitBrainProtectionConfigBuilder) RecentlyActiveSplitBrainProtectionConfigBuilder(com.hazelcast.config.RecentlyActiveSplitBrainProtectionConfigBuilder) ProbabilisticSplitBrainProtectionConfigBuilder(com.hazelcast.config.ProbabilisticSplitBrainProtectionConfigBuilder) SplitBrainProtectionConfig(com.hazelcast.config.SplitBrainProtectionConfig) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Aggregations

ProbabilisticSplitBrainProtectionConfigBuilder (com.hazelcast.config.ProbabilisticSplitBrainProtectionConfigBuilder)3 RecentlyActiveSplitBrainProtectionConfigBuilder (com.hazelcast.config.RecentlyActiveSplitBrainProtectionConfigBuilder)3 SplitBrainProtectionConfigBuilder (com.hazelcast.config.SplitBrainProtectionConfigBuilder)3 InvalidConfigurationException (com.hazelcast.config.InvalidConfigurationException)1 SplitBrainProtectionConfig (com.hazelcast.config.SplitBrainProtectionConfig)1 Node (org.w3c.dom.Node)1