private void createLink(StoreFileTracker sft, boolean createBackReference) throws IOException {
    // Create link to hfile
    familyLinkPath = getFamilyDirPath(rootDir, tableLinkName, hriLink.getEncodedName(), familyName);
    fs.mkdirs(familyLinkPath);
    hfileLinkName =
      sft.createHFileLink(hri.getTable(), hri.getEncodedName(), hfileName, createBackReference);
    linkBackRefDir = HFileLink.getBackReferencesDir(archiveStoreDir, hfileName);
    assertTrue(fs.exists(linkBackRefDir));
    backRefs = fs.listStatus(linkBackRefDir);
    assertEquals(1, backRefs.length);
    linkBackRef = backRefs[0].getPath();
  }
Test the HFileLink Cleaner. HFiles with links cannot be deleted until a link is present.
hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileLinkCleaner.java