美文网首页
storm 多语言支持实践

storm 多语言支持实践

作者: wpb | 来源:发表于2017-12-20 15:58 被阅读0次

原理

  • shell bolt 将数据和命令序列化成 json 后输出到shell 进程中,shell 进程接收 json 解析后将结果输出到 stdout 中,shell bolt 获取 stdout 的输出进行解析然后调用相应的 api 进行后续操作(emit,ack,fail 等)
  • 相关协议见:http://storm.apache.org/releases/1.1.1/Multilang-protocol.html

实现:

  • SimpleShellBolt
public class SimpleShellBolt extends ShellBolt implements IRichBolt {

    public SimpleShellBolt() {
        // 划重点:此处注意传参的方式 不要写成一个 string, 比如"sh start.sh"
        // start.sh 作用是对二进制文件 加执行权限后进行调用,否则会提示没执行权限
        super("sh", "start.sh");

    }

    @Override
    public void declareOutputFields(OutputFieldsDeclarer declarer) {
        declarer.declare(new Fields("word"));
    }

    @Override
    public Map<String, Object> getComponentConfiguration() {
        return null;
    }
}
  • shell 脚本
    • shell 脚本需要放置到 src/main/resources/resources 目录中
    • submit 时 storm 会将 jar 包中的 resources 目录拷贝到 storm 工作目录下的resources 目录下(比如:storm-local/supervisor/stormdist/kafka-2-shell-topic-consumer-38-1513754394/resources/)
    • shell bolt 运行 shell 进程时会 cd 到storm 工作目录下的resources进行启动

踩过的坑

  • 使用的 storm cpp 程序中对 heart beat 的判断不准(估计是 shellbolt 代码升级所致)导致抛出『Anchored onto * after ack/fail』 的异常

    vim https://github.com/honeyligo/StormCpp/blob/master/public/Storm.h
    bool IsHeartbeatTuple()
          {
              // if (this->_task == -1 && this->_stream.compare("__heartbeat") == 0)
              if (this->_stream.compare("__heartbeat") == 0)
                  return true;
              return false;
          }
    
  • shellbolt 调用 shell 命令时遇到 no such file 的异常

    • 原因1.:二进制和脚本放在src/main/resources/ 打包后不会上传到集群中,解决方案为放到src/main/resources/resources目录下
    • 原因2:使用 super("sh start.sh"); 整个字符串是作为一个文件路径进行查找的,实际应为 super("sh", "start.sh");

示例项目

https://gitee.com/wangpeibin/storm-cpp-integration

相关文章

  • storm 多语言支持实践

    原理 shell bolt 将数据和命令序列化成 json 后输出到shell 进程中,shell 进程接收 js...

  • Storm 多语言支持之ShellBolt

    由于使用go语言实现storm的拓扑结构,因此使用go实现了spout和bolt,运行时出现如下问题。 Cause...

  • [Kafka]+Storm+HDFS

    简单之美 | Kafka+Storm+HDFS整合实践http://shiyanjun.cn/archives/9...

  • Storm入门

    Storm 基本介绍 什么是 Storm 首先Storm是Apache顶级项目之一Storm 官网 Storm 是...

  • java大数据之storm

    一、Storm简介 1.1 Storm是什么 Apache Storm(http://storm.apache.o...

  • Storm+Kafka的实践

    环境 storm 1.2.1 kafka 0.10.2.2 eclipse maven依赖 Storm写入到kaf...

  • Apache Storm

    Apache Storm Apache Storm Use Cases Real Time Storm Proje...

  • Storm 性能优化

    目录 场景假设 调优步骤和方法 Storm 的部分特性 Storm 并行度 Storm 消息机制 Storm UI...

  • Storm(三) storm-starter

    原文链接storm-starter storm-starter就是Storm工程里边一个专门用来学习使用Storm...

  • storm 启动 uimbus ui supervisor卡死解

    storm uimbus执行以后,卡死,jps中有nimbus,如下图 storm ui 、storm super...

网友评论

      本文标题:storm 多语言支持实践

      本文链接:https://www.haomeiwen.com/subject/kvigwxtx.html