gpt4 book ai didi

java - 在集群中运行 Storm,不会调用清理

转载 作者:行者123 更新时间:2023-12-04 04:59:10 26 4
gpt4 key购买 nike

我有以下 Storm 拓扑代码,我在集群上运行:

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 --");
}

...并且拓扑未完成运行。

最佳答案

cleanup()



当您 shutdown() 在本地模式下被调用您的 localcluster .但在 storm kill 时不在您的生产集群上被执行或从 nimbus 服务器中删除(在生产集群上永远不会调用清理,它只在本地模式下)
        // 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();
}

欲知更多详情:转至此 docs
同样的事情发生在 close() 也(用于喷口)了解有关该支票的更多详细信息 here

关于java - 在集群中运行 Storm,不会调用清理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16354822/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com