private static List<Mutation> recover(Map<String,KeyValue[]> logs, KeyExtent extent) throws IOException {
return recover(logs, new HashSet<String>(), extent);
}
private static List<Mutation> recover(Map<String,KeyValue[]> logs, Set<String> files, KeyExtent extent) throws IOException {
TemporaryFolder root = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
root.create();
final String workdir = root.getRoot().getAbsolutePath() + "/workdir";
VolumeManager fs = VolumeManagerImpl.getLocal(workdir);
final Path workdirPath = new Path("file://" + workdir);
fs.deleteRecursively(workdirPath);
ArrayList<Path> dirs = new ArrayList<Path>();
try {
for (Entry<String,KeyValue[]> entry : logs.entrySet()) {
String path = workdir + "/" + entry.getKey();
FileSystem ns = fs.getVolumeByPath(new Path(path)).getFileSystem();
@SuppressWarnings("deprecation")
Writer map = new MapFile.Writer(ns.getConf(), ns, path + "/log1", LogFileKey.class, LogFileValue.class);
for (KeyValue lfe : entry.getValue()) {
map.append(lfe.key, lfe.value);
}
map.close();
ns.create(new Path(path, "finished")).close();
dirs.add(new Path(path));
}
// Recover
SortedLogRecovery recovery = new SortedLogRecovery(fs);
CaptureMutations capture = new CaptureMutations();
recovery.recover(extent, dirs, files, capture);
return capture.result;
} finally {
root.delete();
}
}