Search in sources :

Example 1 with KeyspaceParams

use of org.apache.cassandra.schema.KeyspaceParams in project cassandra by apache.

the class KeyspaceAttributes method asAlteredKeyspaceParams.

public KeyspaceParams asAlteredKeyspaceParams(KeyspaceParams previous) {
    boolean durableWrites = getBoolean(Option.DURABLE_WRITES.toString(), previous.durableWrites);
    ReplicationParams replication = getReplicationStrategyClass() == null ? previous.replication : ReplicationParams.fromMap(getAllReplicationOptions());
    return new KeyspaceParams(durableWrites, replication);
}
Also used : ReplicationParams(org.apache.cassandra.schema.ReplicationParams) KeyspaceParams(org.apache.cassandra.schema.KeyspaceParams)

Example 2 with KeyspaceParams

use of org.apache.cassandra.schema.KeyspaceParams in project cassandra by apache.

the class AlterKeyspaceStatement method validate.

public void validate(ClientState state) throws RequestValidationException {
    KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(name);
    if (ksm == null)
        throw new InvalidRequestException("Unknown keyspace " + name);
    if (SchemaConstants.isSystemKeyspace(ksm.name))
        throw new InvalidRequestException("Cannot alter system keyspace");
    attrs.validate();
    if (attrs.getReplicationStrategyClass() == null && !attrs.getReplicationOptions().isEmpty())
        throw new ConfigurationException("Missing replication strategy class");
    if (attrs.getReplicationStrategyClass() != null) {
        // The strategy is validated through KSMetaData.validate() in announceKeyspaceUpdate below.
        // However, for backward compatibility with thrift, this doesn't validate unexpected options yet,
        // so doing proper validation here.
        KeyspaceParams params = attrs.asAlteredKeyspaceParams(ksm.params);
        params.validate(name);
        if (params.replication.klass.equals(LocalStrategy.class))
            throw new ConfigurationException("Unable to use given strategy class: LocalStrategy is reserved for internal use.");
        warnIfIncreasingRF(ksm, params);
    }
}
Also used : KeyspaceParams(org.apache.cassandra.schema.KeyspaceParams) KeyspaceMetadata(org.apache.cassandra.schema.KeyspaceMetadata)

Example 3 with KeyspaceParams

use of org.apache.cassandra.schema.KeyspaceParams in project cassandra by apache.

the class CreateKeyspaceStatement method validate.

/**
     * The <code>CqlParser</code> only goes as far as extracting the keyword arguments
     * from these statements, so this method is responsible for processing and
     * validating.
     *
     * @throws InvalidRequestException if arguments are missing or unacceptable
     */
public void validate(ClientState state) throws RequestValidationException {
    Schema.validateKeyspaceNotSystem(name);
    // keyspace name
    if (!PATTERN_WORD_CHARS.matcher(name).matches())
        throw new InvalidRequestException(String.format("\"%s\" is not a valid keyspace name", name));
    if (name.length() > SchemaConstants.NAME_LENGTH)
        throw new InvalidRequestException(String.format("Keyspace names shouldn't be more than %s characters long (got \"%s\")", SchemaConstants.NAME_LENGTH, name));
    attrs.validate();
    if (attrs.getReplicationStrategyClass() == null)
        throw new ConfigurationException("Missing mandatory replication strategy class");
    // The strategy is validated through KSMetaData.validate() in announceNewKeyspace below.
    // However, for backward compatibility with thrift, this doesn't validate unexpected options yet,
    // so doing proper validation here.
    KeyspaceParams params = attrs.asNewKeyspaceParams();
    params.validate(name);
    if (params.replication.klass.equals(LocalStrategy.class))
        throw new ConfigurationException("Unable to use given strategy class: LocalStrategy is reserved for internal use.");
}
Also used : KeyspaceParams(org.apache.cassandra.schema.KeyspaceParams)

Aggregations

KeyspaceParams (org.apache.cassandra.schema.KeyspaceParams)3 KeyspaceMetadata (org.apache.cassandra.schema.KeyspaceMetadata)1 ReplicationParams (org.apache.cassandra.schema.ReplicationParams)1