Storm thrift获取性能数据报错及解决

现象

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

Traceback (most recent call last):
  File "/home/frankyao/git/StormMetrics/main.py", line 31, in <module>
    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:python

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

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

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

解决方案

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

    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.patchbootstrap

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

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

    thrift --gen py storm.thrift

顺便想到的

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

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

相关文章
相关标签/搜索