Reputation: 374
I was trying to use a static object in hadoop. This object is both used in map and reduce. My program is :
The test result is, the static object in mapper had been cleaned up before the reducer starts. Moreover, the static objects in reducer seems not identical among different tasktrackers, thus different reducers' result cannot be accumulated.
My question is, how can I use a static object and keep it identical among different tasktrackers.
Upvotes: 1
Views: 1621
Reputation: 12883
By default, each mapper and reducer runs in its own JVM, so obviously statics will not be global across the entire cluster. If you want to accumulate global counts, use Hadoop Counters:
reporter.incrCounter("My custom counters", "my counter", 1);
Upvotes: 3