Search in sources :

Example 11 with SnapshotManifest

use of org.apache.hadoop.hbase.snapshot.SnapshotManifest in project hbase by apache.

the class MultiTableSnapshotInputFormatImpl method getSplits.

/**
   * Return the list of splits extracted from the scans/snapshots pushed to conf by
   * {@link
   * #setInput(org.apache.hadoop.conf.Configuration, java.util.Map, org.apache.hadoop.fs.Path)}
   *
   * @param conf Configuration to determine splits from
   * @return Return the list of splits extracted from the scans/snapshots pushed to conf
   * @throws IOException
   */
public List<TableSnapshotInputFormatImpl.InputSplit> getSplits(Configuration conf) throws IOException {
    Path rootDir = FSUtils.getRootDir(conf);
    FileSystem fs = rootDir.getFileSystem(conf);
    List<TableSnapshotInputFormatImpl.InputSplit> rtn = Lists.newArrayList();
    Map<String, Collection<Scan>> snapshotsToScans = getSnapshotsToScans(conf);
    Map<String, Path> snapshotsToRestoreDirs = getSnapshotDirs(conf);
    for (Map.Entry<String, Collection<Scan>> entry : snapshotsToScans.entrySet()) {
        String snapshotName = entry.getKey();
        Path restoreDir = snapshotsToRestoreDirs.get(snapshotName);
        SnapshotManifest manifest = TableSnapshotInputFormatImpl.getSnapshotManifest(conf, snapshotName, rootDir, fs);
        List<HRegionInfo> regionInfos = TableSnapshotInputFormatImpl.getRegionInfosFromManifest(manifest);
        for (Scan scan : entry.getValue()) {
            List<TableSnapshotInputFormatImpl.InputSplit> splits = TableSnapshotInputFormatImpl.getSplits(scan, manifest, regionInfos, restoreDir, conf);
            rtn.addAll(splits);
        }
    }
    return rtn;
}
Also used : Path(org.apache.hadoop.fs.Path) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) SnapshotManifest(org.apache.hadoop.hbase.snapshot.SnapshotManifest) FileSystem(org.apache.hadoop.fs.FileSystem) Collection(java.util.Collection) Scan(org.apache.hadoop.hbase.client.Scan) AbstractMap(java.util.AbstractMap) Map(java.util.Map)

Example 12 with SnapshotManifest

use of org.apache.hadoop.hbase.snapshot.SnapshotManifest in project hbase by apache.

the class HRegion method addRegionToSnapshot.

/**
   * Complete taking the snapshot on the region. Writes the region info and adds references to the
   * working snapshot directory.
   *
   * TODO for api consistency, consider adding another version with no {@link ForeignExceptionSnare}
   * arg.  (In the future other cancellable HRegion methods could eventually add a
   * {@link ForeignExceptionSnare}, or we could do something fancier).
   *
   * @param desc snapshot description object
   * @param exnSnare ForeignExceptionSnare that captures external exceptions in case we need to
   *   bail out.  This is allowed to be null and will just be ignored in that case.
   * @throws IOException if there is an external or internal error causing the snapshot to fail
   */
public void addRegionToSnapshot(SnapshotDescription desc, ForeignExceptionSnare exnSnare) throws IOException {
    Path rootDir = FSUtils.getRootDir(conf);
    Path snapshotDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(desc, rootDir);
    SnapshotManifest manifest = SnapshotManifest.create(conf, getFilesystem(), snapshotDir, desc, exnSnare);
    manifest.addRegion(this);
}
Also used : Path(org.apache.hadoop.fs.Path) SnapshotManifest(org.apache.hadoop.hbase.snapshot.SnapshotManifest)

Aggregations

SnapshotManifest (org.apache.hadoop.hbase.snapshot.SnapshotManifest)12 Path (org.apache.hadoop.fs.Path)9 FileSystem (org.apache.hadoop.fs.FileSystem)7 MasterFileSystem (org.apache.hadoop.hbase.master.MasterFileSystem)5 IOException (java.io.IOException)3 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)3 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)3 TableName (org.apache.hadoop.hbase.TableName)3 SnapshotDescription (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.SnapshotDescription)3 FileNotFoundException (java.io.FileNotFoundException)2 Configuration (org.apache.hadoop.conf.Configuration)2 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)2 Scan (org.apache.hadoop.hbase.client.Scan)2 ForeignException (org.apache.hadoop.hbase.errorhandling.ForeignException)2 ForeignExceptionDispatcher (org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher)2 RestoreSnapshotHelper (org.apache.hadoop.hbase.snapshot.RestoreSnapshotHelper)2 SQLException (java.sql.SQLException)1 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1