Search in sources :

Example 6 with InvalidConfigurationException

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

the class ClientDomConfigProcessor method buildConfig.

@Override
public void buildConfig(Node rootNode) {
    for (Node node : childElements(rootNode)) {
        String nodeName = cleanNodeName(node);
        if (occurrenceSet.contains(nodeName)) {
            throw new InvalidConfigurationException("Duplicate '" + nodeName + "' definition found in the configuration");
        }
        handleNode(node, nodeName);
        if (!canOccurMultipleTimes(nodeName)) {
            occurrenceSet.add(nodeName);
        }
    }
}
Also used : Node(org.w3c.dom.Node) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 7 with InvalidConfigurationException

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

the class MergeOperation method runInternal.

@Override
protected void runInternal() {
    // Check once in a minute as earliest to avoid log bursts.
    if (shouldCheckNow(mapContainer.getLastInvalidMergePolicyCheckTime())) {
        try {
            checkMapMergePolicy(mapContainer.getMapConfig(), mergePolicy.getClass().getName(), getNodeEngine().getSplitBrainMergePolicyProvider());
        } catch (InvalidConfigurationException e) {
            logger().log(Level.WARNING, e.getMessage(), e);
        }
    }
    hasMapListener = mapEventPublisher.hasEventListener(name);
    hasWanReplication = mapContainer.isWanReplicationEnabled() && !disableWanReplicationEvent;
    hasBackups = mapContainer.getTotalBackupCount() > 0;
    hasInvalidation = mapContainer.hasInvalidationListener();
    if (hasBackups) {
        backupPairs = new ArrayList(2 * mergingEntries.size());
    }
    if (hasInvalidation) {
        invalidationKeys = new ArrayList<>(mergingEntries.size());
    }
    // if currentIndex is not zero, this is a
    // continuation of the operation after a NativeOOME
    int size = mergingEntries.size();
    while (currentIndex < size) {
        merge(mergingEntries.get(currentIndex));
        currentIndex++;
    }
}
Also used : ArrayList(java.util.ArrayList) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 8 with InvalidConfigurationException

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

the class SplitBrainProtectionServiceImpl method validateSplitBrainProtectionParameters.

private void validateSplitBrainProtectionParameters(String splitBrainProtectionName, long value, String parameterName) {
    HazelcastProperties nodeProperties = nodeEngine.getProperties();
    long maxNoHeartbeatMillis = nodeProperties.getMillis(ClusterProperty.MAX_NO_HEARTBEAT_SECONDS);
    long heartbeatIntervalMillis = nodeProperties.getMillis(ClusterProperty.HEARTBEAT_INTERVAL_SECONDS);
    if (value > maxNoHeartbeatMillis) {
        throw new InvalidConfigurationException("This member is configured with maximum no-heartbeat duration " + maxNoHeartbeatMillis + " millis. For the split brain protection '" + splitBrainProtectionName + "' to be effective, set " + parameterName + " to a lower value. Currently configured value is " + value + ", reconfigure to a value lower than " + maxNoHeartbeatMillis + ".");
    } else if (value < heartbeatIntervalMillis) {
        throw new InvalidConfigurationException("Split brain protection '" + splitBrainProtectionName + "' is misconfigured: the value of " + "acceptable heartbeat pause (" + value + ") must be greater than " + "the configured heartbeat interval (" + heartbeatIntervalMillis + "), otherwise split brain protection " + "will be always absent.");
    }
}
Also used : HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 9 with InvalidConfigurationException

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

the class YamlMemberDomConfigProcessor method handleSecurityPermissions.

@SuppressWarnings({ "checkstyle:npathcomplexity", "checkstyle:methodlength" })
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);
    }
    Iterable<Node> nodes = childElements(node);
    for (Node child : nodes) {
        String nodeName = cleanNodeName(child);
        if (matches("on-join-operation", nodeName)) {
            continue;
        }
        nodeName = matches("all", nodeName) ? nodeName + "-permissions" : nodeName + "-permission";
        PermissionType type = PermissionConfig.PermissionType.getType(nodeName);
        if (type == null) {
            throw new InvalidConfigurationException("Security permission type is not valid " + nodeName);
        }
        if (PermissionConfig.PermissionType.CONFIG == type || PermissionConfig.PermissionType.ALL == type || PermissionConfig.PermissionType.TRANSACTION == type) {
            handleSecurityPermission(child, type);
        } else {
            handleSecurityPermissionGroup(child, type);
        }
    }
}
Also used : OnJoinPermissionOperationName(com.hazelcast.config.OnJoinPermissionOperationName) PermissionType(com.hazelcast.config.PermissionConfig.PermissionType) Node(org.w3c.dom.Node) YamlNode(com.hazelcast.internal.yaml.YamlNode) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 10 with InvalidConfigurationException

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

the class TcpClientConnectionManager method doConnectToCandidateCluster.

private boolean doConnectToCandidateCluster(CandidateClusterContext context, boolean switchingToNextCluster) {
    Set<Address> triedAddresses = new HashSet<>();
    try {
        waitStrategy.reset();
        do {
            Set<Address> triedAddressesPerAttempt = new HashSet<>();
            List<Member> memberList = new ArrayList<>(client.getClientClusterService().getMemberList());
            if (shuffleMemberList) {
                Collections.shuffle(memberList);
            }
            // try to connect to a member in the member list first
            for (Member member : memberList) {
                checkClientActive();
                triedAddressesPerAttempt.add(member.getAddress());
                Connection connection = connect(member, o -> getOrConnectToMember((Member) o, switchingToNextCluster));
                if (connection != null) {
                    return true;
                }
            }
            // try to connect to a member given via config(explicit config/discovery mechanisms)
            for (Address address : getPossibleMemberAddresses(context.getAddressProvider())) {
                checkClientActive();
                if (!triedAddressesPerAttempt.add(address)) {
                    // if we can not add it means that it is already tried to be connected with the member list
                    continue;
                }
                Connection connection = connect(address, o -> getOrConnectToAddress((Address) o, switchingToNextCluster));
                if (connection != null) {
                    return true;
                }
            }
            triedAddresses.addAll(triedAddressesPerAttempt);
            // and the lifecycle check is missing, hence we need to repeat the same check at this point.
            if (triedAddressesPerAttempt.isEmpty()) {
                checkClientActive();
            }
        } while (waitStrategy.sleep());
    } catch (ClientNotAllowedInClusterException | InvalidConfigurationException e) {
        logger.warning("Stopped trying on the cluster: " + context.getClusterName() + " reason: " + e.getMessage());
    }
    logger.info("Unable to connect to any address from the cluster with name: " + context.getClusterName() + ". The following addresses were tried: " + triedAddresses);
    return false;
}
Also used : Address(com.hazelcast.cluster.Address) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) ClientNotAllowedInClusterException(com.hazelcast.client.ClientNotAllowedInClusterException) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) Connection(com.hazelcast.internal.nio.Connection) ClientConnection(com.hazelcast.client.impl.connection.ClientConnection) Member(com.hazelcast.cluster.Member) LinkedHashSet(java.util.LinkedHashSet) 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