2

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

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

...并且拓扑没有完成运行。

4

2 回答 2

3

清理(​​)

当您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();
        } 

有关更多详细信息:转到此文档


同样的事情close()也发生在(用于喷口)有关该检查的更多详细信息here

于 2013-08-30T12:01:49.823 回答
0

不在集群上调用清理。只是本地模式

http://groups.google.com/group/storm-user/browse_thread/thread/1a7b4998e6599f83/9683ed2b34e2c027?hl=en&lnk=gst&q=clean+up#9683ed2b34e2c027

于 2013-05-13T00:14:11.310 回答