Search in sources :

Example 26 with InvalidConfigurationException

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);
    }
}
Also used : RestEndpointGroup(com.hazelcast.config.RestEndpointGroup) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 27 with InvalidConfigurationException

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);
    }
}
Also used : SecureStoreConfig(com.hazelcast.config.SecureStoreConfig) VaultSecureStoreConfig(com.hazelcast.config.VaultSecureStoreConfig) JavaKeyStoreSecureStoreConfig(com.hazelcast.config.JavaKeyStoreSecureStoreConfig) Node(org.w3c.dom.Node) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 28 with InvalidConfigurationException

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

Example 29 with InvalidConfigurationException

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);
}
Also used : EvictionPolicy(com.hazelcast.config.EvictionPolicy) EvictionPolicyComparator(com.hazelcast.spi.eviction.EvictionPolicyComparator) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 30 with InvalidConfigurationException

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);
}
Also used : PredicateConfig(com.hazelcast.config.PredicateConfig) Node(org.w3c.dom.Node) YamlNode(com.hazelcast.internal.yaml.YamlNode) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Aggregations

InvalidConfigurationException (com.hazelcast.config.InvalidConfigurationException)43 Node (org.w3c.dom.Node)19 YamlNode (com.hazelcast.internal.yaml.YamlNode)5 IOException (java.io.IOException)5 EvictionConfig (com.hazelcast.config.EvictionConfig)3 ValidationException (com.hazelcast.config.properties.ValidationException)3 YamlMapping (com.hazelcast.internal.yaml.YamlMapping)3 DiscoveryStrategy (com.hazelcast.spi.discovery.DiscoveryStrategy)3 ClientConfig (com.hazelcast.client.config.ClientConfig)2 XmlClientConfigBuilder (com.hazelcast.client.config.XmlClientConfigBuilder)2 Member (com.hazelcast.cluster.Member)2 EventJournalConfig (com.hazelcast.config.EventJournalConfig)2 EvictionPolicy (com.hazelcast.config.EvictionPolicy)2 MaxSizePolicy (com.hazelcast.config.MaxSizePolicy)2 OnJoinPermissionOperationName (com.hazelcast.config.OnJoinPermissionOperationName)2 PermissionType (com.hazelcast.config.PermissionConfig.PermissionType)2 PredicateConfig (com.hazelcast.config.PredicateConfig)2 WanReplicationConfig (com.hazelcast.config.WanReplicationConfig)2 DefaultDiscoveryService (com.hazelcast.spi.discovery.impl.DefaultDiscoveryService)2 HazelcastProperties (com.hazelcast.spi.properties.HazelcastProperties)2