【问题标题】:Access Infinispan Server using HotRod C++ throws Exception使用 HotRod C++ 访问 Infinispan 服务器抛出异常
【发布时间】:2016-05-24 08:47:39
【问题描述】:

我正在尝试使用 C++ 中的 HotRod 库访问 Infinispan 服务器,因为我不熟悉 Java,但我遇到了异常并且不知道如何继续。

源码为:

#include "infinispan/hotrod/ConfigurationBuilder.h"
#include "infinispan/hotrod/RemoteCacheManager.h"
#include "infinispan/hotrod/RemoteCache.h"
#include <iostream>
#include <string>

int main(int argc, char **argv) {
        infinispan::hotrod::ConfigurationBuilder cb;
        cb.addServer().host("192.168.1.1").port(11222);
        infinispan::hotrod::RemoteCacheManager cm(cb.build());
        infinispan::hotrod::RemoteCache<std::string, std::string> cache = cm.getCache<std::string, std::string>("dCache");
        cm.start();
        std::cout << cache.size() << std::endl;
        cm.stop();
        return 0;
}

我得到的是:

terminate called after throwing an instance of 'infinispan::hotrod::HotRodClientException'
  what():  scala.MatchError: 24 (of class java.lang.Byte)
Aborted

ps。 GDB回溯表明错误发生在std::cout &lt;&lt; cache.size() &lt;&lt; std::endl;这一行。

【问题讨论】:

  • 这看起来像是协议不匹配。您使用什么版本的客户端和服务器?请检查服务器日志,异常应该用完整的堆栈跟踪记录在那里。
  • @Flavius 客户端是 8.0.0.CR2,服务器是 6.0.0.Final。我检查了服务器日志,得到了很多东西,比如16:28:55,420 ERROR [org.infinispan.server.hotrod.HotRodDecoder] (HotRodServerWorker-223) ISPN005003: Exception reported: org.infinispan.server.hotrod.RequestParsingException: Unable to parse headerERROR [org.infinispan.server.hotrod.HotRodDecoder] (HotRodServerWorker-226) ISPN005009: Unexpected error before any request parameters read: scala.MatchError: 24 (of class java.lang.Byte)
  • 服务器日志是否说明客户端使用的协议版本? C++客户端应该只知道1.2及以下,但我可能错了。

标签: c++ infinispan


【解决方案1】:

C++ 客户端版本 8.0.0 默认使用 Hotrod 协议 VERSION_24,这对于 Infinispan 6.0.0 来说太新了。

尝试以这种方式配置 VERSION_13:

cb.addServer().host("192.168.1.1").port(11222).protocolVersion(Configuration::PROTOCOL_VERSION_13);

【讨论】:

    【解决方案2】:

    我不知道 HotRod C++,我不知道这是否是您的异常的原因,但是,根据 this page
    RemoteCacheManager 构造函数,默认启动管理器;所以,下面的cm.start() 这是第二次开始(?)。

    this example我看到管理器是在没有启动的情况下创建的,所以...

    建议:试试

    infinispan::hotrod::RemoteCacheManager cm(cb.build(), false);
    

    【讨论】:

    • 我已经修改了那部分,但没有任何变化。
    猜你喜欢
    • 2012-09-07
    • 1970-01-01
    • 1970-01-01
    • 2019-04-10
    • 2023-03-06
    • 1970-01-01
    • 2017-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多