1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.giraph;
20
21 import org.apache.giraph.conf.GiraphConfiguration;
22 import org.apache.giraph.conf.GiraphConstants;
23 import org.apache.giraph.examples.SimpleCheckpoint;
24 import org.apache.giraph.examples.SimpleSuperstepComputation.SimpleSuperstepVertexInputFormat;
25 import org.apache.giraph.examples.SimpleSuperstepComputation.SimpleSuperstepVertexOutputFormat;
26 import org.apache.giraph.job.GiraphJob;
27 import org.apache.hadoop.fs.Path;
28 import org.junit.Test;
29
30 import java.io.IOException;
31
32 import static org.junit.Assert.assertTrue;
33
34
35
36
37 public class TestAutoCheckpoint extends BspCase {
38
39 public TestAutoCheckpoint() {
40 super(TestAutoCheckpoint.class.getName());
41 }
42
43
44
45
46
47
48
49
50
51 @Test
52 public void testSingleFault()
53 throws IOException, InterruptedException, ClassNotFoundException {
54 if (!runningInDistributedMode()) {
55 System.out.println(
56 "testSingleFault: Ignore this test in local mode.");
57 return;
58 }
59 Path outputPath = getTempPath(getCallingMethodName());
60 GiraphConfiguration conf = new GiraphConfiguration();
61 conf.setComputationClass(
62 SimpleCheckpoint.SimpleCheckpointComputation.class);
63 conf.setWorkerContextClass(
64 SimpleCheckpoint.SimpleCheckpointVertexWorkerContext.class);
65 conf.setMasterComputeClass(
66 SimpleCheckpoint.SimpleCheckpointVertexMasterCompute.class);
67 conf.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
68 conf.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class);
69 conf.setBoolean(SimpleCheckpoint.ENABLE_FAULT, true);
70 conf.setInt("mapred.map.max.attempts", 4);
71
72 conf.setInt("mapred.task.timeout", 10000);
73 conf.setMaxMasterSuperstepWaitMsecs(10000);
74 conf.setEventWaitMsecs(1000);
75 conf.setCheckpointFrequency(2);
76 GiraphConstants.CHECKPOINT_DIRECTORY.set(conf,
77 getTempPath("_singleFaultCheckpoints").toString());
78 GiraphConstants.CLEANUP_CHECKPOINTS_AFTER_SUCCESS.set(conf, false);
79 GiraphConstants.ZOOKEEPER_SESSION_TIMEOUT.set(conf, 10000);
80 GiraphConstants.ZOOKEEPER_MIN_SESSION_TIMEOUT.set(conf, 10000);
81 GiraphJob job = prepareJob(getCallingMethodName(), conf, outputPath);
82 assertTrue(job.run(true));
83 }
84 }