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.coprocessor;
019
020import java.io.IOException;
021import org.apache.hadoop.hbase.HBaseInterfaceAudience;
022import org.apache.yetus.audience.InterfaceAudience;
023import org.apache.yetus.audience.InterfaceStability;
024
025/**
026 * Coprocessors implement this interface to observe and mediate bulk load operations. <br>
027 * <br>
028 * <h3>Exception Handling</h3> For all functions, exception handling is done as follows:
029 * <ul>
030 * <li>Exceptions of type {@link IOException} are reported back to client.</li>
031 * <li>For any other kind of exception:
032 * <ul>
033 * <li>If the configuration {@link CoprocessorHost#ABORT_ON_ERROR_KEY} is set to true, then the
034 * server aborts.</li>
035 * <li>Otherwise, coprocessor is removed from the server and
036 * {@link org.apache.hadoop.hbase.DoNotRetryIOException} is returned to the client.</li>
037 * </ul>
038 * </li>
039 * </ul>
040 */
041@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
042@InterfaceStability.Evolving
043public interface BulkLoadObserver {
044  /**
045   * Called as part of SecureBulkLoadEndpoint.prepareBulkLoad() RPC call. It can't bypass the
046   * default action, e.g., ctx.bypass() won't have effect. If you need to get the region or table
047   * name, get it from the <code>ctx</code> as follows:
048   * <code>code>ctx.getEnvironment().getRegion()</code>. Use getRegionInfo to fetch the encodedName
049   * and use getDescriptor() to get the tableName.
050   * @param ctx the environment to interact with the framework and master
051   */
052  default void prePrepareBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx)
053    throws IOException {
054  }
055
056  /**
057   * Called as part of SecureBulkLoadEndpoint.cleanupBulkLoad() RPC call. It can't bypass the
058   * default action, e.g., ctx.bypass() won't have effect. If you need to get the region or table
059   * name, get it from the <code>ctx</code> as follows:
060   * <code>code>ctx.getEnvironment().getRegion()</code>. Use getRegionInfo to fetch the encodedName
061   * and use getDescriptor() to get the tableName.
062   * @param ctx the environment to interact with the framework and master
063   */
064  default void preCleanupBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx)
065    throws IOException {
066  }
067}