本文整理汇总了Java中org.apache.cassandra.transport.SimpleClient类的典型用法代码示例。如果您正苦于以下问题:Java SimpleClient类的具体用法?Java SimpleClient怎么用?Java SimpleClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleClient类属于org.apache.cassandra.transport包,在下文中一共展示了SimpleClient类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
public void run(final SimpleClient client) throws IOException
{
run(new CQLQueryExecutor()
{
public boolean execute(String cqlQuery, List<String> queryParams) throws Exception
{
ResultMessage result = null;
if (session.usePreparedStatements())
{
byte[] stmntId = getPreparedStatement(client, cqlQuery);
result = client.executePrepared(stmntId, queryParamsAsByteBuffer(queryParams), ThriftConversion.fromThrift(session.getConsistencyLevel()));
}
else
{
String formattedQuery = formatCqlQuery(cqlQuery, queryParams);
result = client.execute(formattedQuery, ThriftConversion.fromThrift(session.getConsistencyLevel()));
}
return validateNativeResult(result);
}
});
}
示例2: getSimpleNativeClient
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
public SimpleClient getSimpleNativeClient()
{
try
{
String currentNode = node.randomNode();
SimpleClient client = new SimpleClient(currentNode, port.nativePort);
client.connect(false);
client.execute("USE \"" + schema.keyspace + "\";", org.apache.cassandra.db.ConsistencyLevel.ONE);
return client;
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage());
}
}
示例3: getNativeClient
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
public SimpleClient getNativeClient()
{
try
{
String currentNode = nodes[Stress.randomizer.nextInt(nodes.length)];
SimpleClient client = new SimpleClient(currentNode, 9042);
client.connect(false);
client.execute("USE \"Keyspace1\";", org.apache.cassandra.db.ConsistencyLevel.ONE);
return client;
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage());
}
}
示例4: getPreparedStatement
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
protected static byte[] getPreparedStatement(SimpleClient client, String cqlQuery) throws Exception
{
byte[] statementId = preparedStatementsNative.get(cqlQuery.hashCode());
if (statementId == null)
{
statementId = client.prepare(cqlQuery).statementId.bytes;
preparedStatementsNative.put(cqlQuery.hashCode(), statementId);
}
return statementId;
}
示例5: testLargeBatchWithProtoV4
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
@Test
public void testLargeBatchWithProtoV4() throws Exception
{
createTable("CREATE TABLE %s (pk int PRIMARY KEY, v text)");
try (SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort, Server.VERSION_4))
{
client.connect(false);
QueryMessage query = new QueryMessage(createBatchStatement(DatabaseDescriptor.getBatchSizeWarnThreshold()), QueryOptions.DEFAULT);
Message.Response resp = client.execute(query);
assertEquals(1, resp.getWarnings().size());
}
}
示例6: testLargeBatchWithProtoV2
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
@Test
public void testLargeBatchWithProtoV2() throws Exception
{
createTable("CREATE TABLE %s (pk int PRIMARY KEY, v text)");
try (SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort, Server.VERSION_3))
{
client.connect(false);
QueryMessage query = new QueryMessage(createBatchStatement(DatabaseDescriptor.getBatchSizeWarnThreshold()), QueryOptions.DEFAULT);
Message.Response resp = client.execute(query);
assertNull(resp.getWarnings());
}
}
示例7: getSimpleNativeClient
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
public SimpleClient getSimpleNativeClient()
{
try
{
String currentNode = node.randomNode();
SimpleClient client = new SimpleClient(currentNode, port.nativePort);
client.connect(false);
client.execute("USE \"Keyspace1\";", org.apache.cassandra.db.ConsistencyLevel.ONE);
return client;
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage());
}
}
示例8: run
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
@Override
public void run(SimpleClient client) throws IOException
{
run(wrap(client));
}
示例9: wrap
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
public ClientWrapper wrap(SimpleClient client)
{
return new SimpleClientWrapper(client);
}
示例10: SimpleClientWrapper
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
private SimpleClientWrapper(SimpleClient client)
{
this.client = client;
}
示例11: run
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
@Override
public void run(SimpleClient client) throws IOException
{
throw new UnsupportedOperationException();
}
示例12: run
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
public void run(SimpleClient client) throws IOException {
throw new UnsupportedOperationException();
}
示例13: run
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
public void run()
{
operations.initTimers();
try
{
SimpleClient sclient = null;
ThriftClient tclient = null;
JavaDriverClient jclient = null;
switch (settings.mode.api)
{
case JAVA_DRIVER_NATIVE:
jclient = settings.getJavaDriverClient();
break;
case SIMPLE_NATIVE:
sclient = settings.getSimpleNativeClient();
break;
case THRIFT:
case THRIFT_SMART:
tclient = settings.getThriftClient();
break;
default:
throw new IllegalStateException();
}
while (true)
{
Operation op = operations.next();
if (!op.ready(workManager, rateLimiter))
break;
try
{
switch (settings.mode.api)
{
case JAVA_DRIVER_NATIVE:
op.run(jclient);
break;
case SIMPLE_NATIVE:
op.run(sclient);
break;
case THRIFT:
case THRIFT_SMART:
default:
op.run(tclient);
}
}
catch (Exception e)
{
if (output == null)
{
System.err.println(e.getMessage());
success = false;
System.exit(-1);
}
e.printStackTrace(output);
success = false;
workManager.stop();
metrics.cancel();
return;
}
}
}
finally
{
done.countDown();
operations.closeTimers();
}
}
示例14: run
import org.apache.cassandra.transport.SimpleClient; //导入依赖的package包/类
public void run(SimpleClient client) throws IOException
{
throw new RuntimeException("Multiget is not implemented for CQL");
}