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  package org.apache.hadoop.hbase.regionserver.wal;
20  
21  import java.io.IOException;
22  
23  import org.apache.hadoop.hbase.classification.InterfaceAudience;
24  import org.apache.hadoop.fs.Path;
25  import org.apache.hadoop.hbase.HRegionInfo;
26  import org.apache.hadoop.hbase.HTableDescriptor;
27  
28  /**
29   * Get notification of {@link FSHLog}/WAL log events. The invocations are inline
30   * so make sure your implementation is fast else you'll slow hbase.
31   */
32  @InterfaceAudience.Private
33  public interface WALActionsListener {
34  
35    /**
36     * The WAL is going to be rolled. The oldPath can be null if this is
37     * the first log file from the regionserver.
38     * @param oldPath the path to the old hlog
39     * @param newPath the path to the new hlog
40     */
41    void preLogRoll(Path oldPath, Path newPath) throws IOException;
42  
43    /**
44     * The WAL has been rolled. The oldPath can be null if this is
45     * the first log file from the regionserver.
46     * @param oldPath the path to the old hlog
47     * @param newPath the path to the new hlog
48     */
49    void postLogRoll(Path oldPath, Path newPath) throws IOException;
50  
51    /**
52     * The WAL is going to be archived.
53     * @param oldPath the path to the old hlog
54     * @param newPath the path to the new hlog
55     */
56    void preLogArchive(Path oldPath, Path newPath) throws IOException;
57  
58    /**
59     * The WAL has been archived.
60     * @param oldPath the path to the old hlog
61     * @param newPath the path to the new hlog
62     */
63    void postLogArchive(Path oldPath, Path newPath) throws IOException;
64  
65    /**
66     * A request was made that the WAL be rolled.
67     */
68    void logRollRequested();
69  
70    /**
71     * The WAL is about to close.
72     */
73    void logCloseRequested();
74  
75    /**
76    * Called before each write.
77    * @param info
78    * @param logKey
79    * @param logEdit
80    */
81    void visitLogEntryBeforeWrite(
82      HRegionInfo info, HLogKey logKey, WALEdit logEdit
83    );
84  
85    /**
86     *
87     * @param htd
88     * @param logKey
89     * @param logEdit
90     * TODO: Retire this in favor of {@link #visitLogEntryBeforeWrite(HRegionInfo, HLogKey, WALEdit)}
91     * It only exists to get scope when replicating.  Scope should be in the HLogKey and not need
92     * us passing in a <code>htd</code>.
93     */
94    void visitLogEntryBeforeWrite(
95      HTableDescriptor htd, HLogKey logKey, WALEdit logEdit
96    );
97  }