You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@hadoop.apache.org by Alessandro Binhara <bi...@gmail.com> on 2011/03/04 13:59:55 UTC

How i can test a Job finished and sucess in java

hello all ..

i writte mapreduce in java . It works very well.
How i know  a Job finished and sucess in java ?


 JobConf conf = new JobConf(AverageJob.class);
    conf.setJobName("AverageProductTime");

    FileInputFormat.addInputPath(conf, new Path(inputDir));
    FileOutputFormat.setOutputPath(conf, new Path(outputDir));

    conf.setMapperClass(MapAverage.class);
    conf.setReducerClass(RedAverage.class);
      conf.setOutputKeyClass(Text.class);
      conf.setOutputValueClass(IntWritable.class);

    JobClient.runJob(conf);


    if (JobClient.SUCCESS == 0)
    {
                ... do someting ...
    }

????

Thanks

Re: How i can test a Job finished and sucess in java

Posted by Marcos Ortiz <ml...@uci.cu>.
El 3/4/2011 7:59 AM, Alessandro Binhara escribió:
> hello all ..
>
> i writte mapreduce in java . It works very well.
> How i know  a Job finished and sucess in java ?
>
>
>   JobConf conf = new JobConf(AverageJob.class);
>      conf.setJobName("AverageProductTime");
>
>      FileInputFormat.addInputPath(conf, new Path(inputDir));
>      FileOutputFormat.setOutputPath(conf, new Path(outputDir));
>
>      conf.setMapperClass(MapAverage.class);
>      conf.setReducerClass(RedAverage.class);
>        conf.setOutputKeyClass(Text.class);
>        conf.setOutputValueClass(IntWritable.class);
>
>      JobClient.runJob(conf);
>
>
>      if (JobClient.SUCCESS == 0)
>      {
>                  ... do someting ...
>      }
>
> ????
>
> Thanks
>
>    
Regards, Alessandro.
I 'm going to use a example of the Pro Hadoop's book. On Chapter 2, 
Jason Venner explains the different ways to see the success of a certain 
job. The RunningJobs class has the right methods to do this. For example:
  logger.info("Launching the job...");
/** Send the job configuration to the framework
* and request that the job be run.
*/
final RunningJob job = JobClient.runJob(conf);
logger.info("The job has completed.");

Jason says that one of the more useful methods is job.isSuccessful(). I 
recommend to you that you look on the Hadoop MapReduce API for this 
class.(RunningJob)



Re: How i can test a Job finished and sucess in java

Posted by Harsh J <qw...@gmail.com>.
On Fri, Mar 4, 2011 at 6:29 PM, Alessandro Binhara <bi...@gmail.com> wrote:
> ????
>
> Thanks
>

JobClient.runJob returns a RunningJob object at. Use that to determine
the result.
Please see: http://hadoop.apache.org/common/docs/r0.20.0/api/org/apache/hadoop/mapred/RunningJob.html#isSuccessful()

-- 
Harsh J
www.harshj.com