本文整理汇总了Java中org.apache.cassandra.cql3.QueryProcessor.process方法的典型用法代码示例。如果您正苦于以下问题:Java QueryProcessor.process方法的具体用法?Java QueryProcessor.process怎么用?Java QueryProcessor.process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.cql3.QueryProcessor
的用法示例。
在下文中一共展示了QueryProcessor.process方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWriting
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
private static void testWriting() throws Exception
{
// do some writing.
for (int i = 0; i < 100; i++)
{
QueryProcessor.process(String.format("INSERT INTO %s.%s (id, name, value) VALUES ( 'key%d', 'colb', 'value%d')",
KEYSPACE,
COLUMN_FAMILY,
i,
i),
ConsistencyLevel.QUORUM);
System.out.println("wrote key" + i);
}
System.out.println("Done writing.");
}
示例2: testValidationCompactStorage
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
/**
* For CASSANDRA-6892 too, check that for a compact table with one cluster column, we can insert whatever
* we want as value for the clustering column, including something that would conflict with a CQL column definition.
*/
@Test
public void testValidationCompactStorage() throws Exception
{
QueryProcessor.process(String.format("CREATE TABLE \"%s\".test_compact_dynamic_columns (a int, b text, c text, PRIMARY KEY (a, b)) WITH COMPACT STORAGE", KEYSPACE), ConsistencyLevel.ONE);
Keyspace keyspace = Keyspace.open(KEYSPACE);
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore("test_compact_dynamic_columns");
QueryProcessor.executeInternal(String.format("INSERT INTO \"%s\".test_compact_dynamic_columns (a, b, c) VALUES (0, 'a', 'foo')", KEYSPACE));
QueryProcessor.executeInternal(String.format("INSERT INTO \"%s\".test_compact_dynamic_columns (a, b, c) VALUES (0, 'b', 'bar')", KEYSPACE));
QueryProcessor.executeInternal(String.format("INSERT INTO \"%s\".test_compact_dynamic_columns (a, b, c) VALUES (0, 'c', 'boo')", KEYSPACE));
cfs.forceBlockingFlush();
CompactionManager.instance.performScrub(cfs, true, true, 2);
// Scrub is silent, but it will remove broken records. So reading everything back to make sure nothing to "scrubbed away"
UntypedResultSet rs = QueryProcessor.executeInternal(String.format("SELECT * FROM \"%s\".test_compact_dynamic_columns", KEYSPACE));
assertEquals(3, rs.size());
Iterator<UntypedResultSet.Row> iter = rs.iterator();
assertEquals("foo", iter.next().getString("c"));
assertEquals("bar", iter.next().getString("c"));
assertEquals("boo", iter.next().getString("c"));
}
示例3: setupDefaultSuperuser
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
private static void setupDefaultSuperuser()
{
try
{
// insert a default superuser if AUTH_KS.USERS_CF is empty.
if (!hasExistingUsers())
{
QueryProcessor.process(String.format("INSERT INTO %s.%s (name, super) VALUES ('%s', %s) USING TIMESTAMP 0",
AUTH_KS,
USERS_CF,
DEFAULT_SUPERUSER_NAME,
true),
ConsistencyLevel.ONE);
logger.info("Created default superuser '{}'", DEFAULT_SUPERUSER_NAME);
}
}
catch (RequestExecutionException e)
{
logger.warn("Skipped default superuser setup: some nodes were not ready");
}
}
示例4: testValidationCompactStorage
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
/**
* For CASSANDRA-6892 too, check that for a compact table with one cluster column, we can insert whatever
* we want as value for the clustering column, including something that would conflict with a CQL column definition.
*/
@Test
public void testValidationCompactStorage() throws Exception
{
QueryProcessor.process("CREATE TABLE \"Keyspace1\".test_compact_dynamic_columns (a int, b text, c text, PRIMARY KEY (a, b)) WITH COMPACT STORAGE", ConsistencyLevel.ONE);
Keyspace keyspace = Keyspace.open("Keyspace1");
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore("test_compact_dynamic_columns");
QueryProcessor.executeInternal("INSERT INTO \"Keyspace1\".test_compact_dynamic_columns (a, b, c) VALUES (0, 'a', 'foo')");
QueryProcessor.executeInternal("INSERT INTO \"Keyspace1\".test_compact_dynamic_columns (a, b, c) VALUES (0, 'b', 'bar')");
QueryProcessor.executeInternal("INSERT INTO \"Keyspace1\".test_compact_dynamic_columns (a, b, c) VALUES (0, 'c', 'boo')");
cfs.forceBlockingFlush();
CompactionManager.instance.performScrub(cfs, true);
// Scrub is silent, but it will remove broken records. So reading everything back to make sure nothing to "scrubbed away"
UntypedResultSet rs = QueryProcessor.executeInternal("SELECT * FROM \"Keyspace1\".test_compact_dynamic_columns");
assertEquals(3, rs.size());
Iterator<UntypedResultSet.Row> iter = rs.iterator();
assertEquals("foo", iter.next().getString("c"));
assertEquals("bar", iter.next().getString("c"));
assertEquals("boo", iter.next().getString("c"));
}
示例5: setupDefaultSuperuser
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
private static void setupDefaultSuperuser()
{
try
{
// insert a default superuser if AUTH_KS.USERS_CF is empty.
if (QueryProcessor.process(String.format("SELECT * FROM %s.%s", AUTH_KS, USERS_CF), ConsistencyLevel.QUORUM).isEmpty())
{
QueryProcessor.process(String.format("INSERT INTO %s.%s (name, super) VALUES ('%s', %s) USING TIMESTAMP 0",
AUTH_KS,
USERS_CF,
DEFAULT_SUPERUSER_NAME,
true),
ConsistencyLevel.QUORUM);
logger.info("Created default superuser '{}'", DEFAULT_SUPERUSER_NAME);
}
}
catch (RequestExecutionException e)
{
logger.warn("Skipped default superuser setup: some nodes were not ready");
}
}
示例6: executeTriggerOnCqlInsert
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
@Test
public void executeTriggerOnCqlInsert() throws Exception
{
String cql = String.format("INSERT INTO %s.%s (k, v1) VALUES (0, 0)", ksName, cfName);
QueryProcessor.process(cql, ConsistencyLevel.ONE);
assertUpdateIsAugmented(0);
}
示例7: setup
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
@Before
public void setup() throws Exception
{
StorageService.instance.initServer(0);
if (thriftServer == null || ! thriftServer.isRunning())
{
thriftServer = new ThriftServer(InetAddress.getLocalHost(), 9170, 50);
thriftServer.start();
}
String cql = String.format("CREATE KEYSPACE IF NOT EXISTS %s " +
"WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1}",
ksName);
QueryProcessor.process(cql, ConsistencyLevel.ONE);
cql = String.format("CREATE TABLE IF NOT EXISTS %s.%s (k int, v1 int, v2 int, PRIMARY KEY (k))", ksName, cfName);
QueryProcessor.process(cql, ConsistencyLevel.ONE);
cql = String.format("CREATE TABLE IF NOT EXISTS %s.%s (k int, v1 int, v2 int, PRIMARY KEY (k))", ksName, otherCf);
QueryProcessor.process(cql, ConsistencyLevel.ONE);
// no conditional execution of create trigger stmt yet
if (! triggerCreated)
{
cql = String.format("CREATE TRIGGER trigger_1 ON %s.%s USING '%s'",
ksName, cfName, TestTrigger.class.getName());
QueryProcessor.process(cql, ConsistencyLevel.ONE);
triggerCreated = true;
}
}
示例8: deleteUser
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
/**
* Deletes the user from AUTH_KS.USERS_CF.
*
* @param username Username to delete.
* @throws RequestExecutionException
*/
public static void deleteUser(String username) throws RequestExecutionException
{
QueryProcessor.process(String.format("DELETE FROM %s.%s WHERE name = '%s'",
AUTH_KS,
USERS_CF,
escape(username)),
consistencyForUser(username));
}
示例9: onCqlUpdateWithConditionsRejectGeneratedUpdatesForDifferentPartition
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
@Test(expected=RuntimeException.class)
public void onCqlUpdateWithConditionsRejectGeneratedUpdatesForDifferentPartition() throws Exception
{
String cf = "cf" + System.nanoTime();
try
{
setupTableWithTrigger(cf, CrossPartitionTrigger.class);
String cql = String.format("INSERT INTO %s.%s (k, v1) VALUES (7, 7) IF NOT EXISTS", ksName, cf);
QueryProcessor.process(cql, ConsistencyLevel.ONE);
}
finally
{
assertUpdateNotExecuted(cf, 7);
}
}
示例10: testScrubColumnValidation
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
@Test
public void testScrubColumnValidation() throws InterruptedException, RequestExecutionException, ExecutionException
{
QueryProcessor.process("CREATE TABLE \"Keyspace1\".test_compact_static_columns (a bigint, b timeuuid, c boolean static, d text, PRIMARY KEY (a, b))", ConsistencyLevel.ONE);
Keyspace keyspace = Keyspace.open("Keyspace1");
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore("test_compact_static_columns");
QueryProcessor.executeInternal("INSERT INTO \"Keyspace1\".test_compact_static_columns (a, b, c, d) VALUES (123, c3db07e8-b602-11e3-bc6b-e0b9a54a6d93, true, 'foobar')");
cfs.forceBlockingFlush();
CompactionManager.instance.performScrub(cfs, false);
}
示例11: setupTableWithTrigger
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
private void setupTableWithTrigger(String cf, Class<? extends ITrigger> triggerImpl)
throws RequestExecutionException
{
String cql = String.format("CREATE TABLE IF NOT EXISTS %s.%s (k int, v1 int, v2 int, PRIMARY KEY (k))", ksName, cf);
QueryProcessor.process(cql, ConsistencyLevel.ONE);
// no conditional execution of create trigger stmt yet
cql = String.format("CREATE TRIGGER trigger_1 ON %s.%s USING '%s'",
ksName, cf, triggerImpl.getName());
QueryProcessor.process(cql, ConsistencyLevel.ONE);
}
示例12: executeTriggerOnCqlInsertWithConditions
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
@Test
public void executeTriggerOnCqlInsertWithConditions() throws Exception
{
String cql = String.format("INSERT INTO %s.%s (k, v1) VALUES (4, 4) IF NOT EXISTS", ksName, cfName);
QueryProcessor.process(cql, ConsistencyLevel.ONE);
assertUpdateIsAugmented(4);
}
示例13: executeTriggerOnCqlBatchWithConditions
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
@Test
public void executeTriggerOnCqlBatchWithConditions() throws Exception
{
String cql = String.format("BEGIN BATCH " +
" INSERT INTO %1$s.%2$s (k, v1) VALUES (5, 5) IF NOT EXISTS; " +
" INSERT INTO %1$s.%2$s (k, v1) VALUES (5, 5); " +
"APPLY BATCH",
ksName, cfName);
QueryProcessor.process(cql, ConsistencyLevel.ONE);
assertUpdateIsAugmented(5);
}
示例14: onCqlUpdateWithConditionsRejectGeneratedUpdatesForDifferentTable
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
@Test(expected=RuntimeException.class)
public void onCqlUpdateWithConditionsRejectGeneratedUpdatesForDifferentTable() throws Exception
{
String cf = "cf" + System.nanoTime();
try
{
setupTableWithTrigger(cf, CrossTableTrigger.class);
String cql = String.format("INSERT INTO %s.%s (k, v1) VALUES (8, 8) IF NOT EXISTS", ksName, cf);
QueryProcessor.process(cql, ConsistencyLevel.ONE);
}
finally
{
assertUpdateNotExecuted(cf, 7);
}
}
示例15: process
import org.apache.cassandra.cql3.QueryProcessor; //导入方法依赖的package包/类
private static UntypedResultSet process(String query, ConsistencyLevel cl) throws RequestExecutionException
{
return QueryProcessor.process(query, cl);
}