本文整理汇总了Java中org.apache.cassandra.service.ClientState.forInternalCalls方法的典型用法代码示例。如果您正苦于以下问题:Java ClientState.forInternalCalls方法的具体用法?Java ClientState.forInternalCalls怎么用?Java ClientState.forInternalCalls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.service.ClientState
的用法示例。
在下文中一共展示了ClientState.forInternalCalls方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseSchema
import org.apache.cassandra.service.ClientState; //导入方法依赖的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: getStatement
import org.apache.cassandra.service.ClientState; //导入方法依赖的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);
}
}
示例3: setupClientState
import org.apache.cassandra.service.ClientState; //导入方法依赖的package包/类
void setupClientState()
{
try
{
role = RoleResource.role(roleName);
// use reflection to set the logged in user so that we don't need to
// bother setting up an IRoleManager
user = new AuthenticatedUser(roleName);
clientState = ClientState.forInternalCalls();
Field userField = ClientState.class.getDeclaredField("user");
userField.setAccessible(true);
userField.set(clientState, user);
}
catch (IllegalAccessException | NoSuchFieldException e)
{
throw new RuntimeException(e);
}
}
示例4: schemaChange
import org.apache.cassandra.service.ClientState; //导入方法依赖的package包/类
protected static void schemaChange(String query)
{
try
{
ClientState state = ClientState.forInternalCalls();
state.setKeyspace(SystemKeyspace.NAME);
QueryState queryState = new QueryState(state);
ParsedStatement.Prepared prepared = QueryProcessor.parseStatement(query, queryState);
prepared.statement.validate(state);
QueryOptions options = QueryOptions.forInternalCalls(Collections.<ByteBuffer>emptyList());
lastSchemaChangeResult = prepared.statement.executeInternal(queryState, options);
}
catch (Exception e)
{
logger.info("Error performing schema change", e);
throw new RuntimeException("Error setting schema for test (query was: " + query + ")", e);
}
}
示例5: InternalStateInstance
import org.apache.cassandra.service.ClientState; //导入方法依赖的package包/类
InternalStateInstance()
{
ClientState state = ClientState.forInternalCalls();
try
{
state.setKeyspace(Keyspace.SYSTEM_KS);
}
catch (InvalidRequestException e)
{
throw new RuntimeException();
}
this.queryState = new QueryState(state);
}