咱們想經過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的問題,在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
使用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
打上這個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
安裝thrift-stormdom
sudo ./bootstrap.sh sudo ./configure sudo make sudo make install
從新使用thrift生成python包性能
thrift --gen py storm.thrift
我想起了Storm在之前還依賴zeromq的時候,是zeromq仍是jzmq來着,不能使用官方版本,要使用storm提供的一個特定版本。這個問題坑了不少人,在使用netty後,這個問題已經解決。ui
Storm要獲取這些運行時的性能數據,必定要使用thrift(或者抓取ui用dom分析,但這個很是麻煩),這個問題也是很是的坑爹。netty