1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.giraph.bsp; |
20 | |
|
21 | |
import java.io.IOException; |
22 | |
|
23 | |
import org.apache.giraph.graph.BspUtils; |
24 | |
import org.apache.hadoop.io.Text; |
25 | |
import org.apache.hadoop.mapreduce.JobContext; |
26 | |
import org.apache.hadoop.mapreduce.OutputCommitter; |
27 | |
import org.apache.hadoop.mapreduce.OutputFormat; |
28 | |
import org.apache.hadoop.mapreduce.RecordWriter; |
29 | |
import org.apache.hadoop.mapreduce.TaskAttemptContext; |
30 | |
import org.apache.log4j.Logger; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 48 | public class BspOutputFormat extends OutputFormat<Text, Text> { |
37 | |
|
38 | 1 | private static Logger LOG = Logger.getLogger(BspOutputFormat.class); |
39 | |
|
40 | |
@Override |
41 | |
public void checkOutputSpecs(JobContext context) |
42 | |
throws IOException, InterruptedException { |
43 | 24 | if (BspUtils.getVertexOutputFormatClass(context.getConfiguration()) == |
44 | |
null) { |
45 | 7 | LOG.warn("checkOutputSpecs: ImmutableOutputCommiter" + |
46 | |
" will not check anything"); |
47 | 7 | return; |
48 | |
} |
49 | 17 | BspUtils.createVertexOutputFormat(context.getConfiguration()). |
50 | |
checkOutputSpecs(context); |
51 | 17 | } |
52 | |
|
53 | |
@Override |
54 | |
public OutputCommitter getOutputCommitter(TaskAttemptContext context) |
55 | |
throws IOException, InterruptedException { |
56 | 24 | if (BspUtils.getVertexOutputFormatClass(context.getConfiguration()) == |
57 | |
null) { |
58 | 7 | LOG.warn("getOutputCommitter: Returning " + |
59 | |
"ImmutableOutputCommiter (does nothing)."); |
60 | 7 | return new ImmutableOutputCommitter(); |
61 | |
} |
62 | 17 | return BspUtils.createVertexOutputFormat(context.getConfiguration()). |
63 | |
getOutputCommitter(context); |
64 | |
} |
65 | |
|
66 | |
@Override |
67 | |
public RecordWriter<Text, Text> getRecordWriter(TaskAttemptContext context) |
68 | |
throws IOException, InterruptedException { |
69 | 24 | return new BspRecordWriter(); |
70 | |
} |
71 | |
} |