-
Notifications
You must be signed in to change notification settings - Fork 0
/
AmazonFoodAnalytic.java
66 lines (44 loc) · 2.13 KB
/
AmazonFoodAnalytic.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package mapreduce.job3;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
import org.apache.log4j.Logger;
public class AmazonFoodAnalytic extends Configured implements Tool {
private static final Logger LOG = Logger.getLogger(AmazonFoodAnalytic.class);
private AmazonFoodAnalytic() {}
public static void main(String[] args) throws Exception {
ToolRunner.run(new AmazonFoodAnalytic(), args);
}
@Override
@SuppressWarnings({ "static-access" })
public int run(String[] args) throws Exception {
long startTime = System.currentTimeMillis();
Job job = new Job(new Configuration(), "mapreduce.job3.AmazonFoodAnalytic");
job.setJarByClass(AmazonFoodAnalytic.class);
job.setMapperClass(AmazonFoodAnalyticMapper.class);
job.setReducerClass(AmazonFoodAnalyticReducer.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
job.waitForCompletion(true);
Job job2 = new Job(new Configuration(), "mapreduce.job3.AmazonFoodAnalytic");
job2.setJarByClass(AmazonFoodAnalytic.class);
job2.setMapperClass(AmazonFoodAnalyticMapperTwo.class);
job2.setReducerClass(AmazonFoodAnalyticReducerTwo.class);
FileInputFormat.addInputPath(job2, new Path(args[1]));
FileOutputFormat.setOutputPath(job2, new Path(args[1] + "/final"));
job2.setOutputKeyClass(Text.class);
job2.setOutputValueClass(IntWritable.class);
job2.waitForCompletion(true);
LOG.info("Job Finished in " + (System.currentTimeMillis() - startTime) / 1000.0 + " seconds");
return 0;
}
}