1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.giraph.io;
20
21 import org.apache.giraph.BspCase;
22 import org.apache.giraph.benchmark.WeightedPageRankComputation;
23 import org.apache.giraph.conf.GiraphConfiguration;
24 import org.apache.giraph.io.formats.GiraphFileInputFormat;
25 import org.apache.giraph.io.formats.JsonBase64VertexInputFormat;
26 import org.apache.giraph.io.formats.JsonBase64VertexOutputFormat;
27 import org.apache.giraph.io.formats.PseudoRandomInputFormatConstants;
28 import org.apache.giraph.io.formats.PseudoRandomVertexInputFormat;
29 import org.apache.giraph.job.GiraphJob;
30 import org.apache.hadoop.fs.Path;
31 import org.junit.Test;
32
33 import java.io.IOException;
34
35 import static org.junit.Assert.assertEquals;
36 import static org.junit.Assert.assertTrue;
37
38
39
40
41 public class TestJsonBase64Format extends BspCase {
42
43
44
45 public TestJsonBase64Format() {
46 super(TestJsonBase64Format.class.getName());
47 }
48
49
50
51
52
53
54
55
56
57
58 @Test
59 public void testContinue()
60 throws IOException, InterruptedException, ClassNotFoundException {
61
62 Path outputPath = getTempPath(getCallingMethodName());
63 GiraphConfiguration conf = new GiraphConfiguration();
64 conf.setComputationClass(WeightedPageRankComputation.class);
65 conf.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class);
66 conf.setVertexOutputFormatClass(JsonBase64VertexOutputFormat.class);
67 GiraphJob job = prepareJob(getCallingMethodName(), conf, outputPath);
68 job.getConfiguration().setLong(
69 PseudoRandomInputFormatConstants.AGGREGATE_VERTICES, 101);
70 job.getConfiguration().setLong(
71 PseudoRandomInputFormatConstants.EDGES_PER_VERTEX, 2);
72 job.getConfiguration().setInt(
73 WeightedPageRankComputation.SUPERSTEP_COUNT, 2);
74 assertTrue(job.run(true));
75
76 Path outputPath2 = getTempPath(getCallingMethodName() + "2");
77 conf = new GiraphConfiguration();
78 conf.setComputationClass(WeightedPageRankComputation.class);
79 conf.setVertexInputFormatClass(JsonBase64VertexInputFormat.class);
80 conf.setVertexOutputFormatClass(JsonBase64VertexOutputFormat.class);
81 job = prepareJob(getCallingMethodName(), conf, outputPath2);
82 job.getConfiguration().setInt(
83 WeightedPageRankComputation.SUPERSTEP_COUNT, 3);
84 GiraphFileInputFormat.addVertexInputPath(
85 job.getInternalJob().getConfiguration(), outputPath);
86 assertTrue(job.run(true));
87
88 Path outputPath3 = getTempPath(getCallingMethodName() + "3");
89 conf = new GiraphConfiguration();
90 conf.setComputationClass(WeightedPageRankComputation.class);
91 conf.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class);
92 conf.setVertexOutputFormatClass(JsonBase64VertexOutputFormat.class);
93 job = prepareJob(getCallingMethodName(), conf, outputPath3);
94 conf = job.getConfiguration();
95 conf.setLong(PseudoRandomInputFormatConstants.AGGREGATE_VERTICES, 101);
96 conf.setLong(PseudoRandomInputFormatConstants.EDGES_PER_VERTEX, 2);
97 conf.setInt(
98 WeightedPageRankComputation.SUPERSTEP_COUNT, 5);
99 assertTrue(job.run(true));
100
101 assertEquals(101, getNumResults(conf, outputPath));
102 assertEquals(101, getNumResults(conf, outputPath2));
103 assertEquals(101, getNumResults(conf, outputPath3));
104 }
105 }