View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.apache.hadoop.hbase.coprocessor;
20  
21  import java.io.IOException;
22  
23  import org.apache.hadoop.fs.Path;
24  import org.apache.hadoop.hbase.classification.InterfaceAudience;
25  import org.apache.hadoop.hbase.classification.InterfaceStability;
26  import org.apache.hadoop.hbase.CoprocessorEnvironment;
27  import org.apache.hadoop.hbase.HBaseInterfaceAudience;
28  import org.apache.hadoop.hbase.HRegionInfo;
29  import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
30  import org.apache.hadoop.hbase.wal.WALKey;
31  import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
32  
33  /**
34   * An abstract class that implements WALObserver.
35   * By extending it, you can create your own WAL observer without
36   * overriding all abstract methods of WALObserver.
37   */
38  @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
39  @InterfaceStability.Evolving
40  public class BaseWALObserver implements WALObserver {
41    @Override
42    public void start(CoprocessorEnvironment e) throws IOException { }
43  
44    @Override
45    public void stop(CoprocessorEnvironment e) throws IOException { }
46  
47    /**
48     * Implementers should override this method and leave the deprecated version as-is.
49     */
50    @Override
51    public boolean preWALWrite(ObserverContext<? extends WALCoprocessorEnvironment> ctx,
52        HRegionInfo info, WALKey logKey, WALEdit logEdit) throws IOException {
53      return false;
54    }
55  
56    @Override
57    public boolean preWALWrite(ObserverContext<WALCoprocessorEnvironment> ctx, HRegionInfo info,
58        HLogKey logKey, WALEdit logEdit) throws IOException {
59      return preWALWrite(ctx, info, (WALKey)logKey, logEdit);
60    }
61  
62    /**
63     * Implementers should override this method and leave the deprecated version as-is.
64     */
65    @Override
66    public void postWALWrite(ObserverContext<? extends WALCoprocessorEnvironment> ctx,
67        HRegionInfo info, WALKey logKey, WALEdit logEdit) throws IOException { }
68  
69    @Override
70    public void postWALWrite(ObserverContext<WALCoprocessorEnvironment> ctx, HRegionInfo info,
71        HLogKey logKey, WALEdit logEdit) throws IOException {
72      postWALWrite(ctx, info, (WALKey)logKey, logEdit);
73    }
74  
75    @Override
76    public void preWALRoll(ObserverContext<? extends WALCoprocessorEnvironment> ctx,
77        Path oldPath, Path newPath) throws IOException { }
78  
79    @Override
80    public void postWALRoll(ObserverContext<? extends WALCoprocessorEnvironment> ctx,
81        Path oldPath, Path newPath) throws IOException { }
82  }