本文整理汇总了Java中org.apache.cassandra.thrift.InvalidRequestException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidRequestException类的具体用法?Java InvalidRequestException怎么用?Java InvalidRequestException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidRequestException类属于org.apache.cassandra.thrift包,在下文中一共展示了InvalidRequestException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SingleKeyTableTest
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
private void SingleKeyTableTest(String initialQuery)
throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException
{
pig.setBatchOn();
pig.registerQuery(initialQuery);
pig.registerQuery("insertformat= FOREACH moretestvalues GENERATE TOTUPLE(TOTUPLE('a',x)),TOTUPLE(y);");
pig.registerQuery("STORE insertformat INTO 'cql://cql3ks/test?" + defaultParameters + nativeParameters + "&output_query=UPDATE+cql3ks.test+set+b+%3D+%3F' USING CqlNativeStorage();");
pig.executeBatch();
//(5,5)
//(6,6)
//(4,4)
//(2,2)
//(3,3)
//(1,1)
//input_cql=select * from test where token(a) > ? and token(a) <= ?
pig.registerQuery("result= LOAD 'cql://cql3ks/test?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20test%20where%20token(a)%20%3E%20%3F%20and%20token(a)%20%3C%3D%20%3F' USING CqlNativeStorage();");
Iterator<Tuple> it = pig.openIterator("result");
while (it.hasNext()) {
Tuple t = it.next();
Assert.assertEquals(t.get(0), t.get(1));
}
}
示例2: testCassandraStorageCounterCF
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
@Test
public void testCassandraStorageCounterCF() throws IOException, ClassNotFoundException, TException, TimedOutException, NotFoundException, InvalidRequestException, NoSuchFieldException, UnavailableException, IllegalAccessException, InstantiationException, AuthenticationException, AuthorizationException
{
pig.registerQuery("rows = LOAD 'cassandra://thriftKs/SomeApp?" + defaultParameters + "' USING CassandraStorage();");
//Test counter column family support
pig.registerQuery("CC = load 'cassandra://thriftKs/CC?" + defaultParameters + "' using CassandraStorage();");
pig.registerQuery("total_hits = foreach CC generate key, SUM(columns.value);");
//(chuck,4)
Iterator<Tuple> it = pig.openIterator("total_hits");
if (it.hasNext()) {
Tuple t = it.next();
Assert.assertEquals(t.get(0), "chuck");
Assert.assertEquals(t.get(1), 4l);
}
}
示例3: deduceExceptionMessage
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
private static String deduceExceptionMessage(Throwable t)
{
StringBuilder msg = new StringBuilder("Details: ");
if ( t instanceof UnavailableException )
msg.append("You do not have enough nodes up to handle the specified consistency level");
else if ( t instanceof TimedOutException )
msg.append("Request timed out - server load may be too high, or you may be requesting too many rows for a single operation");
else if ( t instanceof InvalidRequestException )
msg.append("The request was not properly formatted ").append(((InvalidRequestException) t).getWhy());
else if ( t instanceof SchemaDisagreementException)
msg.append("Schema versions are out of sync");
else if ( t instanceof TException )
msg.append("General Thrift Exception, ensure Apache Cassandra is running and all necessary ports are accessible");
else
msg.append("n/a");
return msg.toString();
}
示例4: initialSetup
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
public void initialSetup() throws NotFoundException, InvalidRequestException, NoSuchFieldException, UnavailableException, IllegalAccessException, InstantiationException, ClassNotFoundException, TimedOutException, URISyntaxException, IOException, TException {
context = new AstyanaxContext.Builder()
.forCluster(_cluster) //"Test Cluster"
.forKeyspace(_keyspaceName)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl(_pool).setPort(_port).setMaxConnsPerHost(1).setSeeds(_host+":"+_port))
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
GlobalVariables.KS_AST = context.getClient();
CF_AST_BACK = ColumnFamily
.newColumnFamily(_columnFamilyNameBack,
StringSerializer.get(), // Key Serializer
StringSerializer.get()) ; // Column Serializer
CF_AST_DYNA = ColumnFamily
.newColumnFamily(_columnFamilyNameDyna,
StringSerializer.get(), // Key Serializer
StringSerializer.get()) ; // Column Serializer
this.cliSchema();
}
示例5: testCqlStorageCompositeKeyTable
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
@Test
public void testCqlStorageCompositeKeyTable()
throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException
{
pig.setBatchOn();
pig.registerQuery("moredata= LOAD 'cql://cql3ks/compmore?" + defaultParameters + "' USING CqlStorage();");
pig.registerQuery("insertformat = FOREACH moredata GENERATE TOTUPLE (TOTUPLE('a',x),TOTUPLE('b',y), TOTUPLE('c',z)),TOTUPLE(data);");
pig.registerQuery("STORE insertformat INTO 'cql://cql3ks/compotable?" + defaultParameters + "&output_query=UPDATE%20cql3ks.compotable%20SET%20d%20%3D%20%3F' USING CqlStorage();");
pig.executeBatch();
//(5,6,Fix,nomatch)
//(3,3,Three,match)
//(1,1,One,match)
//(2,2,Two,match)
//(7,7,Seven,match)
//(8,8,Eight,match)
//(6,5,Sive,nomatch)
//(4,4,Four,match)
//(9,10,Ninen,nomatch)
pig.registerQuery("result= LOAD 'cql://cql3ks/compotable?" + defaultParameters + "' USING CqlStorage();");
Iterator<Tuple> it = pig.openIterator("result");
if (it.hasNext()) {
Tuple t = it.next();
Assert.assertEquals(t.get(3), "match");
}
}
示例6: testCqlStorageSingleKeyTable
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
@Test
public void testCqlStorageSingleKeyTable()
throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException
{
pig.setBatchOn();
pig.registerQuery("moretestvalues= LOAD 'cql://cql3ks/moredata?" + defaultParameters + "' USING CqlStorage();");
pig.registerQuery("insertformat= FOREACH moretestvalues GENERATE TOTUPLE(TOTUPLE('a',x)),TOTUPLE(y);");
pig.registerQuery("STORE insertformat INTO 'cql://cql3ks/test?" + defaultParameters + "&output_query=UPDATE+cql3ks.test+set+b+%3D+%3F' USING CqlStorage();");
pig.executeBatch();
//(5,5)
//(6,6)
//(4,4)
//(2,2)
//(3,3)
//(1,1)
pig.registerQuery("result= LOAD 'cql://cql3ks/test?" + defaultParameters + "' USING CqlStorage();");
Iterator<Tuple> it = pig.openIterator("result");
if (it.hasNext()) {
Tuple t = it.next();
Assert.assertEquals(t.get(0), t.get(1));
}
}
示例7: dropOldKeyspace
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
private void dropOldKeyspace() throws InvalidRequestException, SchemaDisagreementException, TException {
TTransport tr = new TFramedTransport(new TSocket("localhost", 9160));
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
tr.open();
client.system_drop_keyspace(JANUSGRAPH);
LOGGER.info("DROPPED keyspace janusgraph");
tr.close();
}
示例8: ensureStandardCF
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
public void ensureStandardCF(String cfName) throws InvalidRequestException, TException, UnavailableException, TimedOutException,
SchemaDisagreementException {
KsDef keyspace = getKeyspace(keySpace);
log.info(String.format("Ensuring standard cf:%s", cfName));
for (CfDef cfdef : keyspace.getCf_defs()) {
if (cfdef.getName().equals(cfName)) {
return;
}
}
String cql = "CREATE TABLE %s (KEY text PRIMARY KEY) WITH comparator=text";
executeCQL(String.format(cql, cfName));
}
示例9: getKeyspace
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
private KsDef getKeyspace(String keys) throws InvalidRequestException, TException {
List<KsDef> keyspaces = client.describe_keyspaces();
for (KsDef k : keyspaces) {
if (k.getName().equals(keys)) {
return k;
}
}
return null;
}
示例10: executeCQL
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
protected void executeCQL(String cql) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException {
try {
client.execute_cql_query(ByteBuffer.wrap(cql.getBytes("UTF-8")), Compression.NONE);
} catch (UnsupportedEncodingException e) {
throw new InvalidRequestException("Argument is not in UTF-8 character set");
}
}
示例11: setupDataByCli
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的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.
}
}
示例12: setup
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
@BeforeClass
public static void setup() throws TTransportException, IOException, InterruptedException, ConfigurationException,
AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, CharacterCodingException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException
{
startCassandra();
setupDataByCql(statements);
startHadoopCluster();
}
示例13: testCqlNativeStorageSchema
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
@Test
public void testCqlNativeStorageSchema()
throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException
{
//input_cql=select * from cqltable where token(key1) > ? and token(key1) <= ?
cqlTableSchemaTest("rows = LOAD 'cql://cql3ks/cqltable?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20cqltable%20where%20token(key1)%20%3E%20%3F%20and%20token(key1)%20%3C%3D%20%3F' USING CqlNativeStorage();");
//input_cql=select * from compactcqltable where token(key1) > ? and token(key1) <= ?
compactCqlTableSchemaTest("rows = LOAD 'cql://cql3ks/compactcqltable?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20compactcqltable%20where%20token(key1)%20%3E%20%3F%20and%20token(key1)%20%3C%3D%20%3F' USING CqlNativeStorage();");
}
示例14: testCqlNativeStorageSingleKeyTable
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
@Test
public void testCqlNativeStorageSingleKeyTable()
throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException
{
//input_cql=select * from moredata where token(x) > ? and token(x) <= ?
SingleKeyTableTest("moretestvalues= LOAD 'cql://cql3ks/moredata?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20moredata%20where%20token(x)%20%3E%20%3F%20and%20token(x)%20%3C%3D%20%3F' USING CqlNativeStorage();");
}
示例15: testCqlNativeStorageCompositeKeyTable
import org.apache.cassandra.thrift.InvalidRequestException; //导入依赖的package包/类
@Test
public void testCqlNativeStorageCompositeKeyTable()
throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, SchemaDisagreementException, IOException
{
//input_cql=select * from compmore where token(id) > ? and token(id) <= ?
CompositeKeyTableTest("moredata= LOAD 'cql://cql3ks/compmore?" + defaultParameters + nativeParameters + "&input_cql=select%20*%20from%20compmore%20where%20token(id)%20%3E%20%3F%20and%20token(id)%20%3C%3D%20%3F' USING CqlNativeStorage();");
}