* @throws ClassNotFoundException
* @throws InterruptedException
*/
public void testBspCheckpoint()
throws IOException, InterruptedException, ClassNotFoundException {
GiraphJob job = new GiraphJob(getCallingMethodName());
setupConfiguration(job);
job.getConfiguration().set(GiraphJob.CHECKPOINT_DIRECTORY,
HDFS_CHECKPOINT_DIR);
job.getConfiguration().setBoolean(
GiraphJob.CLEANUP_CHECKPOINTS_AFTER_SUCCESS, false);
job.setVertexClass(SimpleCheckpointVertex.class);
job.setWorkerContextClass(
SimpleCheckpointVertex.SimpleCheckpointVertexWorkerContext.class);
job.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
job.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class);
Path outputPath = new Path("/tmp/" + getCallingMethodName());
removeAndSetOutput(job, outputPath);
assertTrue(job.run(true));
long fileLen = 0;
long idSum = 0;
if (getJobTracker() == null) {
FileStatus fileStatus = getSinglePartFileStatus(job, outputPath);
fileLen = fileStatus.getLen();
idSum =
SimpleCheckpointVertex.SimpleCheckpointVertexWorkerContext.finalSum;
System.out.println("testBspCheckpoint: idSum = " + idSum +
" fileLen = " + fileLen);
}
// Restart the test from superstep 2
System.out.println(
"testBspCheckpoint: Restarting from superstep 2" +
" with checkpoint path = " + HDFS_CHECKPOINT_DIR);
GiraphJob restartedJob = new GiraphJob(getCallingMethodName() +
"Restarted");
setupConfiguration(restartedJob);
restartedJob.getConfiguration().set(GiraphJob.CHECKPOINT_DIRECTORY,
HDFS_CHECKPOINT_DIR);
restartedJob.getConfiguration().setLong(GiraphJob.RESTART_SUPERSTEP, 2);
restartedJob.setVertexClass(SimpleCheckpointVertex.class);
restartedJob.setWorkerContextClass(
SimpleCheckpointVertex.SimpleCheckpointVertexWorkerContext.class);
restartedJob.setVertexInputFormatClass(
SimpleSuperstepVertexInputFormat.class);
restartedJob.setVertexOutputFormatClass(
SimpleSuperstepVertexOutputFormat.class);
outputPath = new Path("/tmp/" + getCallingMethodName() + "Restarted");
removeAndSetOutput(restartedJob, outputPath);
assertTrue(restartedJob.run(true));
if (getJobTracker() == null) {
FileStatus fileStatus = getSinglePartFileStatus(job, outputPath);
fileLen = fileStatus.getLen();
assertTrue(fileStatus.getLen() == fileLen);
long idSumRestarted =