@Override public Void call() throws IOException { visitRegionStoreFiles(regionManifest, visitor); return null; } });
/**© * Iterate over the snapshot store files * * @param conf The current {@link Configuration} instance. * @param fs {@link FileSystem} * @param snapshotDir {@link Path} to the Snapshot directory * @param desc the {@link SnapshotDescription} of the snapshot to verify * @param visitor callback object to get the store files * @throws IOException if an error occurred while scanning the directory */ static void visitTableStoreFiles(final Configuration conf, final FileSystem fs, final Path snapshotDir, final SnapshotDescription desc, final StoreFileVisitor visitor) throws IOException { SnapshotManifest manifest = SnapshotManifest.open(conf, fs, snapshotDir, desc); List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests(); if (regionManifests == null || regionManifests.isEmpty()) { LOG.debug("No manifest files present: " + snapshotDir); return; } for (SnapshotRegionManifest regionManifest: regionManifests) { visitRegionStoreFiles(regionManifest, visitor); } }
Map<String, SnapshotRegionManifest> regionManifests = manifest.getRegionManifestsMap(); for (SnapshotRegionManifest regionManifest: regionManifests.values()) { SnapshotReferenceUtil.visitRegionStoreFiles(regionManifest, new SnapshotReferenceUtil.StoreFileVisitor() { @Override
@Override public Void call() throws IOException { visitRegionStoreFiles(regionManifest, visitor); return null; } });
/** * Get the list of hfiles for the specified snapshot region. * NOTE: The current implementation keeps one empty file per HFile in the region. * The file name matches the one in the original table, and by reconstructing * the path you can quickly jump to the referenced file. * * @param fs {@link FileSystem} * @param snapshotRegionDir {@link Path} to the Snapshot region directory * @return Map of hfiles per family, the key is the family name and values are hfile names * @throws IOException if an error occurred while scanning the directory */ public static Map<String, List<String>> getRegionHFileReferences(final FileSystem fs, final Path snapshotRegionDir) throws IOException { final Map<String, List<String>> familyFiles = new TreeMap<String, List<String>>(); visitRegionStoreFiles(fs, snapshotRegionDir, new FSVisitor.StoreFileVisitor() { public void storeFile (final String region, final String family, final String hfile) throws IOException { List<String> hfiles = familyFiles.get(family); if (hfiles == null) { hfiles = new LinkedList<String>(); familyFiles.put(family, hfiles); } hfiles.add(hfile); } }); return familyFiles; }
/** * 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 region {@link HRegion} cloned * @param snapshotRegionInfo */ private void cloneRegion(final HRegion region, final HRegionInfo snapshotRegionInfo) throws IOException { final Path snapshotRegionDir = new Path(snapshotDir, snapshotRegionInfo.getEncodedName()); final Path regionDir = new Path(tableDir, region.getRegionInfo().getEncodedName()); final String tableName = tableDesc.getNameAsString(); SnapshotReferenceUtil.visitRegionStoreFiles(fs, snapshotRegionDir, new FSVisitor.StoreFileVisitor() { public void storeFile (final String region, final String family, final String hfile) throws IOException { LOG.info("Adding HFileLink " + hfile + " to table=" + tableName); Path familyDir = new Path(regionDir, family); restoreStoreFile(familyDir, snapshotRegionInfo, hfile); } }); }
/**© * Iterate over the snapshot store files * * @param conf The current {@link Configuration} instance. * @param fs {@link FileSystem} * @param snapshotDir {@link Path} to the Snapshot directory * @param desc the {@link SnapshotDescription} of the snapshot to verify * @param visitor callback object to get the store files * @throws IOException if an error occurred while scanning the directory */ static void visitTableStoreFiles(final Configuration conf, final FileSystem fs, final Path snapshotDir, final SnapshotDescription desc, final StoreFileVisitor visitor) throws IOException { SnapshotManifest manifest = SnapshotManifest.open(conf, fs, snapshotDir, desc); List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests(); if (regionManifests == null || regionManifests.size() == 0) { LOG.debug("No manifest files present: " + snapshotDir); return; } for (SnapshotRegionManifest regionManifest: regionManifests) { visitRegionStoreFiles(regionManifest, visitor); } }
Map<String, SnapshotRegionManifest> regionManifests = manifest.getRegionManifestsMap(); for (SnapshotRegionManifest regionManifest: regionManifests.values()) { SnapshotReferenceUtil.visitRegionStoreFiles(regionManifest, new SnapshotReferenceUtil.StoreFileVisitor() { @Override