Search in sources :

Example 16 with InvalidConfigurationException

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

the class MemberDomConfigProcessor method handleSecurityPermissions.

protected void handleSecurityPermissions(Node node) {
    String onJoinOp = getAttribute(node, "on-join-operation");
    if (onJoinOp != null) {
        OnJoinPermissionOperationName onJoinPermissionOperation = OnJoinPermissionOperationName.valueOf(upperCaseInternal(onJoinOp));
        config.getSecurityConfig().setOnJoinPermissionOperation(onJoinPermissionOperation);
    }
    for (Node child : childElements(node)) {
        String nodeName = cleanNodeName(child);
        PermissionType type = PermissionConfig.PermissionType.getType(nodeName);
        if (type == null) {
            throw new InvalidConfigurationException("Security permission type is not valid " + nodeName);
        }
        handleSecurityPermission(child, type);
    }
}
Also used : OnJoinPermissionOperationName(com.hazelcast.config.OnJoinPermissionOperationName) PermissionType(com.hazelcast.config.PermissionConfig.PermissionType) Node(org.w3c.dom.Node) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 17 with InvalidConfigurationException

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

the class MemberDomConfigProcessor method handleServerSocketEndpointConfig.

protected void handleServerSocketEndpointConfig(ServerSocketEndpointConfig endpointConfig, Node node, String name) throws Exception {
    endpointConfig.setName(name);
    for (Node child : childElements(node)) {
        String nodeName = cleanNodeName(child);
        if (matches("port", nodeName)) {
            handlePort(child, endpointConfig);
        } else if (matches("public-address", nodeName)) {
            String address = getTextContent(child);
            endpointConfig.setPublicAddress(address);
        } else if (matches("reuse-address", nodeName)) {
            endpointConfig.setReuseAddress(getBooleanValue(getTextContent(child)));
        } else {
            handleEndpointConfigCommons(child, nodeName, endpointConfig);
        }
    }
    switch(endpointConfig.getProtocolType()) {
        case MEMBER:
            ensureServerSocketEndpointConfig(endpointConfig);
            config.getAdvancedNetworkConfig().setMemberEndpointConfig(endpointConfig);
            break;
        case CLIENT:
            ensureServerSocketEndpointConfig(endpointConfig);
            config.getAdvancedNetworkConfig().setClientEndpointConfig(endpointConfig);
            break;
        case REST:
            ensureServerSocketEndpointConfig(endpointConfig);
            config.getAdvancedNetworkConfig().setRestEndpointConfig((RestServerEndpointConfig) endpointConfig);
            break;
        case WAN:
            config.getAdvancedNetworkConfig().addWanEndpointConfig(endpointConfig);
            break;
        case MEMCACHE:
            config.getAdvancedNetworkConfig().setMemcacheEndpointConfig(endpointConfig);
            break;
        default:
            throw new InvalidConfigurationException("Endpoint config has invalid protocol type " + endpointConfig.getProtocolType());
    }
}
Also used : Node(org.w3c.dom.Node) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 18 with InvalidConfigurationException

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

the class MemberDomConfigProcessor method handleCacheNode.

