本帖最后由 mjjian0 于 2015-4-12 19:55 编辑
六台flume服务器,三台kafka服务器,大概流程是这样:flume采集数据到kafka,然后storm去kafka数据分析,为了做交易耗时统计,采用redis做缓存。
我日志文件的数据格式是这样的:
第一个字段是traceid,第四个字段是status,第五个字段是时间timestamp,在日志文件中同一个traceid的status状态,一定是值为start的在前面。
01 130 10 START 1427857588 com.newtouchone.watchmen.Example#method 01 130 10 CLIENT_SEND 1427857598 com.newtouchone.watchmen.Example#method 01 130 10 SERVER_RECV 1427857607 com.newtouchone.watchmen.Example#method 01 130 10 SERVER_SEND 1427857616 com.newtouchone.watchmen.Example#method 01 130 10 CLIENT_RECV 1427857630 com.newtouchone.watchmen.Example#method 01 130 10 END 1427857637 com.newtouchone.watchmen.Example#method
然后我在一个bolt里面先判断tuple的status值是否为start的,如果为start的则把它放入redis中去,比如key:start_01 value: 1427857588,这里的value是timestamp
接着判断是否为end,如果为end则先从redis中取key为start_01的值,然后和当前tuple的timestamp值计算耗时,但是问题来了,通过压力测试,在这一步从redis取值的时候报空指针异常。我的程序是这样的: 难道status值为END的比值为START的tuple先过bolt????
|