Advertisement
Guest User

Untitled

a guest
Dec 17th, 2011
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1.  
  2.  
  3. import org.apache.hadoop.fs.Path;
  4. import org.apache.hadoop.io.Text;
  5. import org.apache.hadoop.conf.Configuration;
  6. import org.apache.hadoop.conf.Configured;
  7. import org.apache.hadoop.mapreduce.Job;
  8. import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
  9. import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
  10. import org.apache.hadoop.util.Tool;
  11. import org.apache.hadoop.util.ToolRunner;
  12.  
  13.  
  14.  
  15. public class DistCacheTest extends Configured implements Tool
  16. {
  17. public int run(String[] args) throws Exception
  18. {
  19. //getting configuration object and setting job name
  20. Configuration conf = getConf();
  21. Job job = new Job(conf, "Word Count hadoop-0.20");
  22.  
  23. //setting the class names
  24. job.setJarByClass(DistCacheTest.class);
  25. job.setMapperClass(DistCacheTestMapper.class);
  26.  
  27. //setting the output data type classes
  28. job.setOutputKeyClass(Text.class);
  29. job.setOutputValueClass(Text.class);
  30.  
  31. //to accept the hdfs input and output dir at run time
  32. FileInputFormat.addInputPath(job, new Path(args[0]));
  33. FileOutputFormat.setOutputPath(job, new Path(args[1]));
  34.  
  35. return job.waitForCompletion(true) ? 0 : 1;
  36. }
  37.  
  38. public static void main(String[] args) throws Exception {
  39. int res = ToolRunner.run(new Configuration(), new DistCacheTest(), args);
  40. System.exit(res);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement