在本地模式下运行Apache Storm连接错误

时间:2019-05-18 14:08:42

标签: java multithreading apache apache-storm executorservice

编辑:所以当我增加睡眠时间但仍然出现连接/超时错误时,此问题已“解决”

59297 [Thread-14] ERROR o.a.s.d.s.ReadClusterState - Failed to Sync Supervisor

这是我的自定义拓扑:

public class MyTopology {
    public static void main(String[] args) {
        TopologyBuilder builder = new TopologyBuilder();
        builder.setSpout("NameSpout", new NameSpout());
        builder.setBolt("NameBolt", new MyBolt()).shuffleGrouping("NameSpout");

        Config config = new Config();
        config.setDebug(true);
        config.setNumWorkers(1);

        LocalCluster cluster = new LocalCluster();

        try {

            cluster.submitTopology("TryingOne", config, builder.createTopology());
            Thread.sleep(10000);
        } catch (Exception e) {
            e.printStackTrace();

        } finally {
            cluster.shutdown();
        }

    }

}

1 个答案:

答案 0 :(得分:1)

是的,LocalCluster会照顾好它。使用LocalCluster时,您不应运行自己的Zookeeper服务器。

为了排除运行环境的问题,请尝试签出并运行此拓扑https://github.com/apache/storm/blob/v1.2.2/examples/storm-starter/src/jvm/org/apache/storm/starter/ExclamationTopology.java

如果有效,那么您的项目配置将有问题。如果没有,那么您所处的环境可能有问题。