Java 类org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsRestoreSnapshotDoneResponse 实例源码

项目:pbase    文件:MasterRpcServices.java   
/**
 * Returns the status of the requested snapshot restore/clone operation.
 * This method is not exposed to the user, it is just used internally by HBaseAdmin
 * to verify if the restore is completed.
 *
 * No exceptions are thrown if the restore is not running, the result will be "done".
 *
 * @return done <tt>true</tt> if the restore/clone operation is completed.
 * @throws ServiceException if the operation failed.
 */
@Override
public IsRestoreSnapshotDoneResponse isRestoreSnapshotDone(RpcController controller,
    IsRestoreSnapshotDoneRequest request) throws ServiceException {
  try {
    master.checkInitialized();
    SnapshotDescription snapshot = request.getSnapshot();
    IsRestoreSnapshotDoneResponse.Builder builder = IsRestoreSnapshotDoneResponse.newBuilder();
    boolean done = master.snapshotManager.isRestoreDone(snapshot);
    builder.setDone(done);
    return builder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:pbase    文件:HBaseAdmin.java   
/**
 * 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 {
        return master.isRestoreSnapshotDone(null, request);
      }
    });
  }
  if (!done.getDone()) {
    throw new RestoreSnapshotException("Snapshot '" + snapshot.getName() + "' wasn't restored.");
  }
}
项目:HIndex    文件:HMaster.java   
/**
 * Returns the status of the requested snapshot restore/clone operation.
 * This method is not exposed to the user, it is just used internally by HBaseAdmin
 * to verify if the restore is completed.
 *
 * No exceptions are thrown if the restore is not running, the result will be "done".
 *
 * @return done <tt>true</tt> if the restore/clone operation is completed.
 * @throws ServiceException if the operation failed.
 */
@Override
public IsRestoreSnapshotDoneResponse isRestoreSnapshotDone(RpcController controller,
    IsRestoreSnapshotDoneRequest request) throws ServiceException {
  try {
    SnapshotDescription snapshot = request.getSnapshot();
    IsRestoreSnapshotDoneResponse.Builder builder = IsRestoreSnapshotDoneResponse.newBuilder();
    boolean done = snapshotManager.isRestoreDone(snapshot);
    builder.setDone(done);
    return builder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:HIndex    文件:HBaseAdmin.java   
/**
 * 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) {
      LOG.debug("Interrupted while waiting for snapshot " + snapshot + " restore to complete");
      Thread.currentThread().interrupt();
    }
    LOG.debug("Getting current status of snapshot restore from master...");
    done = executeCallable(new MasterCallable<IsRestoreSnapshotDoneResponse>(
        getConnection()) {
      @Override
      public IsRestoreSnapshotDoneResponse call() throws ServiceException {
        return master.isRestoreSnapshotDone(null, request);
      }
    });
  }
  if (!done.getDone()) {
    throw new RestoreSnapshotException("Snapshot '" + snapshot.getName() + "' wasn't restored.");
  }
}
项目:PyroDB    文件:MasterRpcServices.java   
/**
 * Returns the status of the requested snapshot restore/clone operation.
 * This method is not exposed to the user, it is just used internally by HBaseAdmin
 * to verify if the restore is completed.
 *
 * No exceptions are thrown if the restore is not running, the result will be "done".
 *
 * @return done <tt>true</tt> if the restore/clone operation is completed.
 * @throws ServiceException if the operation failed.
 */
@Override
public IsRestoreSnapshotDoneResponse isRestoreSnapshotDone(RpcController controller,
    IsRestoreSnapshotDoneRequest request) throws ServiceException {
  try {
    master.checkInitialized();
    SnapshotDescription snapshot = request.getSnapshot();
    IsRestoreSnapshotDoneResponse.Builder builder = IsRestoreSnapshotDoneResponse.newBuilder();
    boolean done = master.snapshotManager.isRestoreDone(snapshot);
    builder.setDone(done);
    return builder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:PyroDB    文件:HBaseAdmin.java   
/**
 * 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 {
        return master.isRestoreSnapshotDone(null, request);
      }
    });
  }
  if (!done.getDone()) {
    throw new RestoreSnapshotException("Snapshot '" + snapshot.getName() + "' wasn't restored.");
  }
}
项目:c5    文件:HMaster.java   
/**
 * Returns the status of the requested snapshot restore/clone operation.
 * This method is not exposed to the user, it is just used internally by HBaseAdmin
 * to verify if the restore is completed.
 *
 * No exceptions are thrown if the restore is not running, the result will be "done".
 *
 * @return done <tt>true</tt> if the restore/clone operation is completed.
 * @throws ServiceException if the operation failed.
 */
@Override
public IsRestoreSnapshotDoneResponse isRestoreSnapshotDone(RpcController controller,
    IsRestoreSnapshotDoneRequest request) throws ServiceException {
  try {
    SnapshotDescription snapshot = request.getSnapshot();
    IsRestoreSnapshotDoneResponse.Builder builder = IsRestoreSnapshotDoneResponse.newBuilder();
    boolean done = snapshotManager.isRestoreDone(snapshot);
    builder.setDone(done);
    return builder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:c5    文件:HBaseAdmin.java   
/**
 * 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) {
      LOG.debug("Interrupted while waiting for snapshot " + snapshot + " restore to complete");
      Thread.currentThread().interrupt();
    }
    LOG.debug("Getting current status of snapshot restore from master...");
    done = executeCallable(new MasterCallable<IsRestoreSnapshotDoneResponse>(
        getConnection()) {
      @Override
      public IsRestoreSnapshotDoneResponse call() throws ServiceException {
        return master.isRestoreSnapshotDone(null, request);
      }
    });
  }
  if (!done.getDone()) {
    throw new RestoreSnapshotException("Snapshot '" + snapshot.getName() + "' wasn't restored.");
  }
}
项目:ditb    文件:HBaseAdmin.java   
/**
 * 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.");
  }
}