Examples of SnapshotSentinel


Examples of org.apache.hadoop.hbase.master.SnapshotSentinel

   *
   * @param tableName table under restore
   * @return <tt>true</tt> if there is a restore in progress of the specified table.
   */
  private synchronized boolean isRestoringTable(final String tableName) {
    SnapshotSentinel sentinel = this.restoreHandlers.get(tableName);
    return(sentinel != null && !sentinel.isFinished());
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.master.SnapshotSentinel

   * @throws IOException if there was a failure during the restore
   */
  public boolean isRestoreDone(final SnapshotDescription snapshot) throws IOException {
    // check to see if the sentinel exists,
    // and if the task is complete removes it from the in-progress restore map.
    SnapshotSentinel sentinel = removeSentinelIfFinished(this.restoreHandlers, snapshot);

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

    if (sentinel == null) {
      // there is no sentinel so restore is not in progress.
      return true;
    }

    LOG.debug("Verify snapshot=" + snapshot.getName() + " against="
        + sentinel.getSnapshot().getName() + " table=" + snapshot.getTable());

    // If the restore is failed, rethrow the exception
    sentinel.rethrowExceptionIfFailed();

    // check to see if we are done
    if (sentinel.isFinished()) {
      LOG.debug("Restore snapshot=" + SnapshotDescriptionUtils.toString(snapshot) +
          " has completed. Notifying the client.");
      return true;
    }

View Full Code Here

Examples of org.apache.hadoop.hbase.master.SnapshotSentinel

   * @param snapshot snapshot description
   * @return null if doesn't match, else a live handler.
   */
  private synchronized SnapshotSentinel removeSentinelIfFinished(
      final Map<String, SnapshotSentinel> sentinels, final SnapshotDescription snapshot) {
    SnapshotSentinel h = sentinels.get(snapshot.getTable());
    if (h == null) {
      return null;
    }

    if (!h.getSnapshot().getName().equals(snapshot.getName())) {
      // specified snapshot is to the one currently running
      return null;
    }

    // Remove from the "in-progress" list once completed
    if (h.isFinished()) {
      sentinels.remove(snapshot.getTable());
    }

    return h;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.master.SnapshotSentinel

  private synchronized void cleanupSentinels(final Map<String, SnapshotSentinel> sentinels) {
    long currentTime = EnvironmentEdgeManager.currentTimeMillis();
    Iterator<Map.Entry<String, SnapshotSentinel>> it = sentinels.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry<String, SnapshotSentinel> entry = it.next();
      SnapshotSentinel sentinel = entry.getValue();
      if (sentinel.isFinished() &&
          (currentTime - sentinel.getCompletionTimestamp()) > SNAPSHOT_SENTINELS_CLEANUP_TIMEOUT)
      {
        it.remove();
      }
    }
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.master.SnapshotSentinel

    String ssString = SnapshotDescriptionUtils.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!");
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.master.SnapshotSentinel

   * limitation only allowing a single snapshot per table at a time.
   * @param tableName name of the table being snapshotted.
   * @return <tt>true</tt> if there is a snapshot in progress on the specified table.
   */
  synchronized boolean isTakingSnapshot(final String tableName) {
    SnapshotSentinel handler = this.snapshotHandlers.get(tableName);
    return handler != null && !handler.isFinished();
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.master.SnapshotSentinel

    FileSystem fs = master.getMasterFileSystem().getFileSystem();
    Path workingDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(snapshot, rootDir);

    // make sure we aren't already running a snapshot
    if (isTakingSnapshot(snapshot.getTable())) {
      SnapshotSentinel handler = this.snapshotHandlers.get(snapshot.getTable());
      throw new SnapshotCreationException("Rejected taking "
          + SnapshotDescriptionUtils.toString(snapshot)
          + " because we are already running another snapshot "
          + SnapshotDescriptionUtils.toString(handler.getSnapshot()), snapshot);
    }

    // make sure we aren't running a restore on the same table
    if (isRestoringTable(snapshot.getTable())) {
      SnapshotSentinel handler = restoreHandlers.get(snapshot.getTable());
      throw new SnapshotCreationException("Rejected taking "
          + SnapshotDescriptionUtils.toString(snapshot)
          + " because we are already have a restore in progress on the same snapshot "
          + SnapshotDescriptionUtils.toString(handler.getSnapshot()), snapshot);
    }

    try {
      // delete the working directory, since we aren't running the snapshot. Likely leftovers
      // from a failed attempt.
View Full Code Here

Examples of org.apache.hadoop.hbase.master.SnapshotSentinel

   *
   * @param tableName table under restore
   * @return <tt>true</tt> if there is a restore in progress of the specified table.
   */
  private synchronized boolean isRestoringTable(final String tableName) {
    SnapshotSentinel sentinel = this.restoreHandlers.get(tableName);
    return(sentinel != null && !sentinel.isFinished());
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.master.SnapshotSentinel

   * @throws IOException if there was a failure during the restore
   */
  public boolean isRestoreDone(final SnapshotDescription snapshot) throws IOException {
    // check to see if the sentinel exists,
    // and if the task is complete removes it from the in-progress restore map.
    SnapshotSentinel sentinel = removeSentinelIfFinished(this.restoreHandlers, snapshot);

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

    if (sentinel == null) {
      // there is no sentinel so restore is not in progress.
      return true;
    }

    LOG.debug("Verify snapshot=" + snapshot.getName() + " against="
        + sentinel.getSnapshot().getName() + " table=" + snapshot.getTable());

    // If the restore is failed, rethrow the exception
    sentinel.rethrowExceptionIfFailed();

    // check to see if we are done
    if (sentinel.isFinished()) {
      LOG.debug("Restore snapshot=" + SnapshotDescriptionUtils.toString(snapshot) +
          " has completed. Notifying the client.");
      return true;
    }

View Full Code Here

Examples of org.apache.hadoop.hbase.master.SnapshotSentinel

   * @param snapshot snapshot description
   * @return null if doesn't match, else a live handler.
   */
  private synchronized SnapshotSentinel removeSentinelIfFinished(
      final Map<String, SnapshotSentinel> sentinels, final SnapshotDescription snapshot) {
    SnapshotSentinel h = sentinels.get(snapshot.getTable());
    if (h == null) {
      return null;
    }

    if (!h.getSnapshot().getName().equals(snapshot.getName())) {
      // specified snapshot is to the one currently running
      return null;
    }

    // Remove from the "in-progress" list once completed
    if (h.isFinished()) {
      sentinels.remove(snapshot.getTable());
    }

    return h;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.