>
> It looks like you need to move the timer to the prepare method.
> That thread is running in JVM you used to submit to the cluster.
> Moving it to prepare will set it up in the worker.


Thanks, moving the timer to the *prepare* method solved it.
I didn't know that the constructor of a bolt is executed within a different
JVM than the worker.

Thank you very much!

2014-10-29 16:51 GMT+01:00 Martin Illecker <[email protected]>:

> Hello!
>
> I have tried to reimplement the WordCount example [1].
> Since the *cleanup* method is not guaranteed and not executed on a
> cluster [2], I tried to use a *TimerTask* which should print out the
> wordcount stats.
>
> But the inner class implementation of the *TimerTask* [3] is not able to
> see the updated *HashMap* values from the *execute* method.
> The output of the *TimerTask* looks as follows:
>
> storm jar WordCount.jar
> at.illecker.storm.examples.wordcount.WordCountTopology
> 253  [Timer-0] INFO
>  at.illecker.storm.examples.wordcount.ReportWordCountBolt - WordCounts: 0
> 458  [main] INFO  backtype.storm.StormSubmitter - Jar not uploaded to
> master yet. Submitting jar...
> 462  [main] INFO  backtype.storm.StormSubmitter - Uploading topology jar
> WordCount.jar to assigned location:
> storm-local/nimbus/inbox/stormjar-e74db7f7-098b-4757-b11d-55f3ed6d0d86.jar
> 468  [main] INFO  backtype.storm.StormSubmitter - Successfully uploaded
> topology jar to assigned location:
> storm-local/nimbus/inbox/stormjar-e74db7f7-098b-4757-b11d-55f3ed6d0d86.jar
> 468  [main] INFO  backtype.storm.StormSubmitter - Submitting topology
> word-count-topology in distributed mode with conf {}
> 500  [main] INFO  backtype.storm.StormSubmitter - Finished submitting
> topology: word-count-topology
> To kill the topology run: storm kill word-count-topology
> 1251 [Timer-0] INFO
>  at.illecker.storm.examples.wordcount.ReportWordCountBolt - WordCounts: 0
> 2255 [Timer-0] INFO
>  at.illecker.storm.examples.wordcount.ReportWordCountBolt - WordCounts: 0
> 3259 [Timer-0] INFO
>  at.illecker.storm.examples.wordcount.ReportWordCountBolt - WordCounts: 0
> 4263 [Timer-0] INFO
>  at.illecker.storm.examples.wordcount.ReportWordCountBolt - WordCounts: 0
> 5265 [Timer-0] INFO
>  at.illecker.storm.examples.wordcount.ReportWordCountBolt - WordCounts: 0
> 6267 [Timer-0] INFO
>  at.illecker.storm.examples.wordcount.ReportWordCountBolt - WordCounts: 0
>
> I'm sure the tuples are added into the *HashMap* but the *TimerTask*
> thread does not see it.
> How can I solve this under Storm?
> (e.g., a monitoring thread which prints out statistics within a single
> bolt with globalGrouping)
>
> Thanks for your help!
>
> Martin
>
> [1] https://github.com/millecker/storm-apps/tree/master/wordcount
> [2] https://groups.google.com/forum/#!topic/storm-user/GntJmOZZn4M
> [3]
> https://github.com/millecker/storm-apps/blob/master/wordcount/src/at/illecker/storm/examples/wordcount/ReportWordCountBolt.java#L68-83
> [4]
> https://github.com/millecker/storm-apps/blob/master/wordcount/src/at/illecker/storm/examples/wordcount/ReportWordCountBolt.java#L63
>
>
> $ git clone https://github.com/millecker/storm-apps.git
> $ cd storm-apps/wordcount/
> $ ant run-cpu
>

Reply via email to