• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java QueryMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.cassandra.transport.messages.QueryMessage的典型用法代码示例。如果您正苦于以下问题:Java QueryMessage类的具体用法?Java QueryMessage怎么用?Java QueryMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



QueryMessage类属于org.apache.cassandra.transport.messages包,在下文中一共展示了QueryMessage类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testLargeBatchWithProtoV4

import org.apache.cassandra.transport.messages.QueryMessage; //导入依赖的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());
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:ClientWarningsTest.java


示例2: testLargeBatchWithProtoV2

import org.apache.cassandra.transport.messages.QueryMessage; //导入依赖的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());
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:ClientWarningsTest.java


示例3: testMessagePayload

import org.apache.cassandra.transport.messages.QueryMessage; //导入依赖的package包/类
@Test
public void testMessagePayload() throws Throwable
{
    QueryHandler queryHandler = (QueryHandler) cqlQueryHandlerField.get(null);
    cqlQueryHandlerField.set(null, new TestQueryHandler());
    try
    {
        requireNetwork();

        Assert.assertSame(TestQueryHandler.class, ClientState.getCQLQueryHandler().getClass());

        SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort);
        try
        {
            client.connect(false);

            Map<String, ByteBuffer> reqMap;
            Map<String, ByteBuffer> respMap;

            QueryMessage queryMessage = new QueryMessage(
                                                        "CREATE TABLE " + KEYSPACE + ".atable (pk int PRIMARY KEY, v text)",
                                                        QueryOptions.DEFAULT
            );
            PrepareMessage prepareMessage = new PrepareMessage("SELECT * FROM " + KEYSPACE + ".atable");

            reqMap = Collections.singletonMap("foo", bytes(42));
            responsePayload = respMap = Collections.singletonMap("bar", bytes(42));
            queryMessage.setCustomPayload(reqMap);
            Message.Response queryResponse = client.execute(queryMessage);
            payloadEquals(reqMap, requestPayload);
            payloadEquals(respMap, queryResponse.getCustomPayload());

            reqMap = Collections.singletonMap("foo", bytes(43));
            responsePayload = respMap = Collections.singletonMap("bar", bytes(43));
            prepareMessage.setCustomPayload(reqMap);
            ResultMessage.Prepared prepareResponse = (ResultMessage.Prepared) client.execute(prepareMessage);
            payloadEquals(reqMap, requestPayload);
            payloadEquals(respMap, prepareResponse.getCustomPayload());

            ExecuteMessage executeMessage = new ExecuteMessage(prepareResponse.statementId, QueryOptions.DEFAULT);
            reqMap = Collections.singletonMap("foo", bytes(44));
            responsePayload = respMap = Collections.singletonMap("bar", bytes(44));
            executeMessage.setCustomPayload(reqMap);
            Message.Response executeResponse = client.execute(executeMessage);
            payloadEquals(reqMap, requestPayload);
            payloadEquals(respMap, executeResponse.getCustomPayload());

            BatchMessage batchMessage = new BatchMessage(BatchStatement.Type.UNLOGGED,
                                                         Collections.<Object>singletonList("INSERT INTO " + KEYSPACE + ".atable (pk,v) VALUES (1, 'foo')"),
                                                         Collections.singletonList(Collections.<ByteBuffer>emptyList()),
                                                         QueryOptions.DEFAULT);
            reqMap = Collections.singletonMap("foo", bytes(45));
            responsePayload = respMap = Collections.singletonMap("bar", bytes(45));
            batchMessage.setCustomPayload(reqMap);
            Message.Response batchResponse = client.execute(batchMessage);
            payloadEquals(reqMap, requestPayload);
            payloadEquals(respMap, batchResponse.getCustomPayload());
        }
        finally
        {
            client.close();
        }
    }
    finally
    {
        cqlQueryHandlerField.set(null, queryHandler);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:69,代码来源:MessagePayloadTest.java



注:本文中的org.apache.cassandra.transport.messages.QueryMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GenericTypeValidator类代码示例发布时间:2022-05-22
下一篇:
Java TreeClassChooserFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap