hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Ulrik S√łttrup <soett...@nbi.dk>
Subject Re: question about Counters
Date Mon, 21 Jul 2008 22:37:37 GMT
Hi,

I use a counter in my reducer to check whether another iteration (of map 
reduce cycle) is necessary. I have a similar declaration as yours.
Then in my main program i have:

***
client.setConf(conf);
RunningJob rj = JobClient.runJob(conf);
Counters cs = rj.getCounters();
long swaps=cs.getCounter(Red.Count.SWAPS);

where Red is the class that defines the reducer and contains the 
enumeration.

Cheers,
Christian

Daniel Yu skrev:
> hi,
>   i defined a counter of my own, and updated it in map method,
>
> protected static enum MyCounter {
>         INPUT_WORDS
>     };
> ...
> public void map(...) {
>   ...
>     reporter.incrCounter(MyCounter.INPUT_WORDS, 1);
> }
>
> and can i fetch the counts later? like in the  run() method after the job is
> finished,
> coz i want to store it as a parameter file for later MR jobs.
>
> looks like the framework will use Counters.getCounter(enum key) to return a
> certain count,
> which can be seen when the JobClient tries to run a job, but in my
> application(outside the
> job running) how can i get the Counters object? my guess is its maintained
> by the framework,
> so user doesnt need to create Counters object in the application.
>
> Thanks.
>
> Daniel
>
>   


Mime
View raw message