View Javadoc

1   /*
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   * http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  package org.apache.hadoop.hbase.coprocessor;
21  
22  import org.apache.hadoop.classification.InterfaceAudience;
23  import org.apache.hadoop.classification.InterfaceStability;
24  import org.apache.hadoop.hbase.Coprocessor;
25  import org.apache.hadoop.hbase.HRegionInfo;
26  import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
27  import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
28  
29  import java.io.IOException;
30  
31  /**
32   * It's provided to have a way for coprocessors to observe, rewrite,
33   * or skip WALEdits as they are being written to the WAL.
34   *
35   * {@link org.apache.hadoop.hbase.coprocessor.RegionObserver} provides
36   * hooks for adding logic for WALEdits in the region context during reconstruction,
37   *
38   * Defines coprocessor hooks for interacting with operations on the
39   * {@link org.apache.hadoop.hbase.regionserver.wal.HLog}.
40   */
41  @InterfaceAudience.Public
42  @InterfaceStability.Evolving
43  public interface WALObserver extends Coprocessor {
44  
45    /**
46     * Called before a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit}
47     * is writen to WAL.
48     *
49     * @param ctx
50     * @param info
51     * @param logKey
52     * @param logEdit
53     * @return true if default behavior should be bypassed, false otherwise
54     * @throws IOException
55     */
56    boolean preWALWrite(ObserverContext<WALCoprocessorEnvironment> ctx,
57        HRegionInfo info, HLogKey logKey, WALEdit logEdit) throws IOException;
58  
59    /**
60     * Called after a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit}
61     * is writen to WAL.
62     *
63     * @param ctx
64     * @param info
65     * @param logKey
66     * @param logEdit
67     * @throws IOException
68     */
69    void postWALWrite(ObserverContext<WALCoprocessorEnvironment> ctx,
70        HRegionInfo info, HLogKey logKey, WALEdit logEdit) throws IOException;
71  }