Java Code Examples for org.apache.cassandra.exceptions.RequestValidationException#getMessage()

The following examples show how to use org.apache.cassandra.exceptions.RequestValidationException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CQLSSTableWriter.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
private static <T extends CQLStatement> Pair<T, List<ColumnSpecification>> getStatement(String query, Class<T> klass, String type)
{
    try
    {
        ClientState state = ClientState.forInternalCalls();
        ParsedStatement.Prepared prepared = QueryProcessor.getStatement(query, state);
        CQLStatement stmt = prepared.statement;
        stmt.validate(state);

        if (!stmt.getClass().equals(klass))
            throw new IllegalArgumentException("Invalid query, must be a " + type + " statement");

        return Pair.create(klass.cast(stmt), prepared.boundNames);
    }
    catch (RequestValidationException e)
    {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
Example 2
Source File: CQLSSTableWriter.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * The schema (CREATE TABLE statement) for the table for which sstable are to be created.
 * <p>
 * Please note that the provided CREATE TABLE statement <b>must</b> use a fully-qualified
 * table name, one that include the keyspace name.
 * <p>
 * This is a mandatory option.
 *
 * @param schema the schema of the table for which sstables are to be created.
 * @return this builder.
 *
 * @throws IllegalArgumentException if {@code schema} is not a valid CREATE TABLE statement
 * or does not have a fully-qualified table name.
 */
public Builder forTable(String schema)
{
    try
    {
        synchronized (CQLSSTableWriter.class)
        {
            this.schema = getStatement(schema, CreateTableStatement.class, "CREATE TABLE").left.getCFMetaData().rebuild();

            // We need to register the keyspace/table metadata through Schema, otherwise we won't be able to properly
            // build the insert statement in using().
            KSMetaData ksm = Schema.instance.getKSMetaData(this.schema.ksName);
            if (ksm == null)
            {
                createKeyspaceWithTable(this.schema);
            }
            else if (Schema.instance.getCFMetaData(this.schema.ksName, this.schema.cfName) == null)
            {
                addTableToKeyspace(ksm, this.schema);
            }
            return this;
        }
    }
    catch (RequestValidationException e)
    {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
Example 3
Source File: ThriftConversion.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public static InvalidRequestException toThrift(RequestValidationException e)
{
    return new InvalidRequestException(e.getMessage());
}