本文整理汇总了Java中org.apache.cassandra.cli.CliMain.processStatement方法的典型用法代码示例。如果您正苦于以下问题:Java CliMain.processStatement方法的具体用法?Java CliMain.processStatement怎么用?Java CliMain.processStatement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.cli.CliMain
的用法示例。
在下文中一共展示了CliMain.processStatement方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupDataByCli
import org.apache.cassandra.cli.CliMain; //导入方法依赖的package包/类
protected static void setupDataByCli(String[] statements) throws CharacterCodingException, ClassNotFoundException, TException, TimedOutException, NotFoundException, InvalidRequestException, NoSuchFieldException, UnavailableException, IllegalAccessException, InstantiationException
{
// new error/output streams for CliSessionState
ByteArrayOutputStream errStream = new ByteArrayOutputStream();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
// checking if we can connect to the running cassandra node on localhost
CliMain.connect("127.0.0.1", 9170);
// setting new output stream
CliMain.sessionState.setOut(new PrintStream(outStream));
CliMain.sessionState.setErr(new PrintStream(errStream));
// re-creating keyspace for tests
try
{
// dropping in case it exists e.g. could be left from previous run
CliMain.processStatement("drop keyspace thriftKs;");
}
catch (Exception e)
{
}
for (String statement : statements)
{
errStream.reset();
System.out.println("Executing statement: " + statement);
CliMain.processStatement(statement);
String result = outStream.toString();
System.out.println("result: " + result);
outStream.reset(); // reset stream so we have only output from next statement all the time
errStream.reset(); // no errors to the end user.
}
}
示例2: executeCliStatements
import org.apache.cassandra.cli.CliMain; //导入方法依赖的package包/类
private void executeCliStatements(String[] statements) throws CharacterCodingException, ClassNotFoundException, TException, TimedOutException, NotFoundException, InvalidRequestException, NoSuchFieldException, UnavailableException, IllegalAccessException, InstantiationException
{
CliMain.connect("127.0.0.1", 9170);
try
{
for (String stmt : statements)
CliMain.processStatement(stmt);
}
catch (Exception e)
{
}
}
示例3: cliSchema
import org.apache.cassandra.cli.CliMain; //导入方法依赖的package包/类
private void cliSchema() throws URISyntaxException, IOException, NotFoundException, InvalidRequestException, NoSuchFieldException, UnavailableException, IllegalAccessException, InstantiationException, TException, ClassNotFoundException, TimedOutException {
CliMain.connect(_host, _port);
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(SQL_FILE_PATH);
BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
String line = null;
while ((line = br.readLine()) != null) {
CliMain.processStatement(line);
}
br.close();
CliMain.disconnect();
}
示例4: initialSchema
import org.apache.cassandra.cli.CliMain; //导入方法依赖的package包/类
public void initialSchema() throws URISyntaxException, IOException, NotFoundException, InvalidRequestException, NoSuchFieldException, UnavailableException, IllegalAccessException, InstantiationException, TException, ClassNotFoundException, TimedOutException {
CliMain.connect(_host, _port);
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(_sqlFilePath);
BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
String line = null;
while ((line = br.readLine()) != null) {
CliMain.processStatement(line);
}
br.close();
CliMain.disconnect();
}
示例5: createColumnFamily
import org.apache.cassandra.cli.CliMain; //导入方法依赖的package包/类
private void createColumnFamily(String ks, String cf, String statement) throws CharacterCodingException, ClassNotFoundException, TException, TimedOutException, NotFoundException, InvalidRequestException, NoSuchFieldException, UnavailableException, IllegalAccessException, InstantiationException
{
CliMain.connect("127.0.0.1", 9170);
try
{
CliMain.processStatement("use " + ks + ";");
CliMain.processStatement("drop column family " + cf + ";");
}
catch (Exception e)
{
}
CliMain.processStatement(statement);
}