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.yetus.audience.InterfaceAudience; 021import org.apache.yetus.audience.InterfaceStability; 022import org.apache.hadoop.hbase.errorhandling.ForeignException; 023import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription; 024 025/** 026 * Watch the current snapshot under process 027 */ 028@InterfaceAudience.Private 029@InterfaceStability.Unstable 030public interface SnapshotSentinel { 031 032 /** 033 * Check to see if the snapshot is finished, where finished may be success or failure. 034 * @return <tt>false</tt> if the snapshot is still in progress, <tt>true</tt> if the snapshot has 035 * finished 036 */ 037 boolean isFinished(); 038 039 /** 040 * @return -1 if the snapshot is in progress, otherwise the completion timestamp. 041 */ 042 long getCompletionTimestamp(); 043 044 /** 045 * Actively cancel a running snapshot. 046 * @param why Reason for cancellation. 047 */ 048 void cancel(String why); 049 050 /** 051 * @return the description of the snapshot being run 052 */ 053 SnapshotDescription getSnapshot(); 054 055 /** 056 * Get the exception that caused the snapshot to fail, if the snapshot has failed. 057 * @return {@link ForeignException} that caused the snapshot to fail, or <tt>null</tt> if the 058 * snapshot is still in progress or has succeeded 059 */ 060 ForeignException getExceptionIfFailed(); 061 062 /** 063 * Rethrow the exception returned by {@link SnapshotSentinel#getExceptionIfFailed}. 064 * If there is no exception this is a no-op. 065 * 066 * @throws ForeignException all exceptions from remote sources are procedure exceptions 067 */ 068 void rethrowExceptionIfFailed() throws ForeignException; 069}