Ejemplo n.º 1
0
  /** Test if aggregators are are handled properly when restarting from a checkpoint */
  @Test
  public void testAggregatorsCheckpointing()
      throws ClassNotFoundException, IOException, InterruptedException {
    Path checkpointsDir = getTempPath("checkPointsForTesting");
    Path outputPath = getTempPath(getCallingMethodName());
    GiraphConfiguration conf = new GiraphConfiguration();
    conf.setComputationClass(AggregatorsTestComputation.class);
    conf.setMasterComputeClass(AggregatorsTestComputation.AggregatorsTestMasterCompute.class);
    conf.setVertexInputFormatClass(AggregatorsTestComputation.SimpleVertexInputFormat.class);
    conf.setEdgeInputFormatClass(AggregatorsTestComputation.SimpleEdgeInputFormat.class);
    GiraphJob job = prepareJob(getCallingMethodName(), conf, outputPath);

    GiraphConfiguration configuration = job.getConfiguration();
    GiraphConstants.CHECKPOINT_DIRECTORY.set(configuration, checkpointsDir.toString());
    GiraphConstants.CLEANUP_CHECKPOINTS_AFTER_SUCCESS.set(configuration, false);
    configuration.setCheckpointFrequency(4);

    assertTrue(job.run(true));

    // Restart the test from superstep 4
    System.out.println(
        "testAggregatorsCheckpointing: Restarting from "
            + "superstep 4 with checkpoint path = "
            + checkpointsDir);
    outputPath = getTempPath(getCallingMethodName() + "Restarted");
    conf = new GiraphConfiguration();
    conf.setComputationClass(AggregatorsTestComputation.class);
    conf.setMasterComputeClass(AggregatorsTestComputation.AggregatorsTestMasterCompute.class);
    conf.setVertexInputFormatClass(AggregatorsTestComputation.SimpleVertexInputFormat.class);
    conf.setEdgeInputFormatClass(AggregatorsTestComputation.SimpleEdgeInputFormat.class);
    GiraphJob restartedJob = prepareJob(getCallingMethodName() + "Restarted", conf, outputPath);
    job.getConfiguration()
        .setMasterComputeClass(SimpleCheckpoint.SimpleCheckpointVertexMasterCompute.class);
    GiraphConfiguration restartedJobConf = restartedJob.getConfiguration();
    GiraphConstants.CHECKPOINT_DIRECTORY.set(restartedJobConf, checkpointsDir.toString());
    restartedJobConf.setLong(GiraphConstants.RESTART_SUPERSTEP, 4);

    assertTrue(restartedJob.run(true));
  }