Storm thrift获取性能数据报错及解决
admin
2023-07-31 01:49:13
0

现象

我们想通过Storm提供的thrift接口来获取Toplogy的性能数据,比如emiited了多少,延迟是多少之类。但在使用Python开发过程中,发现getClusterInfo这个方法,会报错,thrift版本0.7,Storm版本为0.9.0.1,错误如下:

Traceback (most recent call last):
  File \"/home/frankyao/git/StormMetrics/main.py\", line 31, in 
    topology_info = nimbus.getTopologyInfo(topology.id)
  File \"./gen-py/storm/Nimbus.py\", line 584, in getTopologyInfo
    return self.recv_getTopologyInfo()
  File \"./gen-py/storm/Nimbus.py\", line 602, in recv_getTopologyInfo
    result.read(self._iprot)
  File \"./gen-py/storm/Nimbus.py\", line 2830, in read
    self.success.read(iprot)
  File \"./gen-py/storm/ttypes.py\", line 2724, in read
    _elem265.read(iprot)
  File \"./gen-py/storm/ttypes.py\", line 2600, in read
    self.stats.read(iprot)
  File \"./gen-py/storm/ttypes.py\", line 2391, in read
    self.specific.read(iprot)
  File \"./gen-py/storm/ttypes.py\", line 2280, in read
    self.bolt.read(iprot)
  File \"./gen-py/storm/ttypes.py\", line 1979, in read
    _val128[_key134] = _val135
TypeError: unhashable instance

使用thrift 0.7还是失败

这个问题看上去是thrift的问题,在Storm的源码中的storm-core/src/getthrift.sh里,发现应该使用thrift 0.7:

thrift7 --gen java:beans,hashcode,nocamel --gen py:utf8strings storm.thrift

随后我安装thrift 0.7,发现还是不行,依然报上面的错。

在查了Google后,发现有一个大哥在今年二月也碰到这个问题,并且解决了。需要使用storm提供的thrift,并且要打上一个thrift的patch。

解决方案

  1. 使用storm提供的thrift:https://github.com/nathanmarz/thrift/archive/storm.zip

    wget https://github.com/nathanmarz/thrift/archive/storm.zip
    unzip storm.zip
    cd thrift-storm
    
  2. 打上这个patch:https://issues.apache.org/jira/secure/attachment/12501771/thrift-1382.patch

    wget https://issues.apache.org/jira/secure/attachment/12501771/thrift-1382.patch
    patch -p0 < thrift-1382.patch
    
  3. 安装thrift-storm

    sudo ./bootstrap.sh
    sudo ./configure
    sudo make
    sudo make install
    
  4. 重新使用thrift生成python包

    thrift --gen py storm.thrift
    

顺便想到的

我想起了Storm在以前还依赖zeromq的时候,是zeromq还是jzmq来着,不能使用官方版本,要使用storm提供的一个特定版本。这个问题坑了很多人,在使用netty后,这个问题已经解决。

Storm要获取这些运行时的性能数据,一定要使用thrift(或者抓取ui用dom分析,但这个非常麻烦),这个问题也是非常的坑爹。

相关内容

热门资讯

Mobi、epub格式电子书如... 在wps里全局设置里有一个文件关联,打开,勾选电子书文件选项就可以了。
定时清理删除C:\Progra... C:\Program Files (x86)下面很多scoped_dir开头的文件夹 写个批处理 定...
500 行 Python 代码... 语法分析器描述了一个句子的语法结构,用来帮助其他的应用进行推理。自然语言引入了很多意外的歧义,以我们...
scoped_dir32_70... 一台虚拟机C盘总是莫名奇妙的空间用完,导致很多软件没法再运行。经过仔细检查发现是C:\Program...
65536是2的几次方 计算2... 65536是2的16次方:65536=2⁶ 65536是256的2次方:65536=256 6553...
小程序支付时提示:appid和... [Q]小程序支付时提示:appid和mch_id不匹配 [A]小程序和微信支付没有进行关联,访问“小...
pycparser 是一个用... `pycparser` 是一个用 Python 编写的 C 语言解析器。它可以用来解析 C 代码并构...
微信小程序使用slider实现... 众所周知哈,微信小程序里面的音频播放是没有进度条的,但最近有个项目呢,客户要求音频要有进度条控制,所...
Apache Doris 2.... 亲爱的社区小伙伴们,我们很高兴地向大家宣布,Apache Doris 2.0.0 版本已于...
python清除字符串里非数字... 本文实例讲述了python清除字符串里非数字字符的方法。分享给大家供大家参考。具体如下: impor...