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