Search in sources :

Example 71 with ConfigurationException

use of org.apache.cassandra.exceptions.ConfigurationException in project cassandra by apache.

the class DatabaseDescriptor method applyAddressConfig.

public static void applyAddressConfig(Config config) throws ConfigurationException {
    listenAddress = null;
    rpcAddress = null;
    broadcastAddress = null;
    broadcastRpcAddress = null;
    /* Local IP, hostname or interface to bind services to */
    if (config.listen_address != null && config.listen_interface != null) {
        throw new ConfigurationException("Set listen_address OR listen_interface, not both", false);
    } else if (config.listen_address != null) {
        try {
            listenAddress = InetAddress.getByName(config.listen_address);
        } catch (UnknownHostException e) {
            throw new ConfigurationException("Unknown listen_address '" + config.listen_address + '\'', false);
        }
        if (listenAddress.isAnyLocalAddress())
            throw new ConfigurationException("listen_address cannot be a wildcard address (" + config.listen_address + ")!", false);
    } else if (config.listen_interface != null) {
        listenAddress = getNetworkInterfaceAddress(config.listen_interface, "listen_interface", config.listen_interface_prefer_ipv6);
    }
    /* Gossip Address to broadcast */
    if (config.broadcast_address != null) {
        try {
            broadcastAddress = InetAddress.getByName(config.broadcast_address);
        } catch (UnknownHostException e) {
            throw new ConfigurationException("Unknown broadcast_address '" + config.broadcast_address + '\'', false);
        }
        if (broadcastAddress.isAnyLocalAddress())
            throw new ConfigurationException("broadcast_address cannot be a wildcard address (" + config.broadcast_address + ")!", false);
    }
    /* Local IP, hostname or interface to bind RPC server to */
    if (config.rpc_address != null && config.rpc_interface != null) {
        throw new ConfigurationException("Set rpc_address OR rpc_interface, not both", false);
    } else if (config.rpc_address != null) {
        try {
            rpcAddress = InetAddress.getByName(config.rpc_address);
        } catch (UnknownHostException e) {
            throw new ConfigurationException("Unknown host in rpc_address " + config.rpc_address, false);
        }
    } else if (config.rpc_interface != null) {
        rpcAddress = getNetworkInterfaceAddress(config.rpc_interface, "rpc_interface", config.rpc_interface_prefer_ipv6);
    } else {
        rpcAddress = FBUtilities.getJustLocalAddress();
    }
    /* RPC address to broadcast */
    if (config.broadcast_rpc_address != null) {
        try {
            broadcastRpcAddress = InetAddress.getByName(config.broadcast_rpc_address);
        } catch (UnknownHostException e) {
            throw new ConfigurationException("Unknown broadcast_rpc_address '" + config.broadcast_rpc_address + '\'', false);
        }
        if (broadcastRpcAddress.isAnyLocalAddress())
            throw new ConfigurationException("broadcast_rpc_address cannot be a wildcard address (" + config.broadcast_rpc_address + ")!", false);
    } else {
        if (rpcAddress.isAnyLocalAddress())
            throw new ConfigurationException("If rpc_address is set to a wildcard address (" + config.rpc_address + "), then " + "you must set broadcast_rpc_address to a value other than " + config.rpc_address, false);
    }
}
Also used : ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException)

Example 72 with ConfigurationException

use of org.apache.cassandra.exceptions.ConfigurationException in project cassandra by apache.

the class DatabaseDescriptor method applySslContext.

public static void applySslContext() {
    try {
        SSLFactory.validateSslContext("Internode messaging", conf.server_encryption_options, true, true);
        SSLFactory.validateSslContext("Native transport", conf.client_encryption_options, conf.client_encryption_options.require_client_auth, true);
        SSLFactory.initHotReloading(conf.server_encryption_options, conf.client_encryption_options, false);
    } catch (IOException e) {
        throw new ConfigurationException("Failed to initialize SSL", e);
    }
}
Also used : ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException) IOException(java.io.IOException)

Example 73 with ConfigurationException

use of org.apache.cassandra.exceptions.ConfigurationException in project cassandra by apache.

the class BootStrapper method getSpecifiedTokens.