void handleCacheNode(Node node, CacheSimpleConfig cacheConfig) throws Exception {
    for (Node n : childElements(node)) {
        String nodeName = cleanNodeName(n);
        if (matches("key-type", nodeName)) {
            cacheConfig.setKeyType(getAttribute(n, "class-name"));
        } else if (matches("value-type", nodeName)) {
            cacheConfig.setValueType(getAttribute(n, "class-name"));
        } else if (matches("statistics-enabled", nodeName)) {
            cacheConfig.setStatisticsEnabled(getBooleanValue(getTextContent(n)));
        } else if (matches("management-enabled", nodeName)) {
            cacheConfig.setManagementEnabled(getBooleanValue(getTextContent(n)));
        } else if (matches("read-through", nodeName)) {
            cacheConfig.setReadThrough(getBooleanValue(getTextContent(n)));
        } else if (matches("write-through", nodeName)) {
            cacheConfig.setWriteThrough(getBooleanValue(getTextContent(n)));
        } else if (matches("cache-loader-factory", nodeName)) {
            cacheConfig.setCacheLoaderFactory(getAttribute(n, "class-name"));
        } else if (matches("cache-loader", nodeName)) {
            cacheConfig.setCacheLoader(getAttribute(n, "class-name"));
        } else if (matches("cache-writer-factory", nodeName)) {
            cacheConfig.setCacheWriterFactory(getAttribute(n, "class-name"));
        } else if (matches("cache-writer", nodeName)) {
            cacheConfig.setCacheWriter(getAttribute(n, "class-name"));
        } else if (matches("expiry-policy-factory", nodeName)) {
            cacheConfig.setExpiryPolicyFactoryConfig(getExpiryPolicyFactoryConfig(n));
        } else if (matches("cache-entry-listeners", nodeName)) {
            cacheListenerHandle(n, cacheConfig);
        } else if (matches("in-memory-format", nodeName)) {
            cacheConfig.setInMemoryFormat(InMemoryFormat.valueOf(upperCaseInternal(getTextContent(n))));
        } else if (matches("backup-count", nodeName)) {
            cacheConfig.setBackupCount(getIntegerValue("backup-count", getTextContent(n)));
        } else if (matches("async-backup-count", nodeName)) {
            cacheConfig.setAsyncBackupCount(getIntegerValue("async-backup-count", getTextContent(n)));
        } else if (matches("wan-replication-ref", nodeName)) {
            cacheWanReplicationRefHandle(n, cacheConfig);
        } else if (matches("eviction", nodeName)) {
            cacheConfig.setEvictionConfig(getEvictionConfig(n, false, false));
        } else if (matches("split-brain-protection-ref", nodeName)) {
            cacheConfig.setSplitBrainProtectionName(getTextContent(n));
        } else if (matches("partition-lost-listeners", nodeName)) {
            cachePartitionLostListenerHandle(n, cacheConfig);
        } else if (matches("merge-policy", nodeName)) {
            MergePolicyConfig mpConfig = createMergePolicyConfig(n, cacheConfig.getMergePolicyConfig());
            cacheConfig.setMergePolicyConfig(mpConfig);
        } else if (matches("event-journal", nodeName)) {
            EventJournalConfig eventJournalConfig = new EventJournalConfig();
            handleViaReflection(n, cacheConfig, eventJournalConfig);
        } else if (matches("hot-restart", nodeName)) {
            cacheConfig.setHotRestartConfig(createHotRestartConfig(n));
        } else if (matches("data-persistence", nodeName)) {
            cacheConfig.setDataPersistenceConfig(createDataPersistenceConfig(n));
        } else if (matches("disable-per-entry-invalidation-events", nodeName)) {
            cacheConfig.setDisablePerEntryInvalidationEvents(getBooleanValue(getTextContent(n)));
        } else if (matches("merkle-tree", nodeName)) {
            handleViaReflection(n, cacheConfig, cacheConfig.getMerkleTreeConfig());
        }
    }
    try {
        checkCacheConfig(cacheConfig, null);
    } catch (IllegalArgumentException e) {
        throw new InvalidConfigurationException(e.getMessage());
    }
    config.addCacheConfig(cacheConfig);
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) Node(org.w3c.dom.Node) EventJournalConfig(com.hazelcast.config.EventJournalConfig) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 19 with InvalidConfigurationException

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

the class MemberDomConfigProcessor method invokeSetter.

private void invokeSetter(Object target, Node node, String argument) {
    Method method = getMethod(target, "set" + toPropertyName(cleanNodeName(node)), true);
    if (method == null) {
        throw new InvalidConfigurationException("Invalid element/attribute name in the configuration: " + cleanNodeName(node));
    }
    Class<?> arg = method.getParameterTypes()[0];
    Object coercedArg = arg == String.class ? argument : arg == int.class ? Integer.valueOf(argument) : arg == long.class ? Long.valueOf(argument) : arg == boolean.class ? getBooleanValue(argument) : null;
    if (coercedArg == null) {
        throw new HazelcastException(String.format("Method %s has unsupported argument type %s", method.getName(), arg.getSimpleName()));
    }
    try {
        method.invoke(target, coercedArg);
    } catch (Exception e) {
        throw new HazelcastException(e);
    }
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) Method(java.lang.reflect.Method) HazelcastException(com.hazelcast.core.HazelcastException) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 20 with InvalidConfigurationException

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

the class MemberDomConfigProcessor method handleTcpIp.

private void handleTcpIp(Node node, boolean advancedNetworkConfig) {
    NamedNodeMap attributes = node.getAttributes();
    JoinConfig join = joinConfig(advancedNetworkConfig);
    TcpIpConfig tcpIpConfig = join.getTcpIpConfig();
    for (int a = 0; a < attributes.getLength(); a++) {
        Node att = attributes.item(a);
        if (matches(att.getNodeName(), "enabled")) {
            tcpIpConfig.setEnabled(getBooleanValue(getTextContent(att)));
        } else if (matches(att.getNodeName(), "connection-timeout-seconds")) {
            tcpIpConfig.setConnectionTimeoutSeconds(getIntegerValue("connection-timeout-seconds", getTextContent(att)));
        }
    }
    Set<String> memberTags = new HashSet<>(Arrays.asList("interface", "member", "members"));
    for (Node n : childElements(node)) {
        if (matches(cleanNodeName(n), "member-list")) {
            handleMemberList(n, advancedNetworkConfig);
        } else if (matches(cleanNodeName(n), "required-member")) {
            if (tcpIpConfig.getRequiredMember() != null) {
                throw new InvalidConfigurationException("Duplicate required-member" + " definition found in the configuration. ");
            }
            tcpIpConfig.setRequiredMember(getTextContent(n));
        } else if (memberTags.contains(cleanNodeName(n))) {
            tcpIpConfig.addMember(getTextContent(n));
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) JoinConfig(com.hazelcast.config.JoinConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) HashSet(java.util.HashSet) 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