private void cloneRegion(final RegionInfo newRegionInfo, final Path regionDir,
    final RegionInfo snapshotRegionInfo, final SnapshotRegionManifest manifest) throws IOException {
    final String tableName = tableDesc.getTableName().getNameAsString();
    final String snapshotName = snapshotDesc.getName();
    for (SnapshotRegionManifest.FamilyFiles familyFiles : manifest.getFamilyFilesList()) {
      Path familyDir = new Path(regionDir, familyFiles.getFamilyName().toStringUtf8());
      List<StoreFileInfo> clonedFiles = new ArrayList<>();
      Path regionPath = new Path(tableDir, newRegionInfo.getEncodedName());
      HRegionFileSystem regionFS = (fs.exists(regionPath))
        ? HRegionFileSystem.openRegionFromFileSystem(conf, fs, tableDir, newRegionInfo, false)
        : HRegionFileSystem.createRegionOnFileSystem(conf, fs, tableDir, newRegionInfo);

      Configuration sftConf = StoreUtils.createStoreConfiguration(conf, tableDesc,
        tableDesc.getColumnFamily(familyFiles.getFamilyName().toByteArray()));
      StoreFileTracker tracker =
        StoreFileTrackerFactory
          .create(sftConf, true,
            StoreContext.getBuilder().withFamilyStoreDirectoryPath(familyDir)
              .withRegionFileSystem(regionFS)
              .withColumnFamilyDescriptor(
                ColumnFamilyDescriptorBuilder.of(familyFiles.getFamilyName().toByteArray()))
              .build());
      for (SnapshotRegionManifest.StoreFile storeFile : familyFiles.getStoreFilesList()) {
        LOG.info("Adding HFileLink " + storeFile.getName() + " from cloned region " + "in snapshot "
          + snapshotName + " to table=" + tableName);
        if (MobUtils.isMobRegionInfo(newRegionInfo)) {
          String mobFileName =
            HFileLink.createHFileLinkName(snapshotRegionInfo, storeFile.getName());
          Path mobPath = new Path(familyDir, mobFileName);
          if (fs.exists(mobPath)) {
            fs.delete(mobPath, true);
          }
          restoreStoreFile(familyDir, snapshotRegionInfo, storeFile, createBackRefs, tracker);
        } else {
          String file =
            restoreStoreFile(familyDir, snapshotRegionInfo, storeFile, createBackRefs, tracker);
          clonedFiles.add(tracker.getStoreFileInfo(new Path(familyDir, file), true));
        }
      }
      // we don't need to track files under mobdir
      if (!MobUtils.isMobRegionInfo(newRegionInfo)) {
        tracker.set(clonedFiles);
      }
    }

  }
Clone region directory content from the snapshot info. Each region is encoded with the table
name, so the cloned region will have a different region name. Instead of copying the hfiles a
HFileLink is created.
@param regionDir {@link Path} cloned dir
hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotHelper.java