当前位置: 首页>>代码示例>>Java>>正文


Java SnapshotDescriptionUtils.readSnapshotInfo方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils.readSnapshotInfo方法的典型用法代码示例。如果您正苦于以下问题:Java SnapshotDescriptionUtils.readSnapshotInfo方法的具体用法?Java SnapshotDescriptionUtils.readSnapshotInfo怎么用?Java SnapshotDescriptionUtils.readSnapshotInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils的用法示例。


在下文中一共展示了SnapshotDescriptionUtils.readSnapshotInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTableDesc

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Get table descriptor
 * @param tableName is the table backed up
 * @return {@link TableDescriptor} saved in backup image of the table
 */
TableDescriptor getTableDesc(TableName tableName) throws IOException {
  Path tableInfoPath = this.getTableInfoPath(tableName);
  SnapshotDescription desc = SnapshotDescriptionUtils.readSnapshotInfo(fs, tableInfoPath);
  SnapshotManifest manifest = SnapshotManifest.open(conf, fs, tableInfoPath, desc);
  TableDescriptor tableDescriptor = manifest.getTableDescriptor();
  if (!tableDescriptor.getTableName().equals(tableName)) {
    LOG.error("couldn't find Table Desc for table: " + tableName + " under tableInfoPath: "
            + tableInfoPath.toString());
    LOG.error("tableDescriptor.getNameAsString() = "
            + tableDescriptor.getTableName().getNameAsString());
    throw new FileNotFoundException("couldn't find Table Desc for table: " + tableName
        + " under tableInfoPath: " + tableInfoPath.toString());
  }
  return tableDescriptor;
}
 
开发者ID:apache,项目名称:hbase,代码行数:21,代码来源:RestoreTool.java

示例2: openWithoutRestoringSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
private void openWithoutRestoringSnapshot() throws IOException {
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  SnapshotProtos.SnapshotDescription snapshotDesc =
      SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);

  SnapshotManifest manifest = SnapshotManifest.open(conf, fs, snapshotDir, snapshotDesc);
  List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests();
  if (regionManifests == null) {
    throw new IllegalArgumentException("Snapshot seems empty, snapshotName: " + snapshotName);
  }

  regions = new ArrayList<>(regionManifests.size());
  regionManifests.stream().map(r -> HRegionInfo.convert(r.getRegionInfo()))
      .filter(this::isValidRegion).sorted().forEach(r -> regions.add(r));
  htd = manifest.getTableDescriptor();
}
 
开发者ID:apache,项目名称:hbase,代码行数:17,代码来源:TableSnapshotScanner.java

示例3: verifySnapshotDescription

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Check that the snapshot description written in the filesystem matches the current snapshot
 * @param snapshotDir snapshot directory to check
 */
