本文整理汇总了Java中org.apache.cassandra.exceptions.RequestValidationException类的典型用法代码示例。如果您正苦于以下问题:Java RequestValidationException类的具体用法?Java RequestValidationException怎么用?Java RequestValidationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestValidationException类属于org.apache.cassandra.exceptions包,在下文中一共展示了RequestValidationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseSchema
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
/**
* Get the meta data (column definitions) for the target table.
*
* @param query The CREATE TABLE statement for the table the Json data should be put into.
* @return The table's meta data
*/
private static CFMetaData parseSchema(String query) {
try {
ClientState state = ClientState.forInternalCalls();
ParsedStatement.Prepared prepared = QueryProcessor.getStatement(query, state);
CQLStatement stmt = prepared.statement;
stmt.validate(state);
if (!stmt.getClass().equals(CreateTableStatement.class)) {
throw new IllegalArgumentException("Invalid query, must be a CREATE TABLE statement");
}
return CreateTableStatement.class.cast(stmt).getCFMetaData();
} catch (RequestValidationException | IllegalArgumentException e) {
throw new RuntimeException(e);
}
}
示例2: executeInternalWithPaging
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
public static UntypedResultSet executeInternalWithPaging(String query, int pageSize, Object... values)
{
try
{
ParsedStatement.Prepared prepared = prepareInternal(query);
if (!(prepared.statement instanceof SelectStatement))
throw new IllegalArgumentException("Only SELECTs can be paged");
SelectStatement select = (SelectStatement)prepared.statement;
QueryPager pager = QueryPagers.localPager(select.getPageableCommand(makeInternalOptions(prepared, values)));
return UntypedResultSet.create(select, pager, pageSize);
}
catch (RequestValidationException e)
{
throw new RuntimeException("Error validating query" + e);
}
}
示例3: processBatch
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
public ResultMessage processBatch(BatchStatement statement,
QueryState state,
BatchQueryOptions options,
Map<String, ByteBuffer> customPayload)
throws RequestExecutionException, RequestValidationException
{
if (customPayload != null)
requestPayload = customPayload;
ResultMessage result = QueryProcessor.instance.processBatch(statement, state, options, customPayload);
if (customPayload != null)
{
result.setCustomPayload(responsePayload);
responsePayload = null;
}
return result;
}
示例4: validate
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
/**
* 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
{
ThriftValidation.validateKeyspaceNotSystem(name);
// keyspace name
if (!name.matches("\\w+"))
throw new InvalidRequestException(String.format("\"%s\" is not a valid keyspace name", name));
if (name.length() > Schema.NAME_LENGTH)
throw new InvalidRequestException(String.format("Keyspace names shouldn't be more than %s characters long (got \"%s\")", Schema.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.
AbstractReplicationStrategy.validateReplicationStrategy(name,
AbstractReplicationStrategy.getClass(attrs.getReplicationStrategyClass()),
StorageService.instance.getTokenMetadata(),
DatabaseDescriptor.getEndpointSnitch(),
attrs.getReplicationOptions());
}
示例5: load
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
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);
}
}
示例6: fetchPage
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
public List<Row> fetchPage(int pageSize) throws RequestValidationException, RequestExecutionException
{
List<Row> result = new ArrayList<Row>();
int remainingThisQuery = Math.min(remaining, pageSize);
while (remainingThisQuery > 0 && !isExhausted())
{
// isExhausted has set us on the first non-exhausted pager
List<Row> page = pagers[current].fetchPage(remainingThisQuery);
if (page.isEmpty())
continue;
Row row = page.get(0);
int fetched = pagers[current].columnCounter().countAll(row.cf).live();
remaining -= fetched;
remainingThisQuery -= fetched;
result.add(row);
}
return result;
}
示例7: countPaged
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
/**
* Convenience method that count (live) cells/rows for a given slice of a row, but page underneath.
*/
public static int countPaged(String keyspace,
String columnFamily,
ByteBuffer key,
SliceQueryFilter filter,
ConsistencyLevel consistencyLevel,
ClientState cState,
final int pageSize,
long now) throws RequestValidationException, RequestExecutionException
{
SliceFromReadCommand command = new SliceFromReadCommand(keyspace, key, columnFamily, now, filter);
final SliceQueryPager pager = new SliceQueryPager(command, consistencyLevel, cState, false);
ColumnCounter counter = filter.columnCounter(Schema.instance.getCFMetaData(keyspace, columnFamily).comparator, now);
while (!pager.isExhausted())
{
List<Row> next = pager.fetchPage(pageSize);
if (!next.isEmpty())
counter.countAll(next.get(0).cf);
}
return counter.live();
}
示例8: execute
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
public ResultMessage execute(ClientState state) throws RequestValidationException, RequestExecutionException
{
List<PermissionDetails> details = new ArrayList<PermissionDetails>();
if (resource != null && recursive)
{
for (IResource r : Resources.chain(resource))
details.addAll(list(state, r));
}
else
{
details.addAll(list(state, resource));
}
Collections.sort(details);
return resultMessage(details);
}
示例9: getFormatType
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
private AbstractType<?> getFormatType(String compareWith)
{
Function function;
try
{
function = Function.valueOf(compareWith.toUpperCase());
}
catch (IllegalArgumentException e)
{
try
{
return TypeParser.parse(compareWith);
}
catch (RequestValidationException ce)
{
String message = String.format("Unknown comparator '%s'. Available functions: %s", compareWith, Function.getFunctionNames());
throw new RuntimeException(message, e);
}
}
return function.getValidator();
}
示例10: getStatement
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
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);
}
}
示例11: announceMigration
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws RequestValidationException
{
Function old = findFunction();
if (old == null)
{
if (ifExists)
return null;
else
throw new InvalidRequestException(getMissingFunctionError());
}
KeyspaceMetadata ksm = Schema.instance.getKSMetaData(old.name().keyspace);
Collection<UDAggregate> referrers = ksm.functions.aggregatesUsingFunction(old);
if (!referrers.isEmpty())
throw new InvalidRequestException(String.format("Function '%s' still referenced by %s", old, referrers));
MigrationManager.announceFunctionDrop((UDFunction) old, isLocalOnly);
return new Event.SchemaChange(Event.SchemaChange.Change.DROPPED, Event.SchemaChange.Target.FUNCTION,
old.name().keyspace, old.name().name, AbstractType.asCQLTypeStringList(old.argTypes()));
}
示例12: announceMigration
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws RequestValidationException
{
CFMetaData meta = validateColumnFamily(keyspace(), columnFamily());
if (!meta.isView())
throw new InvalidRequestException("Cannot use ALTER MATERIALIZED VIEW on Table");
ViewDefinition viewCopy = Schema.instance.getView(keyspace(), columnFamily()).copy();
if (attrs == null)
throw new InvalidRequestException("ALTER MATERIALIZED VIEW WITH invoked, but no parameters found");
attrs.validate();
TableParams params = attrs.asAlteredTableParams(viewCopy.metadata.params);
if (params.gcGraceSeconds == 0)
{
throw new InvalidRequestException("Cannot alter gc_grace_seconds of a materialized view to 0, since this " +
"value is used to TTL undelivered updates. Setting gc_grace_seconds too " +
"low might cause undelivered updates to expire before being replayed.");
}
viewCopy.metadata.params(params);
MigrationManager.announceViewUpdate(viewCopy, isLocalOnly);
return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily());
}
示例13: validate
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
public void validate() throws RequestValidationException
{
validate(keywords, obsoleteKeywords);
if (isCustom && customClass == null)
throw new InvalidRequestException("CUSTOM index requires specifiying the index class");
if (!isCustom && customClass != null)
throw new InvalidRequestException("Cannot specify index class for a non-CUSTOM index");
if (!isCustom && !properties.isEmpty())
throw new InvalidRequestException("Cannot specify options for a non-CUSTOM index");
if (getRawOptions().containsKey(IndexTarget.CUSTOM_INDEX_OPTION_NAME))
throw new InvalidRequestException(String.format("Cannot specify %s as a CUSTOM option",
IndexTarget.CUSTOM_INDEX_OPTION_NAME));
if (getRawOptions().containsKey(IndexTarget.TARGET_OPTION_NAME))
throw new InvalidRequestException(String.format("Cannot specify %s as a CUSTOM option",
IndexTarget.TARGET_OPTION_NAME));
}
示例14: getFormatType
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
private AbstractType<?> getFormatType(String compareWith)
{
Function function;
try
{
function = Function.valueOf(compareWith.toUpperCase());
}
catch (IllegalArgumentException e)
{
try
{
return TypeParser.parse(compareWith);
}
catch (RequestValidationException ce)
{
StringBuilder errorMessage = new StringBuilder("Unknown comparator '" + compareWith + "'. ");
errorMessage.append("Available functions: ");
throw new RuntimeException(errorMessage.append(Function.getFunctionNames()).toString(), e);
}
}
return function.getValidator();
}
示例15: fetchPage
import org.apache.cassandra.exceptions.RequestValidationException; //导入依赖的package包/类
public List<Row> fetchPage(int pageSize) throws RequestValidationException, RequestExecutionException
{
int remaining = pageSize;
List<Row> result = new ArrayList<Row>();
while (!isExhausted() && remaining > 0)
{
// Exhausted also sets us on the first non-exhausted pager
List<Row> page = pagers[current].fetchPage(remaining);
if (page.isEmpty())
continue;
Row row = page.get(0);
remaining -= pagers[current].columnCounter().countAll(row.cf).live();
result.add(row);
}
return result;
}