001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.master;
019
020import org.apache.hadoop.hbase.errorhandling.ForeignException;
021import org.apache.yetus.audience.InterfaceAudience;
022import org.apache.yetus.audience.InterfaceStability;
023
024import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription;
025
026/**
027 * Watch the current snapshot under process
028 */
029@InterfaceAudience.Private
030@InterfaceStability.Unstable
031public interface SnapshotSentinel {
032
033  /**
034   * Check to see if the snapshot is finished, where finished may be success or failure.
035   * @return <tt>false</tt> if the snapshot is still in progress, <tt>true</tt> if the snapshot has
036   *         finished
037   */
038  boolean isFinished();
039
040  /** Returns -1 if the snapshot is in progress, otherwise the completion timestamp. */
041  long getCompletionTimestamp();
042
043  /**
044   * Actively cancel a running snapshot.
045   * @param why Reason for cancellation.
046   */
047  void cancel(String why);
048
049  /** Returns the description of the snapshot being run */
050  SnapshotDescription getSnapshot();
051
052  /**
053   * Get the exception that caused the snapshot to fail, if the snapshot has failed.
054   * @return {@link ForeignException} that caused the snapshot to fail, or <tt>null</tt> if the
055   *         snapshot is still in progress or has succeeded
056   */
057  ForeignException getExceptionIfFailed();
058
059  /**
060   * Rethrow the exception returned by {@link SnapshotSentinel#getExceptionIfFailed}. If there is no
061   * exception this is a no-op.
062   * @throws ForeignException all exceptions from remote sources are procedure exceptions
063   */
064  void rethrowExceptionIfFailed() throws ForeignException;
065}