001/*
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020package org.apache.hadoop.hbase.coprocessor;
021
022import java.io.IOException;
023
024import org.apache.hadoop.hbase.HBaseInterfaceAudience;
025import org.apache.yetus.audience.InterfaceAudience;
026import org.apache.yetus.audience.InterfaceStability;
027
028/**
029 * Coprocessors implement this interface to observe and mediate bulk load operations.
030 * <br><br>
031 *
032 * <h3>Exception Handling</h3>
033 * For all functions, exception handling is done as follows:
034 * <ul>
035 *   <li>Exceptions of type {@link IOException} are reported back to client.</li>
036 *   <li>For any other kind of exception:
037 *     <ul>
038 *       <li>If the configuration {@link CoprocessorHost#ABORT_ON_ERROR_KEY} is set to true, then
039 *         the server aborts.</li>
040 *       <li>Otherwise, coprocessor is removed from the server and
041 *         {@link org.apache.hadoop.hbase.DoNotRetryIOException} is returned to the client.</li>
042 *     </ul>
043 *   </li>
044 * </ul>
045 */
046@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
047@InterfaceStability.Evolving
048public interface BulkLoadObserver {
049    /**
050      * Called as part of SecureBulkLoadEndpoint.prepareBulkLoad() RPC call.
051      * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
052      * If you need to get the region or table name, get it from the
053      * <code>ctx</code> as follows: <code>code>ctx.getEnvironment().getRegion()</code>. Use
054      * getRegionInfo to fetch the encodedName and use getTableDescriptor() to get the tableName.
055      * @param ctx the environment to interact with the framework and master
056      */
057    default void prePrepareBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx)
058    throws IOException {}
059
060    /**
061      * Called as part of SecureBulkLoadEndpoint.cleanupBulkLoad() RPC call.
062      * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
063      * If you need to get the region or table name, get it from the
064      * <code>ctx</code> as follows: <code>code>ctx.getEnvironment().getRegion()</code>. Use
065      * getRegionInfo to fetch the encodedName and use getTableDescriptor() to get the tableName.
066      * @param ctx the environment to interact with the framework and master
067      */
068    default void preCleanupBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx)
069    throws IOException {}
070}