getNextDirectory()));
storage.getFileSystem().delete(getNextDirectory(), true);
}
private void update() throws IOException, InterruptedException {
Job job = JobCompatibility.newJob(getConf());
job.setJobName("TGC-UPDATE-" + storage.getPatchDirectory());
List<StageInput> inputList = new ArrayList<StageInput>();
inputList.add(new StageInput(
storage.getHeadContents("*").toString(),
TemporaryInputFormat.class,
BaseMapper.class));
inputList.add(new StageInput(
storage.getPatchContents("*").toString(),
TemporaryInputFormat.class,
PatchMapper.class));
StageInputDriver.set(job, inputList);
job.setInputFormatClass(StageInputFormat.class);
job.setMapperClass(StageInputMapper.class);
job.setMapOutputKeyClass(PatchApplyKey.class);
job.setMapOutputValueClass(modelClass);
// combiner may have no effect in normal cases
job.setReducerClass(PatchApplyReducer.class);
job.setOutputKeyClass(NullWritable.class);
job.setOutputValueClass(modelClass);
job.setPartitionerClass(PatchApplyKey.Partitioner.class);
job.setSortComparatorClass(PatchApplyKey.SortComparator.class);
job.setGroupingComparatorClass(PatchApplyKey.GroupComparator.class);
TemporaryOutputFormat.setOutputPath(job, getNextDirectory());
job.setOutputFormatClass(TemporaryOutputFormat.class);
job.getConfiguration().setClass(
"mapred.output.committer.class",
LegacyBridgeOutputCommitter.class,
org.apache.hadoop.mapred.OutputCommitter.class);
LOG.info(MessageFormat.format("Applying patch: {0} / {1} -> {2}",
storage.getPatchContents("*"),
storage.getHeadContents("*"),
getNextContents()));
try {
boolean succeed = job.waitForCompletion(true);
LOG.info(MessageFormat.format("Applied patch: succeed={0}, {1} / {2} -> {3}",
succeed,
storage.getPatchContents("*"),
storage.getHeadContents("*"),
getNextContents()));