use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method handleRestEndpointGroup.
private void handleRestEndpointGroup(RestServerEndpointConfig config, Node node) {
boolean enabled = getBooleanValue(getAttribute(node, "enabled"));
String name = extractName(node);
RestEndpointGroup endpointGroup;
try {
endpointGroup = RestEndpointGroup.valueOf(name);
} catch (IllegalArgumentException e) {
throw new InvalidConfigurationException("Wrong name attribute value was provided in endpoint-group element: " + name + "\nAllowed values: " + Arrays.toString(RestEndpointGroup.values()));
}
if (enabled) {
config.enableGroups(endpointGroup);
} else {
config.disableGroups(endpointGroup);
}
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method handleSecureStore.
private void handleSecureStore(Node secureStoreRoot, EncryptionAtRestConfig encryptionAtRestConfig) {
Node n = firstChildElement(secureStoreRoot);
if (n != null) {
String name = cleanNodeName(n);
SecureStoreConfig secureStoreConfig;
if (matches("keystore", name)) {
secureStoreConfig = handleJavaKeyStore(n);
} else if (matches("vault", name)) {
secureStoreConfig = handleVault(n);
} else {
throw new InvalidConfigurationException("Unrecognized Secure Store type: " + name);
}
encryptionAtRestConfig.setSecureStoreConfig(secureStoreConfig);
}
}
use of com.hazelcast.config.InvalidConfigurationException 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);
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class ConfigValidator method checkEvictionConfig.
/**
* Checks if a {@link EvictionConfig} is valid in its context.
*
* @param evictionConfig the {@link EvictionConfig}
*/
public static void checkEvictionConfig(EvictionConfig evictionConfig, EnumSet<EvictionPolicy> supportedEvictionPolicies) {
if (evictionConfig == null) {
throw new InvalidConfigurationException("Eviction config cannot be null!");
}
EvictionPolicy evictionPolicy = evictionConfig.getEvictionPolicy();
String comparatorClassName = evictionConfig.getComparatorClassName();
EvictionPolicyComparator comparator = evictionConfig.getComparator();
checkEvictionConfig(evictionPolicy, comparatorClassName, comparator, supportedEvictionPolicies);
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class YamlMemberDomConfigProcessor method queryCachePredicateHandler.
@Override
protected void queryCachePredicateHandler(Node childNode, QueryCacheConfig queryCacheConfig) {
Node classNameNode = getNamedItemNode(childNode, "class-name");
Node sqlNode = getNamedItemNode(childNode, "sql");
if (classNameNode != null && sqlNode != null) {
throw new InvalidConfigurationException("Both class-name and sql is defined for the predicate of map " + childNode.getParentNode().getParentNode().getNodeName());
}
if (classNameNode == null && sqlNode == null) {
throw new InvalidConfigurationException("Either class-name and sql must be defined for the predicate of map " + childNode.getParentNode().getParentNode().getNodeName());
}
PredicateConfig predicateConfig = new PredicateConfig();
if (classNameNode != null) {
predicateConfig.setClassName(getTextContent(classNameNode));
} else if (sqlNode != null) {
predicateConfig.setSql(getTextContent(sqlNode));
}
queryCacheConfig.setPredicateConfig(predicateConfig);
}
Aggregations