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


Java SnapshotDescription.getName方法代码示例

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


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

示例1: deleteSnapshot

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription; //导入方法依赖的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

示例2: FlushSnapshotSubprocedure

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription; //导入方法依赖的package包/类
public FlushSnapshotSubprocedure(ProcedureMember member,
    ForeignExceptionDispatcher errorListener, long wakeFrequency, long timeout,
    List<Region> regions, SnapshotDescription snapshot,
    SnapshotSubprocedurePool taskManager) {
  super(member, snapshot.getName(), errorListener, wakeFrequency, timeout);
  this.snapshot = snapshot;

  if (this.snapshot.getType() == SnapshotDescription.Type.SKIPFLUSH) {
    snapshotSkipFlush = true;
  }
  this.regions = regions;
  this.taskManager = taskManager;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:FlushSnapshotSubprocedure.java

示例3: addRegion

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription; //导入方法依赖的package包/类
private Path[] addRegion(final SnapshotDescription desc) throws IOException {
  if (this.snapshotted == tableRegions.length) {
    throw new UnsupportedOperationException("No more regions in the table");
  }

  RegionData regionData = tableRegions[this.snapshotted++];
  ForeignExceptionDispatcher monitor = new ForeignExceptionDispatcher(desc.getName());
  SnapshotManifest manifest = SnapshotManifest.create(conf, fs, snapshotDir, desc, monitor);
  manifest.addRegion(regionData.tableDir, regionData.hri);
  return regionData.files;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:SnapshotTestingUtils.java

示例4: isSnapshotDone

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription; //导入方法依赖的package包/类
/**
 * Check if the specified snapshot is done
 *
 * @param expected
 * @return true if snapshot is ready to be restored, false if it is still being taken.
 * @throws IOException IOException if error from HDFS or RPC
 * @throws UnknownSnapshotException if snapshot is invalid or does not exist.
 */
public boolean isSnapshotDone(SnapshotDescription expected) throws IOException {
  // check the request to make sure it has a snapshot
  if (expected == null) {
    throw new UnknownSnapshotException(
       "No snapshot name passed in request, can't figure out which snapshot you want to check.");
  }

  String ssString = ClientSnapshotDescriptionUtils.toString(expected);

  // check to see if the sentinel exists,
  // and if the task is complete removes it from the in-progress snapshots map.
  SnapshotSentinel handler = removeSentinelIfFinished(this.snapshotHandlers, expected);

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

  if (handler == null) {
    // If there's no handler in the in-progress map, it means one of the following:
    //   - someone has already requested the snapshot state
    //   - the requested snapshot was completed long time ago (cleanupSentinels() timeout)
    //   - the snapshot was never requested
    // In those cases returns to the user the "done state" if the snapshots exists on disk,
    // otherwise raise an exception saying that the snapshot is not running and doesn't exist.
    if (!isSnapshotCompleted(expected)) {
      throw new UnknownSnapshotException("Snapshot " + ssString
          + " is not currently running or one of the known completed snapshots.");
    }
    // was done, return true;
    return true;
  }

  // pass on any failure we find in the sentinel
  try {
    handler.rethrowExceptionIfFailed();
  } catch (ForeignException e) {
    // Give some procedure info on an exception.
    String status;
    Procedure p = coordinator.getProcedure(expected.getName());
    if (p != null) {
      status = p.getStatus();
    } else {
      status = expected.getName() + " not found in proclist " + coordinator.getProcedureNames();
    }
    throw new HBaseSnapshotException("Snapshot " + ssString +  " had an error.  " + status, e,
        expected);
  }

  // check to see if we are done
  if (handler.isFinished()) {
    LOG.debug("Snapshot '" + ssString + "' has completed, notifying client.");
    return true;
  } else if (LOG.isDebugEnabled()) {
    LOG.debug("Snapshoting '" + ssString + "' is still in progress!");
  }
  return false;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:65,代码来源:SnapshotManager.java

示例5: buildSubprocedure

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription; //导入方法依赖的package包/类
/**
 * If in a running state, creates the specified subprocedure for handling an online snapshot.
 *
 * Because this gets the local list of regions to snapshot and not the set the master had,
 * there is a possibility of a race where regions may be missed.  This detected by the master in
 * the snapshot verification step.
 *
 * @param snapshot
 * @return Subprocedure to submit to the ProcedureMemeber.
 */
public Subprocedure buildSubprocedure(SnapshotDescription snapshot) {

  // don't run a snapshot if the parent is stop(ping)
  if (rss.isStopping() || rss.isStopped()) {
    throw new IllegalStateException("Can't start snapshot on RS: " + rss.getServerName()
        + ", because stopping/stopped!");
  }

  // check to see if this server is hosting any regions for the snapshots
  // check to see if we have regions for the snapshot
  List<Region> involvedRegions;
  try {
    involvedRegions = getRegionsToSnapshot(snapshot);
  } catch (IOException e1) {
    throw new IllegalStateException("Failed to figure out if we should handle a snapshot - "
        + "something has gone awry with the online regions.", e1);
  }

  // We need to run the subprocedure even if we have no relevant regions.  The coordinator
  // expects participation in the procedure and without sending message the snapshot attempt
  // will hang and fail.

  LOG.debug("Launching subprocedure for snapshot " + snapshot.getName() + " from table "
      + snapshot.getTable() + " type " + snapshot.getType());
  ForeignExceptionDispatcher exnDispatcher = new ForeignExceptionDispatcher(snapshot.getName());
  Configuration conf = rss.getConfiguration();
  long timeoutMillis = conf.getLong(SNAPSHOT_TIMEOUT_MILLIS_KEY,
      SNAPSHOT_TIMEOUT_MILLIS_DEFAULT);
  long wakeMillis = conf.getLong(SNAPSHOT_REQUEST_WAKE_MILLIS_KEY,
      SNAPSHOT_REQUEST_WAKE_MILLIS_DEFAULT);

  switch (snapshot.getType()) {
  case FLUSH:
    SnapshotSubprocedurePool taskManager =
      new SnapshotSubprocedurePool(rss.getServerName().toString(), conf, rss);
    return new FlushSnapshotSubprocedure(member, exnDispatcher, wakeMillis,
        timeoutMillis, involvedRegions, snapshot, taskManager);
  case SKIPFLUSH:
      /*
       * This is to take an online-snapshot without force a coordinated flush to prevent pause
       * The snapshot type is defined inside the snapshot description. FlushSnapshotSubprocedure
       * should be renamed to distributedSnapshotSubprocedure, and the flush() behavior can be
       * turned on/off based on the flush type.
       * To minimized the code change, class name is not changed.
       */
      SnapshotSubprocedurePool taskManager2 =
          new SnapshotSubprocedurePool(rss.getServerName().toString(), conf, rss);
      return new FlushSnapshotSubprocedure(member, exnDispatcher, wakeMillis,
          timeoutMillis, involvedRegions, snapshot, taskManager2);

  default:
    throw new UnsupportedOperationException("Unrecognized snapshot type:" + snapshot.getType());
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:65,代码来源:RegionServerSnapshotManager.java

示例6: internalRestoreSnapshot

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription; //导入方法依赖的package包/类
/**
 * Execute Restore/Clone snapshot and wait for the server to complete (blocking).
 * To check if the cloned table exists, use {@link #isTableAvailable} -- it is not safe to
 * create an HTable instance to this table before it is available.
 * @param snapshotName snapshot to restore
 * @param tableName table name to restore the snapshot on
 * @throws IOException if a remote or network exception occurs
 * @throws RestoreSnapshotException if snapshot failed to be restored
 * @throws IllegalArgumentException if the restore request is formatted incorrectly
 */
private void internalRestoreSnapshot(final String snapshotName, final TableName
    tableName)
    throws IOException, RestoreSnapshotException {
  SnapshotDescription snapshot = SnapshotDescription.newBuilder()
      .setName(snapshotName).setTable(tableName.getNameAsString()).build();

  // actually restore the snapshot
  internalRestoreSnapshotAsync(snapshot);

  final IsRestoreSnapshotDoneRequest request = IsRestoreSnapshotDoneRequest.newBuilder()
      .setSnapshot(snapshot).build();
  IsRestoreSnapshotDoneResponse done = IsRestoreSnapshotDoneResponse.newBuilder()
      .setDone(false).buildPartial();
  final long maxPauseTime = 5000;
  int tries = 0;
  while (!done.getDone()) {
    try {
      // sleep a backoff <= pauseTime amount
      long sleep = getPauseTime(tries++);
      sleep = sleep > maxPauseTime ? maxPauseTime : sleep;
      LOG.debug(tries + ") Sleeping: " + sleep + " ms while we wait for snapshot restore to complete.");
      Thread.sleep(sleep);
    } catch (InterruptedException e) {
      throw (InterruptedIOException)new InterruptedIOException("Interrupted").initCause(e);
    }
    LOG.debug("Getting current status of snapshot restore from master...");
    done = executeCallable(new MasterCallable<IsRestoreSnapshotDoneResponse>(
        getConnection()) {
      @Override
      public IsRestoreSnapshotDoneResponse call(int callTimeout) throws ServiceException {
        PayloadCarryingRpcController controller = rpcControllerFactory.newController();
        controller.setCallTimeout(callTimeout);
        return master.isRestoreSnapshotDone(controller, request);
      }
    });
  }
  if (!done.getDone()) {
    throw new RestoreSnapshotException("Snapshot '" + snapshot.getName() + "' wasn't restored.");
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:51,代码来源:HBaseAdmin.java

示例7: SnapshotDoesNotExistException

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription; //导入方法依赖的package包/类
/**
 * @param desc expected snapshot to find
 */
public SnapshotDoesNotExistException(SnapshotDescription desc) {
  super("Snapshot '" + desc.getName() +"' doesn't exist on the filesystem", desc);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:7,代码来源:SnapshotDoesNotExistException.java


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