private static Collection<Token> getSpecifiedTokens(final TokenMetadata metadata, Collection<String> initialTokens) {
    logger.info("tokens manually specified as {}", initialTokens);
    List<Token> tokens = new ArrayList<>(initialTokens.size());
    for (String tokenString : initialTokens) {
        Token token = metadata.partitioner.getTokenFactory().fromString(tokenString);
        if (metadata.getEndpoint(token) != null)
            throw new ConfigurationException("Bootstrapping to existing token " + tokenString + " is not allowed (decommission/removenode the old node first).");
        tokens.add(token);
    }
    return tokens;
}
Also used : ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException)

Example 74 with ConfigurationException

use of org.apache.cassandra.exceptions.ConfigurationException in project cassandra by apache.

the class BootStrapper method getBootstrapTokens.

/**
 * if initialtoken was specified, use that (split on comma).
 * otherwise, if allocationKeyspace is specified use the token allocation algorithm to generate suitable tokens
 * else choose num_tokens tokens at random
 */
public static Collection<Token> getBootstrapTokens(final TokenMetadata metadata, InetAddressAndPort address, long schemaWaitDelay) throws ConfigurationException {
    String allocationKeyspace = DatabaseDescriptor.getAllocateTokensForKeyspace();
    Integer allocationLocalRf = DatabaseDescriptor.getAllocateTokensForLocalRf();
    Collection<String> initialTokens = DatabaseDescriptor.getInitialTokens();
    if (initialTokens.size() > 0 && allocationKeyspace != null)
        logger.warn("manually specified tokens override automatic allocation");
    // if user specified tokens, use those
    if (initialTokens.size() > 0) {
        Collection<Token> tokens = getSpecifiedTokens(metadata, initialTokens);
        BootstrapDiagnostics.useSpecifiedTokens(address, allocationKeyspace, tokens, DatabaseDescriptor.getNumTokens());
        return tokens;
    }
    int numTokens = DatabaseDescriptor.getNumTokens();
    if (numTokens < 1)
        throw new ConfigurationException("num_tokens must be >= 1");
    if (allocationKeyspace != null)
        return allocateTokens(metadata, address, allocationKeyspace, numTokens, schemaWaitDelay);
    if (allocationLocalRf != null)
        return allocateTokens(metadata, address, allocationLocalRf, numTokens, schemaWaitDelay);
    if (numTokens == 1)
        logger.warn("Picking random token for a single vnode.  You should probably add more vnodes and/or use the automatic token allocation mechanism.");
    Collection<Token> tokens = getRandomTokens(metadata, numTokens);
    BootstrapDiagnostics.useRandomTokens(address, metadata, numTokens, tokens);
    return tokens;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException)

Example 75 with ConfigurationException

use of org.apache.cassandra.exceptions.ConfigurationException in project cassandra by apache.

the class FixedSpeculativeRetryPolicy method fromString.

static FixedSpeculativeRetryPolicy fromString(String str) {
    Matcher matcher = PATTERN.matcher(str);
    if (!matcher.matches())
        throw new IllegalArgumentException();
    String val = matcher.group("val");
    try {
        // historically we've always parsed this as double, but treated as int; so we keep doing it for compatibility
        return new FixedSpeculativeRetryPolicy((int) Double.parseDouble(val));
    } catch (IllegalArgumentException e) {
        throw new ConfigurationException(String.format("Invalid value %s for option '%s'", str, TableParams.Option.SPECULATIVE_RETRY));
    }
}
Also used : Matcher(java.util.regex.Matcher) ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException)

Aggregations

ConfigurationException (org.apache.cassandra.exceptions.ConfigurationException)84 IOException (java.io.IOException)12 URL (java.net.URL)6 HashMap (java.util.HashMap)6 Keyspace (org.apache.cassandra.db.Keyspace)5 DataInputStream (java.io.DataInputStream)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 HttpURLConnection (java.net.HttpURLConnection)4 Map (java.util.Map)4 Matcher (java.util.regex.Matcher)4 File (org.apache.cassandra.io.util.File)4 FilterInputStream (java.io.FilterInputStream)3 UnknownHostException (java.net.UnknownHostException)3 CFMetaData (org.apache.cassandra.config.CFMetaData)3 IPartitioner (org.apache.cassandra.dht.IPartitioner)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)2 InputStream (java.io.InputStream)2 InetAddress (java.net.InetAddress)2 HashSet (java.util.HashSet)2