在集群中运行storm,不会调用cleanup

nc1teljy  于 2021-06-24  发布在  Storm
关注(0)|答案(2)|浏览(423)

我在群集上运行的storm topology有以下代码:

TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word-reader", new WordReader());
builder.setBolt("word-normalizer", new WordNormalizer())
        .shuffleGrouping("word-reader");
builder.setBolt("word-counter", new WordCounter()).fieldsGrouping(
        "word-normalizer", new Fields("word"));
Config conf = new Config();
conf.put("wordsFile", args[0]);
conf.setDebug(false);
conf.put(Config.TOPOLOGY_MAX_SPOUT_PENDING, 1);
try {
    StormSubmitter.submitTopology("Test-topology", conf,
            builder.createTopology());
} catch (AlreadyAliveException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (InvalidTopologyException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

当我调试它时,下面 cleanup() 方法未在类中运行 WordCounter ...

@Override
public void cleanup() {
    System.out.println("-- Word Counter --");
}

…拓扑结构还没有运行完。

xkftehaa

xkftehaa1#

清理()
在本地模式下调用 shutdown() 你的 localcluster . 但不是在生产集群上 storm kill 执行或从nimbus服务器中删除(从不在生产集群上调用cleanup,仅在本地模式下调用)

// Keep commented if submitting to production cluster, since no
        // automatic shutdown is required on production cluster
        try {
            // Runs for specified number of ms after submitting topology on
            // local cluster and then resumes itself and shutdowns the
            // local cluster
            Thread.sleep(10000);
            objOfLocalCluster.shutdown();
        } catch (InterruptedException e) {
            // Prints a stack trace for this Throwable object on the error
            // output stream..
            e.printStackTrace();
        }

有关更多详细信息:请转到此文档
同样的事情也发生在 close() 此外(这是喷口)更多的细节,在这里检查

cnjp1d6j

cnjp1d6j2#

不在集群上调用清理。只是本地模式
http://groups.google.com/group/storm-user/browse_thread/thread/1a7b4998e6599f83/9683ed2b34e2c027?hl=en&lnk=gst&q=clean+up#9683ed2b34e2c027

相关问题