static void linkBlocks(File fromDir, File toDir, String subdir, int oldLV, HardLink hl, Configuration conf) throws IOException { linkBlocks(new File(fromDir, subdir), new File(toDir, subdir), oldLV, hl, conf); }
/** * Hardlink all finalized and RBW blocks in fromDir to toDir * * @param fromDir directory where the snapshot is stored * @param toDir the current data directory * @throws IOException if error occurs during hardlink */ private static void linkAllBlocks(File fromDir, File toDir, int diskLayoutVersion, Configuration conf) throws IOException { // do the link // hardlink finalized blocks in tmpDir HardLink hardLink = new HardLink(); DataStorage.linkBlocks(fromDir, toDir, DataStorage.STORAGE_DIR_FINALIZED, diskLayoutVersion, hardLink, conf); DataStorage.linkBlocks(fromDir, toDir, DataStorage.STORAGE_DIR_RBW, diskLayoutVersion, hardLink, conf); LOG.info("Linked blocks from {} to {}. {}", fromDir, toDir, hardLink.linkStats.report()); }
LayoutVersion.Feature.APPEND_RBW_DIR, diskLayoutVersion)) { linkBlocks(fromDir, toDir, STORAGE_DIR_FINALIZED, diskLayoutVersion, hardLink, conf); linkBlocks(fromDir, toDir, STORAGE_DIR_RBW, diskLayoutVersion, hardLink, conf); } else { // pre-RBW version linkBlocks(fromDir, new File(toDir, STORAGE_DIR_FINALIZED), diskLayoutVersion, hardLink, conf); if (fromBbwDir.exists()) { linkBlocks(fromBbwDir, new File(toDir, STORAGE_DIR_RBW), diskLayoutVersion, hardLink, conf);
static void linkBlocks(File fromDir, File toDir, String subdir, int oldLV, HardLink hl, Configuration conf) throws IOException { linkBlocks(new File(fromDir, subdir), new File(toDir, subdir), oldLV, hl, conf); }
static void linkBlocks(File fromDir, File toDir, String subdir, int oldLV, HardLink hl, Configuration conf) throws IOException { linkBlocks(new File(fromDir, subdir), new File(toDir, subdir), oldLV, hl, conf); }
/** * Hardlink all finalized and RBW blocks in fromDir to toDir * * @param fromDir directory where the snapshot is stored * @param toDir the current data directory * @throws IOException if error occurs during hardlink */ private static void linkAllBlocks(File fromDir, File toDir, int diskLayoutVersion, Configuration conf) throws IOException { // do the link // hardlink finalized blocks in tmpDir HardLink hardLink = new HardLink(); DataStorage.linkBlocks(fromDir, toDir, DataStorage.STORAGE_DIR_FINALIZED, diskLayoutVersion, hardLink, conf); DataStorage.linkBlocks(fromDir, toDir, DataStorage.STORAGE_DIR_RBW, diskLayoutVersion, hardLink, conf); LOG.info("Linked blocks from " + fromDir + " to " + toDir + ". " + hardLink.linkStats.report()); }
LayoutVersion.Feature.APPEND_RBW_DIR, diskLayoutVersion)) { linkBlocks(fromDir, toDir, STORAGE_DIR_FINALIZED, diskLayoutVersion, hardLink, conf); linkBlocks(fromDir, toDir, STORAGE_DIR_RBW, diskLayoutVersion, hardLink, conf); } else { // pre-RBW version linkBlocks(fromDir, new File(toDir, STORAGE_DIR_FINALIZED), diskLayoutVersion, hardLink, conf); if (fromBbwDir.exists()) { linkBlocks(fromBbwDir, new File(toDir, STORAGE_DIR_RBW), diskLayoutVersion, hardLink, conf);
LayoutVersion.Feature.APPEND_RBW_DIR, diskLayoutVersion)) { linkBlocks(fromDir, toDir, STORAGE_DIR_FINALIZED, diskLayoutVersion, hardLink, conf); linkBlocks(fromDir, toDir, STORAGE_DIR_RBW, diskLayoutVersion, hardLink, conf); } else { // pre-RBW version linkBlocks(fromDir, new File(toDir, STORAGE_DIR_FINALIZED), diskLayoutVersion, hardLink, conf); if (fromBbwDir.exists()) { linkBlocks(fromBbwDir, new File(toDir, STORAGE_DIR_RBW), diskLayoutVersion, hardLink, conf);
/** * Hardlink all finalized and RBW blocks in fromDir to toDir * * @param fromDir directory where the snapshot is stored * @param toDir the current data directory * @throws IOException if error occurs during hardlink */ private static void linkAllBlocks(File fromDir, File toDir, int diskLayoutVersion, Configuration conf) throws IOException { // do the link // hardlink finalized blocks in tmpDir HardLink hardLink = new HardLink(); DataStorage.linkBlocks(fromDir, toDir, DataStorage.STORAGE_DIR_FINALIZED, diskLayoutVersion, hardLink, conf); DataStorage.linkBlocks(fromDir, toDir, DataStorage.STORAGE_DIR_RBW, diskLayoutVersion, hardLink, conf); LOG.info("Linked blocks from " + fromDir + " to " + toDir + ". " + hardLink.linkStats.report()); }
linkBlocks(new File(from, blockNames[i]), new File(to, blockNames[i]), oldLV);
linkBlocks(new File(tmpDir, STORAGE_DIR_FINALIZED), new File(curDir, STORAGE_DIR_FINALIZED), curLayoutVersion, hardLink, true); linkBlocks(new File(tmpDir, STORAGE_DIR_RBW), new File(curDir, STORAGE_DIR_RBW), curLayoutVersion, hardLink, true); new File(tmpDir, namespaceDir.getName()), STORAGE_DIR_CURRENT); File namespaceDirCur = new File(namespaceDir, STORAGE_DIR_CURRENT); linkBlocks(new File(tmpNamespaceCurDir, STORAGE_DIR_FINALIZED), new File(namespaceDirCur, STORAGE_DIR_FINALIZED), curLayoutVersion, hardLink, true); linkBlocks(new File(tmpNamespaceCurDir, STORAGE_DIR_RBW), new File(namespaceDirCur, STORAGE_DIR_RBW), curLayoutVersion, hardLink, true); linkBlocks(new File(tmpNamespaceCurDir, STORAGE_FILE_VERSION), new File(namespaceDirCur, STORAGE_FILE_VERSION), curLayoutVersion, hardLink, true); File curNsDirFinalized = new File(nsCurDir, STORAGE_DIR_FINALIZED); File curNsDirRbw = new File(nsCurDir, STORAGE_DIR_RBW); linkBlocks(new File(tmpDir, STORAGE_DIR_FINALIZED), curNsDirFinalized, curLayoutVersion, hardLink, false); linkBlocks(new File(tmpDir, STORAGE_DIR_RBW), curNsDirRbw, curLayoutVersion, hardLink, false); } else { linkBlocks(tmpDir, nsDirFinalized, curLayoutVersion, hardLink, true);
linkBlocks(new File(srcCurNsDir, STORAGE_DIR_FINALIZED), new File(mergeTmpCurNSDir, STORAGE_DIR_FINALIZED), nsInfo.getLayoutVersion(), hardLink, true); linkBlocks(new File(srcCurNsDir, STORAGE_DIR_RBW), new File(mergeTmpCurNSDir, STORAGE_DIR_RBW), nsInfo.getLayoutVersion(), hardLink, true);
} else { for(int i = 0; i < blockNames.length; i++) linkBlocks(new File(from, blockNames[i]), new File(to, blockNames[i]), oldLV, hl, true); linkBlocks(new File(from, otherNames[i]), new File(to, otherNames[i]), oldLV, hl, true);
linkBlocks(tmpDir, curDir, this.getLayoutVersion());