/** Check if for a give file in archive, if there are other snapshots/tables still * reference it. * @param filePath file path in archive * @param snapshotFilesMap a map for store files in snapshots about how many snapshots refer * to it. * @return true or false */ private boolean isArchivedFileStillReferenced(final Path filePath, final Map<Path, Integer> snapshotFilesMap) { Integer c = snapshotFilesMap.get(filePath); // Check if there are other snapshots or table from clone_snapshot() (via back-reference) // still reference to it. if ((c != null) && (c == 1)) { Path parentDir = filePath.getParent(); Path backRefDir = HFileLink.getBackReferencesDir(parentDir, filePath.getName()); try { if (FSUtils.listStatus(fs, backRefDir) == null) { return false; } } catch (IOException e) { // For the purpose of this function, IOException is ignored and treated as // the file is still being referenced. } } return true; }
Path backRefPath = null; if (createBackRef) { Path backRefssDir = getBackReferencesDir(archiveStoreDir, hfileName); fs.mkdirs(backRefssDir);
backRefDir = HFileLink.getBackReferencesDir(parentDir, filePath.getName()); return FSUtils.listStatus(fs, backRefDir) == null; } catch (IOException e) {
tableName, regionDir.getName(), storeDir.getName()); Path path = HFileLink.getBackReferencesDir(storeDir, status.getPath().getName()); path = HFileLink.getBackReferencesDir(archiveStoreDir, status.getPath().getName());
fs.mkdirs(familyLinkPath); HFileLink.create(conf, fs, familyLinkPath, hri, hfileName); Path linkBackRefDir = HFileLink.getBackReferencesDir(archiveStoreDir, hfileName); assertTrue(fs.exists(linkBackRefDir)); FileStatus[] backRefs = fs.listStatus(linkBackRefDir);
Path backRefssDir = getBackReferencesDir(archiveStoreDir, hfileName); fs.mkdirs(backRefssDir);
@Override public synchronized boolean isFileDeletable(Path filePath) { if (this.fs == null) return false; // HFile Link is always deletable if (HFileLink.isHFileLink(filePath)) return true; // If the file is inside a link references directory, means that is a back ref link. // The back ref can be deleted only if the referenced file doesn't exists. Path parentDir = filePath.getParent(); if (HFileLink.isBackReferencesDir(parentDir)) { try { Path hfilePath = HFileLink.getHFileFromBackReference(getConf(), filePath); return !fs.exists(hfilePath); } catch (IOException e) { LOG.error("Couldn't verify if the referenced file still exists, keep it just in case"); return false; } } // HFile is deletable only if has no links try { Path backRefDir = HFileLink.getBackReferencesDir(parentDir, filePath.getName()); return FSUtils.listStatus(fs, backRefDir) == null; } catch (IOException e) { LOG.error("Couldn't get the references, not deleting file, just in case"); return false; } }
Path backRefPath = null; if (createBackRef) { Path backRefssDir = getBackReferencesDir(archiveStoreDir, hfileName); fs.mkdirs(backRefssDir);
backRefDir = HFileLink.getBackReferencesDir(parentDir, filePath.getName()); return FSUtils.listStatus(fs, backRefDir) == null; } catch (IOException e) {
tableName, regionDir.getName(), storeDir.getName()); Path path = HFileLink.getBackReferencesDir(storeDir, status.getPath().getName()); path = HFileLink.getBackReferencesDir(archiveStoreDir, status.getPath().getName());
tableName, regionDir.getName(), storeDir.getName()); Path path = HFileLink.getBackReferencesDir(storeDir, status.getPath().getName()); path = HFileLink.getBackReferencesDir(archiveStoreDir, status.getPath().getName());
fs.mkdirs(familyLinkPath); HFileLink.create(conf, fs, familyLinkPath, hri, hfileName); Path linkBackRefDir = HFileLink.getBackReferencesDir(archiveStoreDir, hfileName); assertTrue(fs.exists(linkBackRefDir)); FileStatus[] backRefs = fs.listStatus(linkBackRefDir);