Search in sources :

Example 1 with RestoreSnapshotProcedure

use of org.apache.hadoop.hbase.master.procedure.RestoreSnapshotProcedure in project hbase by apache.

the class SnapshotManager method restoreSnapshot.

/**
   * Restore the specified snapshot.
   * The restore will fail if the destination table has a snapshot or restore in progress.
   *
   * @param snapshot Snapshot Descriptor
   * @param hTableDescriptor Table Descriptor
   * @param nonceKey unique identifier to prevent duplicated RPC
   * @return procId the ID of the restore snapshot procedure
   */
private synchronized long restoreSnapshot(final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor, final NonceKey nonceKey) throws HBaseSnapshotException {
    final TableName tableName = hTableDescriptor.getTableName();
    // make sure we aren't running a snapshot on the same table
    if (isTakingSnapshot(tableName)) {
        throw new RestoreSnapshotException("Snapshot in progress on the restore table=" + tableName);
    }
    // make sure we aren't running a restore on the same table
    if (isRestoringTable(tableName)) {
        throw new RestoreSnapshotException("Restore already in progress on the table=" + tableName);
    }
    try {
        long procId = master.getMasterProcedureExecutor().submitProcedure(new RestoreSnapshotProcedure(master.getMasterProcedureExecutor().getEnvironment(), hTableDescriptor, snapshot), nonceKey);
        this.restoreTableToProcIdMap.put(tableName, procId);
        return procId;
    } catch (Exception e) {
        String msg = "Couldn't restore the snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot) + " on table=" + tableName;
        LOG.error(msg, e);
        throw new RestoreSnapshotException(msg, e);
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) RestoreSnapshotProcedure(org.apache.hadoop.hbase.master.procedure.RestoreSnapshotProcedure) SnapshotExistsException(org.apache.hadoop.hbase.snapshot.SnapshotExistsException) HBaseSnapshotException(org.apache.hadoop.hbase.snapshot.HBaseSnapshotException) RestoreSnapshotException(org.apache.hadoop.hbase.snapshot.RestoreSnapshotException) AccessDeniedException(org.apache.hadoop.hbase.security.AccessDeniedException) FileNotFoundException(java.io.FileNotFoundException) TablePartiallyOpenException(org.apache.hadoop.hbase.snapshot.TablePartiallyOpenException) SnapshotCreationException(org.apache.hadoop.hbase.snapshot.SnapshotCreationException) ForeignException(org.apache.hadoop.hbase.errorhandling.ForeignException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownSnapshotException(org.apache.hadoop.hbase.snapshot.UnknownSnapshotException) SnapshotDoesNotExistException(org.apache.hadoop.hbase.snapshot.SnapshotDoesNotExistException) RestoreSnapshotException(org.apache.hadoop.hbase.snapshot.RestoreSnapshotException)

Example 2 with RestoreSnapshotProcedure

use of org.apache.hadoop.hbase.master.procedure.RestoreSnapshotProcedure in project hbase by apache.

the class SnapshotManager method restoreSnapshot.

/**
 * Restore the specified snapshot. The restore will fail if the destination table has a snapshot
 * or restore in progress.
 * @param snapshot Snapshot Descriptor
 * @param tableDescriptor Table Descriptor
 * @param nonceKey unique identifier to prevent duplicated RPC
 * @param restoreAcl true to restore acl of snapshot
 * @return procId the ID of the restore snapshot procedure
 */
private synchronized long restoreSnapshot(final SnapshotDescription snapshot, final TableDescriptor tableDescriptor, final NonceKey nonceKey, final boolean restoreAcl) throws HBaseSnapshotException {
    final TableName tableName = tableDescriptor.getTableName();
    // make sure we aren't running a snapshot on the same table
    if (isTakingSnapshot(tableName)) {
        throw new RestoreSnapshotException("Snapshot in progress on the restore table=" + tableName);
    }
    // make sure we aren't running a restore on the same table
    if (isRestoringTable(tableName)) {
        throw new RestoreSnapshotException("Restore already in progress on the table=" + tableName);
    }
    try {
        long procId = master.getMasterProcedureExecutor().submitProcedure(new RestoreSnapshotProcedure(master.getMasterProcedureExecutor().getEnvironment(), tableDescriptor, snapshot, restoreAcl), nonceKey);
        this.restoreTableToProcIdMap.put(tableName, procId);
        return procId;
    } catch (Exception e) {
        String msg = "Couldn't restore the snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot) + " on table=" + tableName;
        LOG.error(msg, e);
        throw new RestoreSnapshotException(msg, e);
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) RestoreSnapshotProcedure(org.apache.hadoop.hbase.master.procedure.RestoreSnapshotProcedure) SnapshotExistsException(org.apache.hadoop.hbase.snapshot.SnapshotExistsException) HBaseSnapshotException(org.apache.hadoop.hbase.snapshot.HBaseSnapshotException) RestoreSnapshotException(org.apache.hadoop.hbase.snapshot.RestoreSnapshotException) AccessDeniedException(org.apache.hadoop.hbase.security.AccessDeniedException) FileNotFoundException(java.io.FileNotFoundException) TablePartiallyOpenException(org.apache.hadoop.hbase.snapshot.TablePartiallyOpenException) SnapshotCreationException(org.apache.hadoop.hbase.snapshot.SnapshotCreationException) ForeignException(org.apache.hadoop.hbase.errorhandling.ForeignException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownSnapshotException(org.apache.hadoop.hbase.snapshot.UnknownSnapshotException) SnapshotDoesNotExistException(org.apache.hadoop.hbase.snapshot.SnapshotDoesNotExistException) RestoreSnapshotException(org.apache.hadoop.hbase.snapshot.RestoreSnapshotException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 TableName (org.apache.hadoop.hbase.TableName)2 ForeignException (org.apache.hadoop.hbase.errorhandling.ForeignException)2 RestoreSnapshotProcedure (org.apache.hadoop.hbase.master.procedure.RestoreSnapshotProcedure)2 AccessDeniedException (org.apache.hadoop.hbase.security.AccessDeniedException)2 HBaseSnapshotException (org.apache.hadoop.hbase.snapshot.HBaseSnapshotException)2 RestoreSnapshotException (org.apache.hadoop.hbase.snapshot.RestoreSnapshotException)2 SnapshotCreationException (org.apache.hadoop.hbase.snapshot.SnapshotCreationException)2 SnapshotDoesNotExistException (org.apache.hadoop.hbase.snapshot.SnapshotDoesNotExistException)2 SnapshotExistsException (org.apache.hadoop.hbase.snapshot.SnapshotExistsException)2 TablePartiallyOpenException (org.apache.hadoop.hbase.snapshot.TablePartiallyOpenException)2 UnknownSnapshotException (org.apache.hadoop.hbase.snapshot.UnknownSnapshotException)2 KeeperException (org.apache.zookeeper.KeeperException)2