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.hbase.classification.InterfaceAudience; 23 import org.apache.hadoop.hbase.classification.InterfaceStability; 24 import org.apache.hadoop.hbase.Coprocessor; 25 import org.apache.hadoop.hbase.HBaseInterfaceAudience; 26 import org.apache.hadoop.hbase.HRegionInfo; 27 import org.apache.hadoop.hbase.regionserver.wal.HLogKey; 28 import org.apache.hadoop.hbase.regionserver.wal.WALEdit; 29 30 import java.io.IOException; 31 32 /** 33 * It's provided to have a way for coprocessors to observe, rewrite, 34 * or skip WALEdits as they are being written to the WAL. 35 * 36 * {@link org.apache.hadoop.hbase.coprocessor.RegionObserver} provides 37 * hooks for adding logic for WALEdits in the region context during reconstruction, 38 * 39 * Defines coprocessor hooks for interacting with operations on the 40 * {@link org.apache.hadoop.hbase.regionserver.wal.HLog}. 41 */ 42 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC) 43 @InterfaceStability.Evolving 44 public interface WALObserver extends Coprocessor { 45 46 /** 47 * Called before a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit} 48 * is writen to WAL. 49 * 50 * @param ctx 51 * @param info 52 * @param logKey 53 * @param logEdit 54 * @return true if default behavior should be bypassed, false otherwise 55 * @throws IOException 56 */ 57 // TODO: return value is not used 58 boolean preWALWrite(ObserverContext<WALCoprocessorEnvironment> ctx, 59 HRegionInfo info, HLogKey logKey, WALEdit logEdit) throws IOException; 60 61 /** 62 * Called after a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit} 63 * is writen to WAL. 64 * 65 * @param ctx 66 * @param info 67 * @param logKey 68 * @param logEdit 69 * @throws IOException 70 */ 71 void postWALWrite(ObserverContext<WALCoprocessorEnvironment> ctx, 72 HRegionInfo info, HLogKey logKey, WALEdit logEdit) throws IOException; 73 }