ShellBolt - 锚定在""在确认/失败后

时间:2015-05-06 09:21:01

标签: java apache-storm

我的shellbolt有问题,它使用带有multilang模块的cpp螺栓。这个因为shellBolt的属性" _inputs"为空并调用下一个运行时异常:"在ack / fail"之后锚定到#Anchor上

这是错误:

  

错误backtype.storm.task.ShellBolt - 暂停过程:ShellBolt死了。   java.lang.RuntimeException:在ack / fail之后锚定到-2767654327142912901       at backtype.storm.task.ShellBolt.handleEmit(ShellBolt.java:198)~ [storm-core-0.9.4.jar:0.9.4]       at backtype.storm.task.ShellBolt.access $ 1300(ShellBolt.java:69)〜[storm-core-0.9.4.jar:0.9.4]       在backtype.storm.task.ShellBolt $ BoltReaderRunnable.run(ShellBolt.java:335)〜[storm-core-0.9.4.jar:0.9.4]       在java.lang.Thread.run(Thread.java:745)[na:1.7.0_67]   19630 [Thread-31 -__ system] INFO backtype.storm.util - 异步循环中断!

日志:http://pastebin.com/pG9mHt8X

这是我的Cpp ShellBolt:

public class AppCppStorm {
public static class CppStorm extends ShellBolt implements IRichBolt {

    public CppStorm()
    {
        super("/home/cloudera/IdeaProjects/using_storm/src/main/cpp/test");
    }

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

    @Override
    public Map<String, Object> getComponentConfiguration() {
        return null;
    }
}

public static void main(String[] args) throws Exception {

        TopologyBuilder builder = new TopologyBuilder();

        builder.setSpout("spout", new RandomSentenceSpout(), 5);

        builder.setBolt("split", new SplitSentence(), 8).shuffleGrouping("spout");
        builder.setBolt("count", new WordCount(), 12).fieldsGrouping("split", new Fields("word"));

        Config conf = new Config();
        conf.setDebug(true);


        if (args != null && args.length > 0) {
            conf.setNumWorkers(3);

            StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
        }
        else {
            conf.setMaxTaskParallelism(3);
            conf.setNumWorkers(3);

            LocalCluster cluster = new LocalCluster();
            cluster.submitTopology("word-count", conf, builder.createTopology());

            Thread.sleep(10000);

            cluster.shutdown();
        }
    }
}

我使用了风暴0.9.4,我认为我的错误与下一个报告的错误相同:https://issues.apache.org/jira/browse/STORM-531

如果有人可以帮助我,我会很感激。

1 个答案:

答案 0 :(得分:0)

我解决了我的错误,因为0.9.3风暴版本,我们必须在收到心跳元组时调用bolt synchronize方法。 例如:

class Tuple
{
    private:
        // ...
        int _id;
        std::string _stream;
    public:
        // ...
        bool is_heartbeat_tuple()
        {
            if (this->_id == -1 && this->_stream.compare("__heartbeat") == 0)
                return true;
            return false;
        }
}
class Bolt
{
    public:
        // ...
        void Run()
        {
            Mode = BOLT;
            std::pair<Json::Value, Json::Value> conf_context = InitComponent();
            Initialize(conf_context.first, conf_context.second);
            while(1)
            {
                Tuple tuple = ReadTuple();
                Anchor_tuple = &tuple;
                if (tuple.is_heartbeat_tuple())
                    sync();
                else
                {
                    Process(tuple);
                    Ack(tuple.GetID());
                }
            }
        }
}