Search in sources :

Example 1 with CASQuery

use of org.apache.cassandra.stress.operations.userdefined.CASQuery in project cassandra by apache.

the class StressProfile method getQuery.

public Operation getQuery(String name, Timer timer, PartitionGenerator generator, SeedManager seeds, StressSettings settings, boolean isWarmup) {
    name = name.toLowerCase();
    if (!queries.containsKey(name))
        throw new IllegalArgumentException("No query defined with name " + name);
    if (queryStatements == null) {
        synchronized (this) {
            if (queryStatements == null) {
                JavaDriverClient jclient = settings.getJavaDriverClient(keyspaceName);
                Map<String, PreparedStatement> stmts = new HashMap<>();
                Map<String, SchemaStatement.ArgSelect> args = new HashMap<>();
                for (Map.Entry<String, StressYaml.QueryDef> e : queries.entrySet()) {
                    stmts.put(e.getKey().toLowerCase(), jclient.prepare(e.getValue().cql));
                    args.put(e.getKey().toLowerCase(), e.getValue().fields == null ? SchemaStatement.ArgSelect.MULTIROW : SchemaStatement.ArgSelect.valueOf(e.getValue().fields.toUpperCase()));
                }
                queryStatements = stmts;
                argSelects = args;
            }
        }
    }
    if (dynamicConditionExists(queryStatements.get(name)))
        return new CASQuery(timer, settings, generator, seeds, queryStatements.get(name), settings.command.consistencyLevel, argSelects.get(name), tableName);
    return new SchemaQuery(timer, settings, generator, seeds, queryStatements.get(name), settings.command.consistencyLevel, argSelects.get(name));
}
Also used : JavaDriverClient(org.apache.cassandra.stress.util.JavaDriverClient) CASQuery(org.apache.cassandra.stress.operations.userdefined.CASQuery) ValidatingSchemaQuery(org.apache.cassandra.stress.operations.userdefined.ValidatingSchemaQuery) SchemaQuery(org.apache.cassandra.stress.operations.userdefined.SchemaQuery)

Aggregations

CASQuery (org.apache.cassandra.stress.operations.userdefined.CASQuery)1 SchemaQuery (org.apache.cassandra.stress.operations.userdefined.SchemaQuery)1 ValidatingSchemaQuery (org.apache.cassandra.stress.operations.userdefined.ValidatingSchemaQuery)1 JavaDriverClient (org.apache.cassandra.stress.util.JavaDriverClient)1