Search in sources :

Example 1 with UnknownSnapshotException

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

the class SnapshotManager method isSnapshotDone.

/**
   * 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) {
        // 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, ProtobufUtil.createSnapshotDesc(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;
}
Also used : UnknownSnapshotException(org.apache.hadoop.hbase.snapshot.UnknownSnapshotException) SnapshotSentinel(org.apache.hadoop.hbase.master.SnapshotSentinel) ForeignException(org.apache.hadoop.hbase.errorhandling.ForeignException) RestoreSnapshotProcedure(org.apache.hadoop.hbase.master.procedure.RestoreSnapshotProcedure) CloneSnapshotProcedure(org.apache.hadoop.hbase.master.procedure.CloneSnapshotProcedure) Procedure(org.apache.hadoop.hbase.procedure.Procedure) HBaseSnapshotException(org.apache.hadoop.hbase.snapshot.HBaseSnapshotException)

Example 2 with UnknownSnapshotException

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

the class SnapshotManager method isSnapshotCompleted.

/**
   * Check to see if the snapshot is one of the currently completed snapshots
   * Returns true if the snapshot exists in the "completed snapshots folder".
   *
   * @param snapshot expected snapshot to check
   * @return <tt>true</tt> if the snapshot is stored on the {@link FileSystem}, <tt>false</tt> if is
   *         not stored
   * @throws IOException if the filesystem throws an unexpected exception,
   * @throws IllegalArgumentException if snapshot name is invalid.
   */
private boolean isSnapshotCompleted(SnapshotDescription snapshot) throws IOException {
    try {
        final Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshot, rootDir);
        FileSystem fs = master.getMasterFileSystem().getFileSystem();
        // check to see if the snapshot already exists
        return fs.exists(snapshotDir);
    } catch (IllegalArgumentException iae) {
        throw new UnknownSnapshotException("Unexpected exception thrown", iae);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) FileSystem(org.apache.hadoop.fs.FileSystem) MasterFileSystem(org.apache.hadoop.hbase.master.MasterFileSystem) UnknownSnapshotException(org.apache.hadoop.hbase.snapshot.UnknownSnapshotException)

Aggregations

UnknownSnapshotException (org.apache.hadoop.hbase.snapshot.UnknownSnapshotException)2 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 ForeignException (org.apache.hadoop.hbase.errorhandling.ForeignException)1 MasterFileSystem (org.apache.hadoop.hbase.master.MasterFileSystem)1 SnapshotSentinel (org.apache.hadoop.hbase.master.SnapshotSentinel)1 CloneSnapshotProcedure (org.apache.hadoop.hbase.master.procedure.CloneSnapshotProcedure)1 RestoreSnapshotProcedure (org.apache.hadoop.hbase.master.procedure.RestoreSnapshotProcedure)1 Procedure (org.apache.hadoop.hbase.procedure.Procedure)1 HBaseSnapshotException (org.apache.hadoop.hbase.snapshot.HBaseSnapshotException)1