Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6820163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:23:33+00:00 2026-05-26T21:23:33+00:00

In my Hadoop reducers , I need to know how many successful map tasks

  • 0

In my Hadoop reducers, I need to know how many successful map tasks were executed in the current job. I’ve come up with the following, which as far as I can tell does NOT work.

    Counter totalMapsCounter = 
        context.getCounter(JobInProgress.Counter.TOTAL_LAUNCHED_MAPS);
    Counter failedMapsCounter = 
        context.getCounter(JobInProgress.Counter.NUM_FAILED_MAPS);
    long nSuccessfulMaps = totalMapsCounter.getValue() - 
                           failedMapsCounter.getValue();

Alternatively, if there’s a good way that I could retrieve (again, from within my reducers) the total number of input splits (not number of files, and not splits for one file, but total splits for the job), that would probably also work. (Assuming my job completes normally, that should be the same number, right?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:23:34+00:00Added an answer on May 26, 2026 at 9:23 pm

    Edit: Looks like it’s not a good practice to retrieve the counters in the map and reduce tasks using Job or JobConf. Here is an alternate approach for passing the summary details from the mapper to the reducer. This approach requires some effort to code, but is doable. It would have been nice if the feature had been part of Hadoop and not required to hand code it. I have requested to put this feature into Hadoop and waiting for the response.


    JobCounter.TOTAL_LAUNCHED_MAPS was retrieved using the below code in the Reducer class with the old MR API.

    private String jobID;
    private long launchedMaps;
    
    public void configure(JobConf jobConf) {
    
        try {
            jobID = jobConf.get("mapred.job.id");
    
            JobClient jobClient = new JobClient(jobConf);
    
            RunningJob job = jobClient.getJob(JobID.forName(jobID));
    
            if (job == null) {
                System.out.println("No job with ID found " + jobID);
            } else {
                Counters counters = job.getCounters();
                launchedMaps = counters.getCounter(JobCounter.TOTAL_LAUNCHED_MAPS);
            }
    
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    

    With the new API, Reducer implementations can access the Configuration for the job via the JobContext#getConfiguration(). The above code can be implemented in Reducer#setup().

    Reducer#configure() in the old MR API and Reducer#setup() in the new MR API, are invoked once for each reduce task before the Reducer.reduce() is invoked.

    BTW, the counters can be got from other JVM also beside the one which kicked the job.

    JobInProgress is defined as below, so it should not be used. This API is for limited projects only and the interface may change.

    @InterfaceAudience.LimitedPrivate({“MapReduce”})
    @InterfaceStability.Unstable

    Not that, JobCounter.TOTAL_LAUNCHED_MAPS also includes map tasks launched due to speculative execution also

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read that the Hadoop Map tasks write their output to local disk. Suppose
I've written a Hadoop Map Reduce job. When I run it locally, I notice
I'm running a hadoop job with mapred.reduce.tasks = 100 (just experimenting). The number of
In a Hadoop job I'm writing, I want UTF-8 encoded strings for my mappers/reducers.
I am getting the following excpetion in my reducers: EMFILE: Too many open files
I have an hadoop job with a pretty long map phase and I want
All Hadoop jobs have unique jobid. You can use jobid to get job status
I am new to Hadoop and Hbase. I would like to know if there
I need to split my Map Reduce jar file in two jobs in order
In a typical MapReduce setup(like Hadoop), how many reducer is used for 1 task,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.