Search in sources :

Example 6 with StoreFileTracker

use of org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTracker in project hbase by apache.

the class MergeTableRegionsProcedure method mergeStoreFiles.

private List<Path> mergeStoreFiles(MasterProcedureEnv env, HRegionFileSystem regionFs, HRegionFileSystem mergeRegionFs, RegionInfo mergedRegion) throws IOException {
    final TableDescriptor htd = env.getMasterServices().getTableDescriptors().get(mergedRegion.getTable());
    List<Path> mergedFiles = new ArrayList<>();
    for (ColumnFamilyDescriptor hcd : htd.getColumnFamilies()) {
        String family = hcd.getNameAsString();
        StoreFileTracker tracker = StoreFileTrackerFactory.create(env.getMasterConfiguration(), htd, hcd, regionFs);
        final Collection<StoreFileInfo> storeFiles = tracker.load();
        if (storeFiles != null && storeFiles.size() > 0) {
            final Configuration storeConfiguration = StoreUtils.createStoreConfiguration(env.getMasterConfiguration(), htd, hcd);
            for (StoreFileInfo storeFileInfo : storeFiles) {
                // Create reference file(s) to parent region file here in mergedDir.
                // As this procedure is running on master, use CacheConfig.DISABLED means
                // don't cache any block.
                // We also need to pass through a suitable CompoundConfiguration as if this
                // is running in a regionserver's Store context, or we might not be able
                // to read the hfiles.
                storeFileInfo.setConf(storeConfiguration);
                Path refFile = mergeRegionFs.mergeStoreFile(regionFs.getRegionInfo(), family, new HStoreFile(storeFileInfo, hcd.getBloomFilterType(), CacheConfig.DISABLED));
                mergedFiles.add(refFile);
            }
        }
    }
    return mergedFiles;
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) ArrayList(java.util.ArrayList) HStoreFile(org.apache.hadoop.hbase.regionserver.HStoreFile) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) StoreFileTracker(org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTracker) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) StoreFileInfo(org.apache.hadoop.hbase.regionserver.StoreFileInfo)

Example 7 with StoreFileTracker

use of org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTracker in project hbase by apache.

the class MasterRegionFactory method withTrackerConfigs.

private static TableDescriptor withTrackerConfigs(Configuration conf) {
    String trackerImpl = conf.get(TRACKER_IMPL, conf.get(StoreFileTrackerFactory.TRACKER_IMPL, StoreFileTrackerFactory.Trackers.DEFAULT.name()));
    Class<? extends StoreFileTracker> trackerClass = StoreFileTrackerFactory.getTrackerClass(trackerImpl);
    if (StoreFileTrackerFactory.isMigration(trackerClass)) {
        throw new IllegalArgumentException("Should not set store file tracker to " + StoreFileTrackerFactory.Trackers.MIGRATION.name() + " for master local region");
    }
    StoreFileTracker tracker = ReflectionUtils.newInstance(trackerClass, conf, true, null);
    return tracker.updateWithTrackerConfigs(TableDescriptorBuilder.newBuilder(TABLE_DESC)).build();
}
Also used : StoreFileTracker(org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTracker)

Example 8 with StoreFileTracker

use of org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTracker in project hbase by apache.

the class RestoreSnapshotHelper method cloneRegion.

/**
 * 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
 * @param snapshotRegionInfo
 */
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<>();
        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);
            } else {
                String file = restoreStoreFile(familyDir, snapshotRegionInfo, storeFile, createBackRefs);
                clonedFiles.add(new StoreFileInfo(conf, fs, new Path(familyDir, file), true));
            }
        }
        // we don't need to track files under mobdir
        if (!MobUtils.isMobRegionInfo(newRegionInfo)) {
            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).build());
            tracker.set(clonedFiles);
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) HRegionFileSystem(org.apache.hadoop.hbase.regionserver.HRegionFileSystem) ArrayList(java.util.ArrayList) SnapshotRegionManifest(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest) StoreFileTracker(org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTracker) StoreFileInfo(org.apache.hadoop.hbase.regionserver.StoreFileInfo)

Aggregations

StoreFileTracker (org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTracker)8 Path (org.apache.hadoop.fs.Path)6 StoreFileInfo (org.apache.hadoop.hbase.regionserver.StoreFileInfo)6 ArrayList (java.util.ArrayList)5 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)4 HRegionFileSystem (org.apache.hadoop.hbase.regionserver.HRegionFileSystem)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Configuration (org.apache.hadoop.conf.Configuration)3 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)3 InterruptedIOException (java.io.InterruptedIOException)2 List (java.util.List)2 HStoreFile (org.apache.hadoop.hbase.regionserver.HStoreFile)2 SnapshotRegionManifest (org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest)2 Collection (java.util.Collection)1 LinkedList (java.util.LinkedList)1 TreeMap (java.util.TreeMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1