use of org.apache.cassandra.exceptions.RequestValidationException in project cassandra by apache.
the class QueryMessage method execute.
public Message.Response execute(QueryState state, long queryStartNanoTime) {
try {
if (options.getPageSize() == 0)
throw new ProtocolException("The page size cannot be 0");
UUID tracingId = null;
if (isTracingRequested()) {
tracingId = UUIDGen.getTimeUUID();
state.prepareTracingSession(tracingId);
}
if (state.traceNextQuery()) {
state.createTracingSession();
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("query", query);
if (options.getPageSize() > 0)
builder.put("page_size", Integer.toString(options.getPageSize()));
if (options.getConsistency() != null)
builder.put("consistency_level", options.getConsistency().name());
if (options.getSerialConsistency() != null)
builder.put("serial_consistency_level", options.getSerialConsistency().name());
Tracing.instance.begin("Execute CQL3 query", state.getClientAddress(), builder.build());
}
Message.Response response = ClientState.getCQLQueryHandler().process(query, state, options, getCustomPayload(), queryStartNanoTime);
if (options.skipMetadata() && response instanceof ResultMessage.Rows)
((ResultMessage.Rows) response).result.metadata.setSkipMetadata();
if (tracingId != null)
response.setTracingId(tracingId);
return response;
} catch (Exception e) {
JVMStabilityInspector.inspectThrowable(e);
if (!((e instanceof RequestValidationException) || (e instanceof RequestExecutionException)))
logger.error("Unexpected error during query", e);
return ErrorMessage.fromException(e);
} finally {
Tracing.instance.stopSession();
}
}
use of org.apache.cassandra.exceptions.RequestValidationException in project cassandra by apache.
the class StressProfile method load.
public static StressProfile load(URI file) throws IOError {
try {
Constructor constructor = new Constructor(StressYaml.class);
Yaml yaml = new Yaml(constructor);
InputStream yamlStream = file.toURL().openStream();
if (yamlStream.available() == 0)
throw new IOException("Unable to load yaml file from: " + file);
StressYaml profileYaml = yaml.loadAs(yamlStream, StressYaml.class);
StressProfile profile = new StressProfile();
profile.init(profileYaml);
return profile;
} catch (YAMLException | IOException | RequestValidationException e) {
throw new IOError(e);
}
}
Aggregations