private void verifySnapshotDescription(Path snapshotDir) throws CorruptedSnapshotException {
  SnapshotDescription found = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
  if (!this.snapshot.equals(found)) {
    throw new CorruptedSnapshotException("Snapshot read (" + found
        + ") doesn't equal snapshot we ran (" + snapshot + ").", snapshot);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:MasterSnapshotVerifier.java

示例4: deleteSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Delete the specified snapshot
 * @param snapshot
 * @throws SnapshotDoesNotExistException If the specified snapshot does not exist.
 * @throws IOException For filesystem IOExceptions
 */
public void deleteSnapshot(SnapshotDescription snapshot) throws SnapshotDoesNotExistException, IOException {
  // check to see if it is completed
  if (!isSnapshotCompleted(snapshot)) {
    throw new SnapshotDoesNotExistException(snapshot);
  }

  String snapshotName = snapshot.getName();
  // first create the snapshot description and check to see if it exists
  FileSystem fs = master.getMasterFileSystem().getFileSystem();
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  // Get snapshot info from file system. The one passed as parameter is a "fake" snapshotInfo with
  // just the "name" and it does not contains the "real" snapshot information
  snapshot = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);

  // call coproc pre hook
  MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost();
  if (cpHost != null) {
    cpHost.preDeleteSnapshot(snapshot);
  }

  LOG.debug("Deleting snapshot: " + snapshotName);
  // delete the existing snapshot
  if (!fs.delete(snapshotDir, true)) {
    throw new HBaseSnapshotException("Failed to delete snapshot directory: " + snapshotDir);
  }

  // call coproc post hook
  if (cpHost != null) {
    cpHost.postDeleteSnapshot(snapshot);
  }

}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:39,代码来源:SnapshotManager.java

示例5: loadSnapshotInfo

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Load snapshot info and table descriptor for the specified snapshot
 * @param snapshotName name of the snapshot to load
 * @return false if snapshot is not found
 */
private boolean loadSnapshotInfo(final String snapshotName) throws IOException {
  snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  if (!fs.exists(snapshotDir)) {
    LOG.warn("Snapshot '" + snapshotName + "' not found in: " + snapshotDir);
    return false;
  }

  snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
  snapshotTableDesc = FSTableDescriptors.getTableDescriptor(fs, snapshotDir);
  return true;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:17,代码来源:SnapshotInfo.java

示例6: init

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
private void init() throws IOException {
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  SnapshotDescription snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
  SnapshotManifest manifest = SnapshotManifest.open(conf, fs, snapshotDir, snapshotDesc);

  // load table descriptor
  htd = manifest.getTableDescriptor();

  List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests();
  if (regionManifests == null) {
    throw new IllegalArgumentException("Snapshot seems empty");
  }

  regions = new ArrayList<HRegionInfo>(regionManifests.size());
  for (SnapshotRegionManifest regionManifest : regionManifests) {
    // load region descriptor
    HRegionInfo hri = HRegionInfo.convert(regionManifest.getRegionInfo());

    if (CellUtil.overlappingKeys(scan.getStartRow(), scan.getStopRow(),
        hri.getStartKey(), hri.getEndKey())) {
      regions.add(hri);
    }
  }

  // sort for regions according to startKey.
  Collections.sort(regions);

  initScanMetrics(scan);

  RestoreSnapshotHelper.copySnapshotForScanner(conf, fs,
    rootDir, restoreDir, snapshotName);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:33,代码来源:TableSnapshotScanner.java

示例7: verifySnapshotDescription

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Check that the snapshot description written in the filesystem matches the current snapshot
 * @param snapshotDir snapshot directory to check
 */
private void verifySnapshotDescription(Path snapshotDir) throws CorruptedSnapshotException {
  SnapshotDescription found = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
  if (!this.snapshot.equals(found)) {
    throw new CorruptedSnapshotException(
        "Snapshot read (" + found + ") doesn't equal snapshot we ran (" + snapshot + ").",
        ProtobufUtil.createSnapshotDesc(snapshot));
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:13,代码来源:MasterSnapshotVerifier.java

示例8: deleteSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Delete the specified snapshot
 * @param snapshot
 * @throws SnapshotDoesNotExistException If the specified snapshot does not exist.
 * @throws IOException For filesystem IOExceptions
 */
public void deleteSnapshot(SnapshotDescription snapshot) throws SnapshotDoesNotExistException, IOException {
  // check to see if it is completed
  if (!isSnapshotCompleted(snapshot)) {
    throw new SnapshotDoesNotExistException(ProtobufUtil.createSnapshotDesc(snapshot));
  }

  String snapshotName = snapshot.getName();
  // first create the snapshot description and check to see if it exists
  FileSystem fs = master.getMasterFileSystem().getFileSystem();
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  // Get snapshot info from file system. The one passed as parameter is a "fake" snapshotInfo with
  // just the "name" and it does not contains the "real" snapshot information
  snapshot = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);

  // call coproc pre hook
  MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost();
  org.apache.hadoop.hbase.client.SnapshotDescription snapshotPOJO = null;
  if (cpHost != null) {
    snapshotPOJO = ProtobufUtil.createSnapshotDesc(snapshot);
    cpHost.preDeleteSnapshot(snapshotPOJO);
  }

  LOG.debug("Deleting snapshot: " + snapshotName);
  // delete the existing snapshot
  if (!fs.delete(snapshotDir, true)) {
    throw new HBaseSnapshotException("Failed to delete snapshot directory: " + snapshotDir);
  }

  // call coproc post hook
  if (cpHost != null) {
    cpHost.postDeleteSnapshot(snapshotPOJO);
  }

}
 
开发者ID:apache,项目名称:hbase,代码行数:41,代码来源:SnapshotManager.java

示例9: restoreOrCloneSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Restore or Clone the specified snapshot
 * @param reqSnapshot
 * @param nonceKey unique identifier to prevent duplicated RPC
 * @throws IOException
 */
public long restoreOrCloneSnapshot(final SnapshotDescription reqSnapshot, final NonceKey nonceKey,
    final boolean restoreAcl) throws IOException {
  FileSystem fs = master.getMasterFileSystem().getFileSystem();
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(reqSnapshot, rootDir);

  // check if the snapshot exists
  if (!fs.exists(snapshotDir)) {
    LOG.error("A Snapshot named '" + reqSnapshot.getName() + "' does not exist.");
    throw new SnapshotDoesNotExistException(
      ProtobufUtil.createSnapshotDesc(reqSnapshot));
  }

  // Get snapshot info from file system. The reqSnapshot is a "fake" snapshotInfo with
  // just the snapshot "name" and table name to restore. It does not contains the "real" snapshot
  // information.
  SnapshotDescription snapshot = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
  SnapshotManifest manifest = SnapshotManifest.open(master.getConfiguration(), fs,
      snapshotDir, snapshot);
  TableDescriptor snapshotTableDesc = manifest.getTableDescriptor();
  TableName tableName = TableName.valueOf(reqSnapshot.getTable());

  // stop tracking "abandoned" handlers
  cleanupSentinels();

  // Verify snapshot validity
  SnapshotReferenceUtil.verifySnapshot(master.getConfiguration(), fs, manifest);

  // Execute the restore/clone operation
  long procId;
  if (MetaTableAccessor.tableExists(master.getConnection(), tableName)) {
    procId = restoreSnapshot(reqSnapshot, tableName, snapshot, snapshotTableDesc, nonceKey,
      restoreAcl);
  } else {
    procId =
        cloneSnapshot(reqSnapshot, tableName, snapshot, snapshotTableDesc, nonceKey, restoreAcl);
  }
  return procId;
}
 
开发者ID:apache,项目名称:hbase,代码行数:45,代码来源:SnapshotManager.java

示例10: getSnapshotManifest

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
public static SnapshotManifest getSnapshotManifest(Configuration conf, String snapshotName,
    Path rootDir, FileSystem fs) throws IOException {
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  SnapshotDescription snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
  return SnapshotManifest.open(conf, fs, snapshotDir, snapshotDesc);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:7,代码来源:TableSnapshotInputFormatImpl.java

示例11: restoreSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Restore the specified snapshot
 * @param reqSnapshot
 * @throws IOException
 */
public void restoreSnapshot(SnapshotDescription reqSnapshot) throws IOException {
  FileSystem fs = master.getMasterFileSystem().getFileSystem();
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(reqSnapshot, rootDir);
  MasterCoprocessorHost cpHost = master.getCoprocessorHost();

  // check if the snapshot exists
  if (!fs.exists(snapshotDir)) {
    LOG.error("A Snapshot named '" + reqSnapshot.getName() + "' does not exist.");
    throw new SnapshotDoesNotExistException(reqSnapshot);
  }

  // read snapshot information
  SnapshotDescription fsSnapshot = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
  HTableDescriptor snapshotTableDesc = FSTableDescriptors.getTableDescriptor(fs, snapshotDir);
  String tableName = reqSnapshot.getTable();

  // stop tracking "abandoned" handlers
  cleanupSentinels();

  // Verify snapshot validity
  SnapshotReferenceUtil.verifySnapshot(master.getConfiguration(), fs, snapshotDir, fsSnapshot);

  // Execute the restore/clone operation
  if (MetaReader.tableExists(master.getCatalogTracker(), tableName)) {
    if (master.getAssignmentManager().getZKTable().isEnabledTable(fsSnapshot.getTable())) {
      throw new UnsupportedOperationException("Table '" +
        fsSnapshot.getTable() + "' must be disabled in order to perform a restore operation.");
    }

    // call coproc pre hook
    if (cpHost != null) {
      cpHost.preRestoreSnapshot(reqSnapshot, snapshotTableDesc);
    }
    restoreSnapshot(fsSnapshot, snapshotTableDesc);
    LOG.info("Restore snapshot=" + fsSnapshot.getName() + " as table=" + tableName);

    if (cpHost != null) {
      cpHost.postRestoreSnapshot(reqSnapshot, snapshotTableDesc);
    }
  } else {
    HTableDescriptor htd = RestoreSnapshotHelper.cloneTableSchema(snapshotTableDesc,
                                                       Bytes.toBytes(tableName));
    if (cpHost != null) {
      cpHost.preCloneSnapshot(reqSnapshot, htd);
    }
    cloneSnapshot(fsSnapshot, htd);
    LOG.info("Clone snapshot=" + fsSnapshot.getName() + " as table=" + tableName);

    if (cpHost != null) {
      cpHost.postCloneSnapshot(reqSnapshot, htd);
    }
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:59,代码来源:SnapshotManager.java

示例12: restoreSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Restore the specified snapshot
 * @param reqSnapshot
 * @throws IOException
 */
public void restoreSnapshot(SnapshotDescription reqSnapshot) throws IOException {
  FileSystem fs = master.getMasterFileSystem().getFileSystem();
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(reqSnapshot, rootDir);
  MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost();

  // check if the snapshot exists
  if (!fs.exists(snapshotDir)) {
    LOG.error("A Snapshot named '" + reqSnapshot.getName() + "' does not exist.");
    throw new SnapshotDoesNotExistException(reqSnapshot);
  }

  // read snapshot information
  SnapshotDescription fsSnapshot = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
  SnapshotManifest manifest = SnapshotManifest.open(master.getConfiguration(), fs,
      snapshotDir, fsSnapshot);
  HTableDescriptor snapshotTableDesc = manifest.getTableDescriptor();
  TableName tableName = TableName.valueOf(reqSnapshot.getTable());

  // stop tracking "abandoned" handlers
  cleanupSentinels();

  // Verify snapshot validity
  SnapshotReferenceUtil.verifySnapshot(master.getConfiguration(), fs, manifest);

  // Execute the restore/clone operation
  if (MetaTableAccessor.tableExists(master.getConnection(), tableName)) {
    if (master.getAssignmentManager().getTableStateManager().isTableState(
        TableName.valueOf(fsSnapshot.getTable()), ZooKeeperProtos.Table.State.ENABLED)) {
      throw new UnsupportedOperationException("Table '" +
          TableName.valueOf(fsSnapshot.getTable()) + "' must be disabled in order to " +
          "perform a restore operation" +
          ".");
    }

    // call coproc pre hook
    if (cpHost != null) {
      cpHost.preRestoreSnapshot(reqSnapshot, snapshotTableDesc);
    }
    restoreSnapshot(fsSnapshot, snapshotTableDesc);
    LOG.info("Restore snapshot=" + fsSnapshot.getName() + " as table=" + tableName);

    if (cpHost != null) {
      cpHost.postRestoreSnapshot(reqSnapshot, snapshotTableDesc);
    }
  } else {
    HTableDescriptor htd = RestoreSnapshotHelper.cloneTableSchema(snapshotTableDesc, tableName);
    if (cpHost != null) {
      cpHost.preCloneSnapshot(reqSnapshot, htd);
    }
    cloneSnapshot(fsSnapshot, htd);
    LOG.info("Clone snapshot=" + fsSnapshot.getName() + " as table=" + tableName);

    if (cpHost != null) {
      cpHost.postCloneSnapshot(reqSnapshot, htd);
    }
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:63,代码来源:SnapshotManager.java

示例13: getSplits

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
public static List<InputSplit> getSplits(Configuration conf) throws IOException {
  String snapshotName = getSnapshotName(conf);

  Path rootDir = FSUtils.getRootDir(conf);
  FileSystem fs = rootDir.getFileSystem(conf);

  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  SnapshotDescription snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
  SnapshotManifest manifest = SnapshotManifest.open(conf, fs, snapshotDir, snapshotDesc);
  List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests();
  if (regionManifests == null) {
    throw new IllegalArgumentException("Snapshot seems empty");
  }

  // load table descriptor
  HTableDescriptor htd = manifest.getTableDescriptor();

  // TODO: mapred does not support scan as input API. Work around for now.
  Scan scan = null;
  if (conf.get(TableInputFormat.SCAN) != null) {
    scan = TableMapReduceUtil.convertStringToScan(conf.get(TableInputFormat.SCAN));
  } else if (conf.get(org.apache.hadoop.hbase.mapred.TableInputFormat.COLUMN_LIST) != null) {
    String[] columns =
      conf.get(org.apache.hadoop.hbase.mapred.TableInputFormat.COLUMN_LIST).split(" ");
    scan = new Scan();
    for (String col : columns) {
      scan.addFamily(Bytes.toBytes(col));
    }
  } else {
    throw new IllegalArgumentException("Unable to create scan");
  }
  // the temp dir where the snapshot is restored
  Path restoreDir = new Path(conf.get(RESTORE_DIR_KEY));
  Path tableDir = FSUtils.getTableDir(restoreDir, htd.getTableName());

  List<InputSplit> splits = new ArrayList<InputSplit>();
  for (SnapshotRegionManifest regionManifest : regionManifests) {
    // load region descriptor
    HRegionInfo hri = HRegionInfo.convert(regionManifest.getRegionInfo());

    if (CellUtil.overlappingKeys(scan.getStartRow(), scan.getStopRow(),
      hri.getStartKey(), hri.getEndKey())) {
      // compute HDFS locations from snapshot files (which will get the locations for
      // referred hfiles)
      List<String> hosts = getBestLocations(conf,
        HRegion.computeHDFSBlocksDistribution(conf, htd, hri, tableDir));

      int len = Math.min(3, hosts.size());
      hosts = hosts.subList(0, len);
      splits.add(new InputSplit(htd, hri, hosts));
    }
  }

  return splits;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:56,代码来源:TableSnapshotInputFormatImpl.java

示例14: restoreSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Restore the specified snapshot
 * @param reqSnapshot
 * @throws IOException
 */
public void restoreSnapshot(SnapshotDescription reqSnapshot) throws IOException {
  FileSystem fs = master.getMasterFileSystem().getFileSystem();
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(reqSnapshot, rootDir);
  MasterCoprocessorHost cpHost = master.getCoprocessorHost();

  // check if the snapshot exists
  if (!fs.exists(snapshotDir)) {
    LOG.error("A Snapshot named '" + reqSnapshot.getName() + "' does not exist.");
    throw new SnapshotDoesNotExistException(reqSnapshot);
  }

  // read snapshot information
  SnapshotDescription fsSnapshot = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
  HTableDescriptor snapshotTableDesc =
      FSTableDescriptors.getTableDescriptorFromFs(fs, snapshotDir);
  TableName tableName = TableName.valueOf(reqSnapshot.getTable());

  // stop tracking "abandoned" handlers
  cleanupSentinels();

  // Verify snapshot validity
  SnapshotReferenceUtil.verifySnapshot(master.getConfiguration(), fs, snapshotDir, fsSnapshot);

  // Execute the restore/clone operation
  if (MetaReader.tableExists(master.getCatalogTracker(), tableName)) {
    if (master.getAssignmentManager().getZKTable().isEnabledTable(
        TableName.valueOf(fsSnapshot.getTable()))) {
      throw new UnsupportedOperationException("Table '" +
          TableName.valueOf(fsSnapshot.getTable()) + "' must be disabled in order to " +
          "perform a restore operation" +
          ".");
    }

    // call coproc pre hook
    if (cpHost != null) {
      cpHost.preRestoreSnapshot(reqSnapshot, snapshotTableDesc);
    }
    restoreSnapshot(fsSnapshot, snapshotTableDesc);
    LOG.info("Restore snapshot=" + fsSnapshot.getName() + " as table=" + tableName);

    if (cpHost != null) {
      cpHost.postRestoreSnapshot(reqSnapshot, snapshotTableDesc);
    }
  } else {
    HTableDescriptor htd = RestoreSnapshotHelper.cloneTableSchema(snapshotTableDesc, tableName);
    if (cpHost != null) {
      cpHost.preCloneSnapshot(reqSnapshot, htd);
    }
    cloneSnapshot(fsSnapshot, htd);
    LOG.info("Clone snapshot=" + fsSnapshot.getName() + " as table=" + tableName);

    if (cpHost != null) {
      cpHost.postCloneSnapshot(reqSnapshot, htd);
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:62,代码来源:SnapshotManager.java

示例15: getSplits

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
public static List<InputSplit> getSplits(Configuration conf) throws IOException {
  String snapshotName = getSnapshotName(conf);

  Path rootDir = new Path(conf.get(HConstants.HBASE_DIR));
  FileSystem fs = rootDir.getFileSystem(conf);

  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  HBaseProtos.SnapshotDescription snapshotDesc =
    SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);

  Set<String> snapshotRegionNames =
    SnapshotReferenceUtil.getSnapshotRegionNames(fs, snapshotDir);
  if (snapshotRegionNames == null) {
    throw new IllegalArgumentException("Snapshot seems empty");
  }

  // load table descriptor
  HTableDescriptor htd = FSTableDescriptors.getTableDescriptorFromFs(fs,
    snapshotDir);

  // TODO: mapred does not support scan as input API. Work around for now.
  Scan scan = null;
  if (conf.get(TableInputFormat.SCAN) != null) {
    scan = TableMapReduceUtil.convertStringToScan(conf.get(TableInputFormat.SCAN));
  } else if (conf.get(org.apache.hadoop.hbase.mapred.TableInputFormat.COLUMN_LIST) != null) {
    String[] columns =
      conf.get(org.apache.hadoop.hbase.mapred.TableInputFormat.COLUMN_LIST).split(" ");
    scan = new Scan();
    for (String col : columns) {
      scan.addFamily(Bytes.toBytes(col));
    }
  } else {
    throw new IllegalArgumentException("Unable to create scan");
  }
  Path tableDir = new Path(conf.get(TABLE_DIR_KEY));

  List<InputSplit> splits = new ArrayList<InputSplit>();
  for (String regionName : snapshotRegionNames) {
    // load region descriptor
    Path regionDir = new Path(snapshotDir, regionName);
    HRegionInfo hri = HRegionFileSystem.loadRegionInfoFileContent(fs,
      regionDir);

    if (CellUtil.overlappingKeys(scan.getStartRow(), scan.getStopRow(),
      hri.getStartKey(), hri.getEndKey())) {
      // compute HDFS locations from snapshot files (which will get the locations for
      // referred hfiles)
      List<String> hosts = getBestLocations(conf,
        HRegion.computeHDFSBlocksDistribution(conf, htd, hri, tableDir));

      int len = Math.min(3, hosts.size());
      hosts = hosts.subList(0, len);
      splits.add(new InputSplit(regionName, hosts));
    }
  }

  return splits;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:59,代码来源:TableSnapshotInputFormatImpl.java


注:本文中的org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils.readSnapshotInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。