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,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.hadoop.hbase.coprocessor;
21  
22  import java.io.IOException;
23  import java.util.List;
24  import java.util.NavigableSet;
25  
26  import org.apache.hadoop.hbase.classification.InterfaceAudience;
27  import org.apache.hadoop.hbase.classification.InterfaceStability;
28  import org.apache.hadoop.fs.FileSystem;
29  import org.apache.hadoop.fs.Path;
30  import org.apache.hadoop.hbase.Cell;
31  import org.apache.hadoop.hbase.Coprocessor;
32  import org.apache.hadoop.hbase.HBaseInterfaceAudience;
33  import org.apache.hadoop.hbase.HRegionInfo;
34  import org.apache.hadoop.hbase.client.Append;
35  import org.apache.hadoop.hbase.client.Delete;
36  import org.apache.hadoop.hbase.client.Durability;
37  import org.apache.hadoop.hbase.client.Get;
38  import org.apache.hadoop.hbase.client.Increment;
39  import org.apache.hadoop.hbase.client.Mutation;
40  import org.apache.hadoop.hbase.client.Put;
41  import org.apache.hadoop.hbase.client.Result;
42  import org.apache.hadoop.hbase.client.Scan;
43  import org.apache.hadoop.hbase.filter.ByteArrayComparable;
44  import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
45  import org.apache.hadoop.hbase.io.FSDataInputStreamWrapper;
46  import org.apache.hadoop.hbase.io.Reference;
47  import org.apache.hadoop.hbase.io.hfile.CacheConfig;
48  import org.apache.hadoop.hbase.regionserver.DeleteTracker;
49  import org.apache.hadoop.hbase.regionserver.Region;
50  import org.apache.hadoop.hbase.regionserver.Region.Operation;
51  import org.apache.hadoop.hbase.regionserver.InternalScanner;
52  import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
53  import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress;
54  import org.apache.hadoop.hbase.regionserver.RegionScanner;
55  import org.apache.hadoop.hbase.regionserver.ScanType;
56  import org.apache.hadoop.hbase.regionserver.Store;
57  import org.apache.hadoop.hbase.regionserver.StoreFile;
58  import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
59  import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
60  import org.apache.hadoop.hbase.wal.WALKey;
61  import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
62  import org.apache.hadoop.hbase.util.Pair;
63  
64  import com.google.common.collect.ImmutableList;
65  
66  /**
67   * Coprocessors implement this interface to observe and mediate client actions
68   * on the region.
69   */
70  @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
71  @InterfaceStability.Evolving
72  // TODO as method signatures need to break, update to
73  // ObserverContext<? extends RegionCoprocessorEnvironment>
74  // so we can use additional environment state that isn't exposed to coprocessors.
75  public interface RegionObserver extends Coprocessor {
76  
77    /** Mutation type for postMutationBeforeWAL hook */
78    public enum MutationType {
79      APPEND, INCREMENT
80    }
81  
82    /**
83     * Called before the region is reported as open to the master.
84     * @param c the environment provided by the region server
85     * @throws IOException if an error occurred on the coprocessor
86     */
87    void preOpen(final ObserverContext<RegionCoprocessorEnvironment> c) throws IOException;
88  
89    /**
90     * Called after the region is reported as open to the master.
91     * @param c the environment provided by the region server
92     */
93    void postOpen(final ObserverContext<RegionCoprocessorEnvironment> c);
94  
95    /**
96     * Called after the log replay on the region is over.
97     * @param c the environment provided by the region server
98     */
99    void postLogReplay(final ObserverContext<RegionCoprocessorEnvironment> c);
100 
101   /**
102    * Called before a memstore is flushed to disk and prior to creating the scanner to read from
103    * the memstore.  To override or modify how a memstore is flushed,
104    * implementing classes can return a new scanner to provide the KeyValues to be
105    * stored into the new {@code StoreFile} or null to perform the default processing.
106    * Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
107    * effect in this hook.
108    * @param c the environment provided by the region server
109    * @param store the store being flushed
110    * @param memstoreScanner the scanner for the memstore that is flushed
111    * @param s the base scanner, if not {@code null}, from previous RegionObserver in the chain
112    * @return the scanner to use during the flush.  {@code null} if the default implementation
113    * is to be used.
114    * @throws IOException if an error occurred on the coprocessor
115    */
116   InternalScanner preFlushScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
117       final Store store, final KeyValueScanner memstoreScanner, final InternalScanner s)
118       throws IOException;
119 
120   /**
121    * Called before the memstore is flushed to disk.
122    * @param c the environment provided by the region server
123    * @throws IOException if an error occurred on the coprocessor
124    * @deprecated use {@link #preFlush(ObserverContext, Store, InternalScanner)} instead
125    */
126   @Deprecated
127   void preFlush(final ObserverContext<RegionCoprocessorEnvironment> c) throws IOException;
128 
129   /**
130    * Called before a Store's memstore is flushed to disk.
131    * @param c the environment provided by the region server
132    * @param store the store where compaction is being requested
133    * @param scanner the scanner over existing data used in the store file
134    * @return the scanner to use during compaction.  Should not be {@code null}
135    * unless the implementation is writing new store files on its own.
136    * @throws IOException if an error occurred on the coprocessor
137    */
138   InternalScanner preFlush(final ObserverContext<RegionCoprocessorEnvironment> c, final Store store,
139       final InternalScanner scanner) throws IOException;
140 
141   /**
142    * Called after the memstore is flushed to disk.
143    * @param c the environment provided by the region server
144    * @throws IOException if an error occurred on the coprocessor
145    * @deprecated use {@link #preFlush(ObserverContext, Store, InternalScanner)} instead.
146    */
147   @Deprecated
148   void postFlush(final ObserverContext<RegionCoprocessorEnvironment> c) throws IOException;
149 
150   /**
151    * Called after a Store's memstore is flushed to disk.
152    * @param c the environment provided by the region server
153    * @param store the store being flushed
154    * @param resultFile the new store file written out during compaction
155    * @throws IOException if an error occurred on the coprocessor
156    */
157   void postFlush(final ObserverContext<RegionCoprocessorEnvironment> c, final Store store,
158       final StoreFile resultFile) throws IOException;
159 
160   /**
161    * Called prior to selecting the {@link StoreFile StoreFiles} to compact from the list of
162    * available candidates. To alter the files used for compaction, you may mutate the passed in list
163    * of candidates.
164    * @param c the environment provided by the region server
165    * @param store the store where compaction is being requested
166    * @param candidates the store files currently available for compaction
167    * @param request custom compaction request
168    * @throws IOException if an error occurred on the coprocessor
169    */
170   void preCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
171       final Store store, final List<StoreFile> candidates, final CompactionRequest request)
172       throws IOException;
173 
174   /**
175    * Called prior to selecting the {@link StoreFile}s to compact from the list of available
176    * candidates. To alter the files used for compaction, you may mutate the passed in list of
177    * candidates.
178    * @param c the environment provided by the region server
179    * @param store the store where compaction is being requested
180    * @param candidates the store files currently available for compaction
181    * @throws IOException if an error occurred on the coprocessor
182    * @deprecated Use {@link #preCompactSelection(ObserverContext, Store, List, CompactionRequest)}
183    *             instead
184    */
185   @Deprecated
186   void preCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
187       final Store store, final List<StoreFile> candidates) throws IOException;
188 
189   /**
190    * Called after the {@link StoreFile}s to compact have been selected from the available
191    * candidates.
192    * @param c the environment provided by the region server
193    * @param store the store being compacted
194    * @param selected the store files selected to compact
195    * @param request custom compaction request
196    */
197   void postCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
198       final Store store, final ImmutableList<StoreFile> selected, CompactionRequest request);
199 
200   /**
201    * Called after the {@link StoreFile}s to compact have been selected from the available
202    * candidates.
203    * @param c the environment provided by the region server
204    * @param store the store being compacted
205    * @param selected the store files selected to compact
206    * @deprecated use {@link #postCompactSelection(ObserverContext, Store, ImmutableList,
207    *             CompactionRequest)} instead.
208    */
209   @Deprecated
210   void postCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
211       final Store store, final ImmutableList<StoreFile> selected);
212 
213   /**
214    * Called prior to writing the {@link StoreFile}s selected for compaction into a new
215    * {@code StoreFile}. To override or modify the compaction process, implementing classes have two
216    * options:
217    * <ul>
218    * <li>Wrap the provided {@link InternalScanner} with a custom implementation that is returned
219    * from this method. The custom scanner can then inspect
220    *  {@link org.apache.hadoop.hbase.KeyValue}s from the wrapped scanner, applying its own
221    *   policy to what gets written.</li>
222    * <li>Call {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} and provide a
223    * custom implementation for writing of new {@link StoreFile}s. <strong>Note: any implementations
224    * bypassing core compaction using this approach must write out new store files themselves or the
225    * existing data will no longer be available after compaction.</strong></li>
226    * </ul>
227    * @param c the environment provided by the region server
228    * @param store the store being compacted
229    * @param scanner the scanner over existing data used in the store file rewriting
230    * @param scanType type of Scan
231    * @param request the requested compaction
232    * @return the scanner to use during compaction. Should not be {@code null} unless the
233    *         implementation is writing new store files on its own.
234    * @throws IOException if an error occurred on the coprocessor
235    */
236   InternalScanner preCompact(final ObserverContext<RegionCoprocessorEnvironment> c,
237       final Store store, final InternalScanner scanner, final ScanType scanType,
238       CompactionRequest request) throws IOException;
239 
240   /**
241    * Called prior to writing the {@link StoreFile}s selected for compaction into a new
242    * {@code StoreFile}. To override or modify the compaction process, implementing classes have two
243    * options:
244    * <ul>
245    * <li>Wrap the provided {@link InternalScanner} with a custom implementation that is returned
246    * from this method. The custom scanner can then inspect
247    *  {@link org.apache.hadoop.hbase.KeyValue}s from the wrapped scanner, applying its own
248    *   policy to what gets written.</li>
249    * <li>Call {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} and provide a
250    * custom implementation for writing of new {@link StoreFile}s. <strong>Note: any implementations
251    * bypassing core compaction using this approach must write out new store files themselves or the
252    * existing data will no longer be available after compaction.</strong></li>
253    * </ul>
254    * @param c the environment provided by the region server
255    * @param store the store being compacted
256    * @param scanner the scanner over existing data used in the store file rewriting
257    * @param scanType type of Scan
258    * @return the scanner to use during compaction. Should not be {@code null} unless the
259    *         implementation is writing new store files on its own.
260    * @throws IOException if an error occurred on the coprocessor
261    * @deprecated use
262    *             {@link #preCompact(ObserverContext, Store, InternalScanner,
263    *             ScanType, CompactionRequest)} instead
264    */
265   @Deprecated
266   InternalScanner preCompact(final ObserverContext<RegionCoprocessorEnvironment> c,
267       final Store store, final InternalScanner scanner, final ScanType scanType) throws IOException;
268 
269   /**
270    * Called prior to writing the {@link StoreFile}s selected for compaction into a new
271    * {@code StoreFile} and prior to creating the scanner used to read the input files. To override
272    * or modify the compaction process, implementing classes can return a new scanner to provide the
273    * KeyValues to be stored into the new {@code StoreFile} or null to perform the default
274    * processing. Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
275    * effect in this hook.
276    * @param c the environment provided by the region server
277    * @param store the store being compacted
278    * @param scanners the list {@link org.apache.hadoop.hbase.regionserver.StoreFileScanner}s
279    *  to be read from
280    * @param scanType the {@link ScanType} indicating whether this is a major or minor compaction
281    * @param earliestPutTs timestamp of the earliest put that was found in any of the involved store
282    *          files
283    * @param s the base scanner, if not {@code null}, from previous RegionObserver in the chain
284    * @param request the requested compaction
285    * @return the scanner to use during compaction. {@code null} if the default implementation is to
286    *         be used.
287    * @throws IOException if an error occurred on the coprocessor
288    */
289   InternalScanner preCompactScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
290       final Store store, List<? extends KeyValueScanner> scanners, final ScanType scanType,
291       final long earliestPutTs, final InternalScanner s, CompactionRequest request)
292       throws IOException;
293 
294   /**
295    * Called prior to writing the {@link StoreFile}s selected for compaction into a new
296    * {@code StoreFile} and prior to creating the scanner used to read the input files. To override
297    * or modify the compaction process, implementing classes can return a new scanner to provide the
298    * KeyValues to be stored into the new {@code StoreFile} or null to perform the default
299    * processing. Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
300    * effect in this hook.
301    * @param c the environment provided by the region server
302    * @param store the store being compacted
303    * @param scanners the list {@link org.apache.hadoop.hbase.regionserver.StoreFileScanner}s
304    *  to be read from
305    * @param scanType the {@link ScanType} indicating whether this is a major or minor compaction
306    * @param earliestPutTs timestamp of the earliest put that was found in any of the involved store
307    *          files
308    * @param s the base scanner, if not {@code null}, from previous RegionObserver in the chain
309    * @return the scanner to use during compaction. {@code null} if the default implementation is to
310    *         be used.
311    * @throws IOException if an error occurred on the coprocessor
312    * @deprecated Use
313    *             {@link #preCompactScannerOpen(ObserverContext, Store, List, ScanType, long,
314    *             InternalScanner, CompactionRequest)} instead.
315    */
316   @Deprecated
317   InternalScanner preCompactScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
318       final Store store, List<? extends KeyValueScanner> scanners, final ScanType scanType,
319       final long earliestPutTs, final InternalScanner s) throws IOException;
320 
321   /**
322    * Called after compaction has completed and the new store file has been moved in to place.
323    * @param c the environment provided by the region server
324    * @param store the store being compacted
325    * @param resultFile the new store file written out during compaction
326    * @param request the requested compaction
327    * @throws IOException if an error occurred on the coprocessor
328    */
329   void postCompact(final ObserverContext<RegionCoprocessorEnvironment> c, final Store store,
330       StoreFile resultFile, CompactionRequest request) throws IOException;
331 
332   /**
333    * Called after compaction has completed and the new store file has been moved in to place.
334    * @param c the environment provided by the region server
335    * @param store the store being compacted
336    * @param resultFile the new store file written out during compaction
337    * @throws IOException if an error occurred on the coprocessor
338    * @deprecated Use {@link #postCompact(ObserverContext, Store, StoreFile, CompactionRequest)}
339    *             instead
340    */
341   @Deprecated
342   void postCompact(final ObserverContext<RegionCoprocessorEnvironment> c, final Store store,
343       StoreFile resultFile) throws IOException;
344 
345   /**
346    * Called before the region is split.
347    * @param c the environment provided by the region server
348    * (e.getRegion() returns the parent region)
349    * @throws IOException if an error occurred on the coprocessor
350    * @deprecated Use preSplit(
351    *    final ObserverContext&lt;RegionCoprocessorEnvironment&gt; c, byte[] splitRow)
352    */
353   @Deprecated
354   void preSplit(final ObserverContext<RegionCoprocessorEnvironment> c) throws IOException;
355 
356   /**
357    * Called before the region is split.
358    * @param c the environment provided by the region server
359    * (e.getRegion() returns the parent region)
360    * @throws IOException if an error occurred on the coprocessor
361    */
362   void preSplit(final ObserverContext<RegionCoprocessorEnvironment> c, byte[] splitRow)
363       throws IOException;
364 
365   /**
366    * Called after the region is split.
367    * @param c the environment provided by the region server
368    * (e.getRegion() returns the parent region)
369    * @param l the left daughter region
370    * @param r the right daughter region
371    * @throws IOException if an error occurred on the coprocessor
372    * @deprecated Use postCompleteSplit() instead
373    */
374   @Deprecated
375   void postSplit(final ObserverContext<RegionCoprocessorEnvironment> c, final Region l,
376       final Region r) throws IOException;
377 
378   /**
379    * This will be called before PONR step as part of split transaction. Calling
380    * {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} rollback the split
381    * @param ctx
382    * @param splitKey
383    * @param metaEntries
384    * @throws IOException
385    */
386   void preSplitBeforePONR(final ObserverContext<RegionCoprocessorEnvironment> ctx,
387       byte[] splitKey, List<Mutation> metaEntries) throws IOException;
388 
389 
390   /**
391    * This will be called after PONR step as part of split transaction
392    * Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
393    * effect in this hook.
394    * @param ctx
395    * @throws IOException
396    */
397   void preSplitAfterPONR(final ObserverContext<RegionCoprocessorEnvironment> ctx) throws IOException;
398 
399   /**
400    * This will be called before the roll back of the split region is completed
401    * @param ctx
402    * @throws IOException
403    */
404   void preRollBackSplit(final ObserverContext<RegionCoprocessorEnvironment> ctx) throws IOException;
405 
406   /**
407    * This will be called after the roll back of the split region is completed
408    * @param ctx
409    * @throws IOException
410    */
411   void postRollBackSplit(final ObserverContext<RegionCoprocessorEnvironment> ctx)
412     throws IOException;
413 
414   /**
415    * Called after any split request is processed.  This will be called irrespective of success or
416    * failure of the split.
417    * @param ctx
418    * @throws IOException
419    */
420   void postCompleteSplit(final ObserverContext<RegionCoprocessorEnvironment> ctx)
421     throws IOException;
422   /**
423    * Called before the region is reported as closed to the master.
424    * @param c the environment provided by the region server
425    * @param abortRequested true if the region server is aborting
426    * @throws IOException
427    */
428   void preClose(final ObserverContext<RegionCoprocessorEnvironment> c,
429       boolean abortRequested) throws IOException;
430 
431   /**
432    * Called after the region is reported as closed to the master.
433    * @param c the environment provided by the region server
434    * @param abortRequested true if the region server is aborting
435    */
436   void postClose(final ObserverContext<RegionCoprocessorEnvironment> c,
437       boolean abortRequested);
438 
439   /**
440    * Called before the client performs a Get
441    * <p>
442    * Call CoprocessorEnvironment#bypass to skip default actions
443    * <p>
444    * Call CoprocessorEnvironment#complete to skip any subsequent chained
445    * coprocessors
446    * @param c the environment provided by the region server
447    * @param get the Get request
448    * @param result The result to return to the client if default processing
449    * is bypassed. Can be modified. Will not be used if default processing
450    * is not bypassed.
451    * @throws IOException if an error occurred on the coprocessor
452    */
453   void preGetOp(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
454       final List<Cell> result)
455     throws IOException;
456 
457   /**
458    * Called after the client performs a Get
459    * <p>
460    * Call CoprocessorEnvironment#complete to skip any subsequent chained
461    * coprocessors
462    * @param c the environment provided by the region server
463    * @param get the Get request
464    * @param result the result to return to the client, modify as necessary
465    * @throws IOException if an error occurred on the coprocessor
466    */
467   void postGetOp(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
468       final List<Cell> result)
469     throws IOException;
470 
471   /**
472    * Called before the client tests for existence using a Get.
473    * <p>
474    * Call CoprocessorEnvironment#bypass to skip default actions
475    * <p>
476    * Call CoprocessorEnvironment#complete to skip any subsequent chained
477    * coprocessors
478    * @param c the environment provided by the region server
479    * @param get the Get request
480    * @param exists
481    * @return the value to return to the client if bypassing default processing
482    * @throws IOException if an error occurred on the coprocessor
483    */
484   boolean preExists(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
485       final boolean exists)
486     throws IOException;
487 
488   /**
489    * Called after the client tests for existence using a Get.
490    * <p>
491    * Call CoprocessorEnvironment#complete to skip any subsequent chained
492    * coprocessors
493    * @param c the environment provided by the region server
494    * @param get the Get request
495    * @param exists the result returned by the region server
496    * @return the result to return to the client
497    * @throws IOException if an error occurred on the coprocessor
498    */
499   boolean postExists(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
500       final boolean exists)
501     throws IOException;
502 
503   /**
504    * Called before the client stores a value.
505    * <p>
506    * Call CoprocessorEnvironment#bypass to skip default actions
507    * <p>
508    * Call CoprocessorEnvironment#complete to skip any subsequent chained
509    * coprocessors
510    * @param c the environment provided by the region server
511    * @param put The Put object
512    * @param edit The WALEdit object that will be written to the wal
513    * @param durability Persistence guarantee for this Put
514    * @throws IOException if an error occurred on the coprocessor
515    */
516   void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,
517       final Put put, final WALEdit edit, final Durability durability)
518     throws IOException;
519 
520   /**
521    * Called after the client stores a value.
522    * <p>
523    * Call CoprocessorEnvironment#complete to skip any subsequent chained
524    * coprocessors
525    * @param c the environment provided by the region server
526    * @param put The Put object
527    * @param edit The WALEdit object for the wal
528    * @param durability Persistence guarantee for this Put
529    * @throws IOException if an error occurred on the coprocessor
530    */
531   void postPut(final ObserverContext<RegionCoprocessorEnvironment> c,
532       final Put put, final WALEdit edit, final Durability durability)
533     throws IOException;
534 
535   /**
536    * Called before the client deletes a value.
537    * <p>
538    * Call CoprocessorEnvironment#bypass to skip default actions
539    * <p>
540    * Call CoprocessorEnvironment#complete to skip any subsequent chained
541    * coprocessors
542    * @param c the environment provided by the region server
543    * @param delete The Delete object
544    * @param edit The WALEdit object for the wal
545    * @param durability Persistence guarantee for this Delete
546    * @throws IOException if an error occurred on the coprocessor
547    */
548   void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
549       final Delete delete, final WALEdit edit, final Durability durability)
550     throws IOException;
551 /**
552  * Called before the server updates the timestamp for version delete with latest timestamp.
553  * <p>
554  * Call CoprocessorEnvironment#bypass to skip default actions
555  * <p>
556  * Call CoprocessorEnvironment#complete to skip any subsequent chained
557  * coprocessors
558  * @param c the environment provided by the region server
559  * @param mutation - the parent mutation associated with this delete cell
560  * @param cell - The deleteColumn with latest version cell
561  * @param byteNow - timestamp bytes
562  * @param get - the get formed using the current cell's row.
563  * Note that the get does not specify the family and qualifier
564  * @throws IOException
565  */
566   void prePrepareTimeStampForDeleteVersion(final ObserverContext<RegionCoprocessorEnvironment> c,
567       final Mutation mutation, final Cell cell, final byte[] byteNow,
568       final Get get) throws IOException;
569 
570   /**
571    * Called after the client deletes a value.
572    * <p>
573    * Call CoprocessorEnvironment#complete to skip any subsequent chained
574    * coprocessors
575    * @param c the environment provided by the region server
576    * @param delete The Delete object
577    * @param edit The WALEdit object for the wal
578    * @param durability Persistence guarantee for this Delete
579    * @throws IOException if an error occurred on the coprocessor
580    */
581   void postDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
582       final Delete delete, final WALEdit edit, final Durability durability)
583     throws IOException;
584 
585   /**
586    * This will be called for every batch mutation operation happening at the server. This will be
587    * called after acquiring the locks on the mutating rows and after applying the proper timestamp
588    * for each Mutation at the server. The batch may contain Put/Delete. By setting OperationStatus
589    * of Mutations ({@link MiniBatchOperationInProgress#setOperationStatus(int, OperationStatus)}),
590    * {@link RegionObserver} can make Region to skip these Mutations.
591    * @param c the environment provided by the region server
592    * @param miniBatchOp batch of Mutations getting applied to region.
593    * @throws IOException if an error occurred on the coprocessor
594    */
595   void preBatchMutate(final ObserverContext<RegionCoprocessorEnvironment> c,
596       final MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException;
597 
598   /**
599    * This will be called after applying a batch of Mutations on a region. The Mutations are added to
600    * memstore and WAL.
601    * @param c the environment provided by the region server
602    * @param miniBatchOp batch of Mutations applied to region.
603    * @throws IOException if an error occurred on the coprocessor
604    */
605   void postBatchMutate(final ObserverContext<RegionCoprocessorEnvironment> c,
606       final MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException;
607 
608   /**
609    * This will be called for region operations where read lock is acquired in
610    * {@link Region#startRegionOperation()}.
611    * @param ctx
612    * @param operation The operation is about to be taken on the region
613    * @throws IOException
614    */
615   void postStartRegionOperation(final ObserverContext<RegionCoprocessorEnvironment> ctx,
616       Operation operation) throws IOException;
617 
618   /**
619    * Called after releasing read lock in {@link Region#closeRegionOperation()}.
620    * @param ctx
621    * @param operation
622    * @throws IOException
623    */
624   void postCloseRegionOperation(final ObserverContext<RegionCoprocessorEnvironment> ctx,
625       Operation operation) throws IOException;
626 
627   /**
628    * Called after the completion of batch put/delete and will be called even if the batch operation
629    * fails
630    * @param ctx
631    * @param miniBatchOp
632    * @param success true if batch operation is successful otherwise false.
633    * @throws IOException
634    */
635   void postBatchMutateIndispensably(final ObserverContext<RegionCoprocessorEnvironment> ctx,
636       MiniBatchOperationInProgress<Mutation> miniBatchOp, final boolean success) throws IOException;
637 
638   /**
639    * Called before checkAndPut.
640    * <p>
641    * Call CoprocessorEnvironment#bypass to skip default actions
642    * <p>
643    * Call CoprocessorEnvironment#complete to skip any subsequent chained
644    * coprocessors
645    * @param c the environment provided by the region server
646    * @param row row to check
647    * @param family column family
648    * @param qualifier column qualifier
649    * @param compareOp the comparison operation
650    * @param comparator the comparator
651    * @param put data to put if check succeeds
652    * @param result
653    * @return the return value to return to client if bypassing default
654    * processing
655    * @throws IOException if an error occurred on the coprocessor
656    */
657   boolean preCheckAndPut(final ObserverContext<RegionCoprocessorEnvironment> c,
658       final byte [] row, final byte [] family, final byte [] qualifier,
659       final CompareOp compareOp, final ByteArrayComparable comparator,
660       final Put put, final boolean result)
661     throws IOException;
662 
663   /**
664    * Called before checkAndPut but after acquiring rowlock.
665    * <p>
666    * <b>Note:</b> Caution to be taken for not doing any long time operation in this hook.
667    * Row will be locked for longer time. Trying to acquire lock on another row, within this,
668    * can lead to potential deadlock.
669    * <p>
670    * Call CoprocessorEnvironment#bypass to skip default actions
671    * <p>
672    * Call CoprocessorEnvironment#complete to skip any subsequent chained
673    * coprocessors
674    * @param c the environment provided by the region server
675    * @param row row to check
676    * @param family column family
677    * @param qualifier column qualifier
678    * @param compareOp the comparison operation
679    * @param comparator the comparator
680    * @param put data to put if check succeeds
681    * @param result
682    * @return the return value to return to client if bypassing default
683    * processing
684    * @throws IOException if an error occurred on the coprocessor
685    */
686   boolean preCheckAndPutAfterRowLock(final ObserverContext<RegionCoprocessorEnvironment> c,
687       final byte[] row, final byte[] family, final byte[] qualifier, final CompareOp compareOp,
688       final ByteArrayComparable comparator, final Put put,
689       final boolean result) throws IOException;
690 
691   /**
692    * Called after checkAndPut
693    * <p>
694    * Call CoprocessorEnvironment#complete to skip any subsequent chained
695    * coprocessors
696    * @param c the environment provided by the region server
697    * @param row row to check
698    * @param family column family
699    * @param qualifier column qualifier
700    * @param compareOp the comparison operation
701    * @param comparator the comparator
702    * @param put data to put if check succeeds
703    * @param result from the checkAndPut
704    * @return the possibly transformed return value to return to client
705    * @throws IOException if an error occurred on the coprocessor
706    */
707   boolean postCheckAndPut(final ObserverContext<RegionCoprocessorEnvironment> c,
708       final byte [] row, final byte [] family, final byte [] qualifier,
709       final CompareOp compareOp, final ByteArrayComparable comparator,
710       final Put put, final boolean result)
711     throws IOException;
712 
713   /**
714    * Called before checkAndDelete.
715    * <p>
716    * Call CoprocessorEnvironment#bypass to skip default actions
717    * <p>
718    * Call CoprocessorEnvironment#complete to skip any subsequent chained
719    * coprocessors
720    * @param c the environment provided by the region server
721    * @param row row to check
722    * @param family column family
723    * @param qualifier column qualifier
724    * @param compareOp the comparison operation
725    * @param comparator the comparator
726    * @param delete delete to commit if check succeeds
727    * @param result
728    * @return the value to return to client if bypassing default processing
729    * @throws IOException if an error occurred on the coprocessor
730    */
731   boolean preCheckAndDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
732       final byte [] row, final byte [] family, final byte [] qualifier,
733       final CompareOp compareOp, final ByteArrayComparable comparator,
734       final Delete delete, final boolean result)
735     throws IOException;
736 
737   /**
738    * Called before checkAndDelete but after acquiring rowock.
739    * <p>
740    * <b>Note:</b> Caution to be taken for not doing any long time operation in this hook.
741    * Row will be locked for longer time. Trying to acquire lock on another row, within this,
742    * can lead to potential deadlock.
743    * <p>
744    * Call CoprocessorEnvironment#bypass to skip default actions
745    * <p>
746    * Call CoprocessorEnvironment#complete to skip any subsequent chained
747    * coprocessors
748    * @param c the environment provided by the region server
749    * @param row row to check
750    * @param family column family
751    * @param qualifier column qualifier
752    * @param compareOp the comparison operation
753    * @param comparator the comparator
754    * @param delete delete to commit if check succeeds
755    * @param result
756    * @return the value to return to client if bypassing default processing
757    * @throws IOException if an error occurred on the coprocessor
758    */
759   boolean preCheckAndDeleteAfterRowLock(final ObserverContext<RegionCoprocessorEnvironment> c,
760       final byte[] row, final byte[] family, final byte[] qualifier, final CompareOp compareOp,
761       final ByteArrayComparable comparator, final Delete delete,
762       final boolean result) throws IOException;
763 
764   /**
765    * Called after checkAndDelete
766    * <p>
767    * Call CoprocessorEnvironment#complete to skip any subsequent chained
768    * coprocessors
769    * @param c the environment provided by the region server
770    * @param row row to check
771    * @param family column family
772    * @param qualifier column qualifier
773    * @param compareOp the comparison operation
774    * @param comparator the comparator
775    * @param delete delete to commit if check succeeds
776    * @param result from the CheckAndDelete
777    * @return the possibly transformed returned value to return to client
778    * @throws IOException if an error occurred on the coprocessor
779    */
780   boolean postCheckAndDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
781       final byte [] row, final byte [] family, final byte [] qualifier,
782       final CompareOp compareOp, final ByteArrayComparable comparator,
783       final Delete delete, final boolean result)
784     throws IOException;
785 
786   /**
787    * Called before incrementColumnValue
788    * <p>
789    * Call CoprocessorEnvironment#bypass to skip default actions
790    * <p>
791    * Call CoprocessorEnvironment#complete to skip any subsequent chained
792    * coprocessors
793    * @param c the environment provided by the region server
794    * @param row row to check
795    * @param family column family
796    * @param qualifier column qualifier
797    * @param amount long amount to increment
798    * @param writeToWAL true if the change should be written to the WAL
799    * @return value to return to the client if bypassing default processing
800    * @throws IOException if an error occurred on the coprocessor
801    * @deprecated This hook is no longer called by the RegionServer
802    */
803   @Deprecated
804   long preIncrementColumnValue(final ObserverContext<RegionCoprocessorEnvironment> c,
805       final byte [] row, final byte [] family, final byte [] qualifier,
806       final long amount, final boolean writeToWAL)
807     throws IOException;
808 
809   /**
810    * Called after incrementColumnValue
811    * <p>
812    * Call CoprocessorEnvironment#complete to skip any subsequent chained
813    * coprocessors
814    * @param c the environment provided by the region server
815    * @param row row to check
816    * @param family column family
817    * @param qualifier column qualifier
818    * @param amount long amount to increment
819    * @param writeToWAL true if the change should be written to the WAL
820    * @param result the result returned by incrementColumnValue
821    * @return the result to return to the client
822    * @throws IOException if an error occurred on the coprocessor
823    * @deprecated This hook is no longer called by the RegionServer
824    */
825   @Deprecated
826   long postIncrementColumnValue(final ObserverContext<RegionCoprocessorEnvironment> c,
827       final byte [] row, final byte [] family, final byte [] qualifier,
828       final long amount, final boolean writeToWAL, final long result)
829     throws IOException;
830 
831   /**
832    * Called before Append.
833    * <p>
834    * Call CoprocessorEnvironment#bypass to skip default actions
835    * <p>
836    * Call CoprocessorEnvironment#complete to skip any subsequent chained
837    * coprocessors
838    * @param c the environment provided by the region server
839    * @param append Append object
840    * @return result to return to the client if bypassing default processing
841    * @throws IOException if an error occurred on the coprocessor
842    */
843   Result preAppend(final ObserverContext<RegionCoprocessorEnvironment> c,
844       final Append append)
845     throws IOException;
846 
847   /**
848    * Called before Append but after acquiring rowlock.
849    * <p>
850    * <b>Note:</b> Caution to be taken for not doing any long time operation in this hook.
851    * Row will be locked for longer time. Trying to acquire lock on another row, within this,
852    * can lead to potential deadlock.
853    * <p>
854    * Call CoprocessorEnvironment#bypass to skip default actions
855    * <p>
856    * Call CoprocessorEnvironment#complete to skip any subsequent chained
857    * coprocessors
858    * @param c the environment provided by the region server
859    * @param append Append object
860    * @return result to return to the client if bypassing default processing
861    * @throws IOException if an error occurred on the coprocessor
862    */
863   Result preAppendAfterRowLock(final ObserverContext<RegionCoprocessorEnvironment> c,
864       final Append append) throws IOException;
865 
866   /**
867    * Called after Append
868    * <p>
869    * Call CoprocessorEnvironment#complete to skip any subsequent chained
870    * coprocessors
871    * @param c the environment provided by the region server
872    * @param append Append object
873    * @param result the result returned by increment
874    * @return the result to return to the client
875    * @throws IOException if an error occurred on the coprocessor
876    */
877   Result postAppend(final ObserverContext<RegionCoprocessorEnvironment> c,
878       final Append append, final Result result)
879     throws IOException;
880 
881   /**
882    * Called before Increment.
883    * <p>
884    * Call CoprocessorEnvironment#bypass to skip default actions
885    * <p>
886    * Call CoprocessorEnvironment#complete to skip any subsequent chained
887    * coprocessors
888    * @param c the environment provided by the region server
889    * @param increment increment object
890    * @return result to return to the client if bypassing default processing
891    * @throws IOException if an error occurred on the coprocessor
892    */
893   Result preIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
894       final Increment increment)
895     throws IOException;
896 
897   /**
898    * Called before Increment but after acquiring rowlock.
899    * <p>
900    * <b>Note:</b> Caution to be taken for not doing any long time operation in this hook.
901    * Row will be locked for longer time. Trying to acquire lock on another row, within this,
902    * can lead to potential deadlock.
903    * <p>
904    * Call CoprocessorEnvironment#bypass to skip default actions
905    * <p>
906    * Call CoprocessorEnvironment#complete to skip any subsequent chained coprocessors
907    *
908    * @param c
909    *          the environment provided by the region server
910    * @param increment
911    *          increment object
912    * @return result to return to the client if bypassing default processing
913    * @throws IOException
914    *           if an error occurred on the coprocessor
915    */
916   Result preIncrementAfterRowLock(final ObserverContext<RegionCoprocessorEnvironment> c,
917       final Increment increment) throws IOException;
918 
919   /**
920    * Called after increment
921    * <p>
922    * Call CoprocessorEnvironment#complete to skip any subsequent chained
923    * coprocessors
924    * @param c the environment provided by the region server
925    * @param increment increment object
926    * @param result the result returned by increment
927    * @return the result to return to the client
928    * @throws IOException if an error occurred on the coprocessor
929    */
930   Result postIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
931       final Increment increment, final Result result)
932     throws IOException;
933 
934   /**
935    * Called before the client opens a new scanner.
936    * <p>
937    * Call CoprocessorEnvironment#bypass to skip default actions
938    * <p>
939    * Call CoprocessorEnvironment#complete to skip any subsequent chained
940    * coprocessors
941    * @param c the environment provided by the region server
942    * @param scan the Scan specification
943    * @param s if not null, the base scanner
944    * @return an RegionScanner instance to use instead of the base scanner if
945    * overriding default behavior, null otherwise
946    * @throws IOException if an error occurred on the coprocessor
947    */
948   RegionScanner preScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
949       final Scan scan, final RegionScanner s)
950     throws IOException;
951 
952   /**
953    * Called before a store opens a new scanner.
954    * This hook is called when a "user" scanner is opened.
955    * <p>
956    * See {@link #preFlushScannerOpen(ObserverContext, Store, KeyValueScanner, InternalScanner)}
957    * and {@link #preCompactScannerOpen(ObserverContext,
958    *  Store, List, ScanType, long, InternalScanner)}
959    * to override scanners created for flushes or compactions, resp.
960    * <p>
961    * Call CoprocessorEnvironment#complete to skip any subsequent chained
962    * coprocessors.
963    * Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
964    * effect in this hook.
965    * @param c the environment provided by the region server
966    * @param store the store being scanned
967    * @param scan the Scan specification
968    * @param targetCols columns to be used in the scanner
969    * @param s the base scanner, if not {@code null}, from previous RegionObserver in the chain
970    * @return a KeyValueScanner instance to use or {@code null} to use the default implementation
971    * @throws IOException if an error occurred on the coprocessor
972    */
973   KeyValueScanner preStoreScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
974       final Store store, final Scan scan, final NavigableSet<byte[]> targetCols,
975       final KeyValueScanner s) throws IOException;
976 
977   /**
978    * Called after the client opens a new scanner.
979    * <p>
980    * Call CoprocessorEnvironment#complete to skip any subsequent chained
981    * coprocessors
982    * @param c the environment provided by the region server
983    * @param scan the Scan specification
984    * @param s if not null, the base scanner
985    * @return the scanner instance to use
986    * @throws IOException if an error occurred on the coprocessor
987    */
988   RegionScanner postScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
989       final Scan scan, final RegionScanner s)
990     throws IOException;
991 
992   /**
993    * Called before the client asks for the next row on a scanner.
994    * <p>
995    * Call CoprocessorEnvironment#bypass to skip default actions
996    * <p>
997    * Call CoprocessorEnvironment#complete to skip any subsequent chained
998    * coprocessors
999    * @param c the environment provided by the region server
1000    * @param s the scanner
1001    * @param result The result to return to the client if default processing
1002    * is bypassed. Can be modified. Will not be returned if default processing
1003    * is not bypassed.
1004    * @param limit the maximum number of results to return
1005    * @param hasNext the 'has more' indication
1006    * @return 'has more' indication that should be sent to client
1007    * @throws IOException if an error occurred on the coprocessor
1008    */
1009   boolean preScannerNext(final ObserverContext<RegionCoprocessorEnvironment> c,
1010       final InternalScanner s, final List<Result> result,
1011       final int limit, final boolean hasNext)
1012     throws IOException;
1013 
1014   /**
1015    * Called after the client asks for the next row on a scanner.
1016    * <p>
1017    * Call CoprocessorEnvironment#complete to skip any subsequent chained
1018    * coprocessors
1019    * @param c the environment provided by the region server
1020    * @param s the scanner
1021    * @param result the result to return to the client, can be modified
1022    * @param limit the maximum number of results to return
1023    * @param hasNext the 'has more' indication
1024    * @return 'has more' indication that should be sent to client
1025    * @throws IOException if an error occurred on the coprocessor
1026    */
1027   boolean postScannerNext(final ObserverContext<RegionCoprocessorEnvironment> c,
1028       final InternalScanner s, final List<Result> result, final int limit,
1029       final boolean hasNext)
1030     throws IOException;
1031 
1032   /**
1033    * This will be called by the scan flow when the current scanned row is being filtered out by the
1034    * filter. The filter may be filtering out the row via any of the below scenarios
1035    * <ol>
1036    * <li>
1037    * <code>boolean filterRowKey(byte [] buffer, int offset, int length)</code> returning true</li>
1038    * <li>
1039    * <code>boolean filterRow()</code> returning true</li>
1040    * <li>
1041    * <code>void filterRow(List&lt;KeyValue&gt; kvs)</code> removing all the kvs
1042    * from the passed List</li>
1043    * </ol>
1044    * @param c the environment provided by the region server
1045    * @param s the scanner
1046    * @param currentRow The current rowkey which got filtered out
1047    * @param offset offset to rowkey
1048    * @param length length of rowkey
1049    * @param hasMore the 'has more' indication
1050    * @return whether more rows are available for the scanner or not
1051    * @throws IOException
1052    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
1053    * Instead use {@link #postScannerFilterRow(ObserverContext, InternalScanner, Cell, boolean)}
1054    */
1055   @Deprecated
1056   boolean postScannerFilterRow(final ObserverContext<RegionCoprocessorEnvironment> c,
1057       final InternalScanner s, final byte[] currentRow, final int offset, final short length,
1058       final boolean hasMore) throws IOException;
1059 
1060   /**
1061    * This will be called by the scan flow when the current scanned row is being filtered out by the
1062    * filter. The filter may be filtering out the row via any of the below scenarios
1063    * <ol>
1064    * <li>
1065    * <code>boolean filterRowKey(byte [] buffer, int offset, int length)</code> returning true</li>
1066    * <li>
1067    * <code>boolean filterRow()</code> returning true</li>
1068    * <li>
1069    * <code>void filterRow(List&lt;KeyValue&gt; kvs)</code> removing all the kvs from
1070    * the passed List</li>
1071    * </ol>
1072    * @param c the environment provided by the region server
1073    * @param s the scanner
1074    * @param curRowCell The cell in the current row which got filtered out
1075    * @param hasMore the 'has more' indication
1076    * @return whether more rows are available for the scanner or not
1077    * @throws IOException
1078    */
1079   boolean postScannerFilterRow(final ObserverContext<RegionCoprocessorEnvironment> c,
1080       final InternalScanner s, Cell curRowCell, final boolean hasMore) throws IOException;
1081 
1082   /**
1083    * Called before the client closes a scanner.
1084    * <p>
1085    * Call CoprocessorEnvironment#bypass to skip default actions
1086    * <p>
1087    * Call CoprocessorEnvironment#complete to skip any subsequent chained
1088    * coprocessors
1089    * @param c the environment provided by the region server
1090    * @param s the scanner
1091    * @throws IOException if an error occurred on the coprocessor
1092    */
1093   void preScannerClose(final ObserverContext<RegionCoprocessorEnvironment> c,
1094       final InternalScanner s)
1095     throws IOException;
1096 
1097   /**
1098    * Called after the client closes a scanner.
1099    * <p>
1100    * Call CoprocessorEnvironment#complete to skip any subsequent chained
1101    * coprocessors
1102    * @param c the environment provided by the region server
1103    * @param s the scanner
1104    * @throws IOException if an error occurred on the coprocessor
1105    */
1106   void postScannerClose(final ObserverContext<RegionCoprocessorEnvironment> c,
1107       final InternalScanner s)
1108     throws IOException;
1109 
1110   /**
1111    * Called before a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit}
1112    * replayed for this region.
1113    */
1114   void preWALRestore(final ObserverContext<? extends RegionCoprocessorEnvironment> ctx,
1115       HRegionInfo info, WALKey logKey, WALEdit logEdit) throws IOException;
1116 
1117   /**
1118    * Called before a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit}
1119    * replayed for this region.
1120    *
1121    * This method is left in place to maintain binary compatibility with older
1122    * {@link RegionObserver}s. If an implementation directly overrides
1123    * {@link #preWALRestore(ObserverContext, HRegionInfo, WALKey, WALEdit)} then this version
1124    * won't be called at all, barring problems with the Security Manager. To work correctly
1125    * in the presence of a strict Security Manager, or in the case of an implementation that
1126    * relies on a parent class to implement preWALRestore, you should implement this method
1127    * as a call to the non-deprecated version.
1128    *
1129    * Users of this method will see all edits that can be treated as HLogKey. If there are
1130    * edits that can't be treated as HLogKey they won't be offered to coprocessors that rely
1131    * on this method. If a coprocessor gets skipped because of this mechanism, a log message
1132    * at ERROR will be generated per coprocessor on the logger for {@link CoprocessorHost} once per
1133    * classloader.
1134    *
1135    * @deprecated use {@link #preWALRestore(ObserverContext, HRegionInfo, WALKey, WALEdit)}
1136    */
1137   @Deprecated
1138   void preWALRestore(final ObserverContext<RegionCoprocessorEnvironment> ctx,
1139       HRegionInfo info, HLogKey logKey, WALEdit logEdit) throws IOException;
1140 
1141   /**
1142    * Called after a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit}
1143    * replayed for this region.
1144    */
1145   void postWALRestore(final ObserverContext<? extends RegionCoprocessorEnvironment> ctx,
1146       HRegionInfo info, WALKey logKey, WALEdit logEdit) throws IOException;
1147 
1148   /**
1149    * Called after a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit}
1150    * replayed for this region.
1151    *
1152    * This method is left in place to maintain binary compatibility with older
1153    * {@link RegionObserver}s. If an implementation directly overrides
1154    * {@link #postWALRestore(ObserverContext, HRegionInfo, WALKey, WALEdit)} then this version
1155    * won't be called at all, barring problems with the Security Manager. To work correctly
1156    * in the presence of a strict Security Manager, or in the case of an implementation that
1157    * relies on a parent class to implement preWALRestore, you should implement this method
1158    * as a call to the non-deprecated version.
1159    *
1160    * Users of this method will see all edits that can be treated as HLogKey. If there are
1161    * edits that can't be treated as HLogKey they won't be offered to coprocessors that rely
1162    * on this method. If a coprocessor gets skipped because of this mechanism, a log message
1163    * at ERROR will be generated per coprocessor on the logger for {@link CoprocessorHost} once per
1164    * classloader.
1165    *
1166    * @deprecated use {@link #postWALRestore(ObserverContext, HRegionInfo, WALKey, WALEdit)}
1167    */
1168   @Deprecated
1169   void postWALRestore(final ObserverContext<RegionCoprocessorEnvironment> ctx,
1170       HRegionInfo info, HLogKey logKey, WALEdit logEdit) throws IOException;
1171 
1172   /**
1173    * Called before bulkLoadHFile. Users can create a StoreFile instance to
1174    * access the contents of a HFile.
1175    *
1176    * @param ctx
1177    * @param familyPaths pairs of { CF, HFile path } submitted for bulk load. Adding
1178    * or removing from this list will add or remove HFiles to be bulk loaded.
1179    * @throws IOException
1180    */
1181   void preBulkLoadHFile(final ObserverContext<RegionCoprocessorEnvironment> ctx,
1182     List<Pair<byte[], String>> familyPaths) throws IOException;
1183 
1184   /**
1185    * Called after bulkLoadHFile.
1186    *
1187    * @param ctx
1188    * @param familyPaths pairs of { CF, HFile path } submitted for bulk load
1189    * @param hasLoaded whether the bulkLoad was successful
1190    * @return the new value of hasLoaded
1191    * @throws IOException
1192    */
1193   boolean postBulkLoadHFile(final ObserverContext<RegionCoprocessorEnvironment> ctx,
1194     List<Pair<byte[], String>> familyPaths, boolean hasLoaded) throws IOException;
1195 
1196   /**
1197    * Called before creation of Reader for a store file.
1198    * Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
1199    * effect in this hook.
1200    *
1201    * @param ctx the environment provided by the region server
1202    * @param fs fileystem to read from
1203    * @param p path to the file
1204    * @param in {@link FSDataInputStreamWrapper}
1205    * @param size Full size of the file
1206    * @param cacheConf
1207    * @param r original reference file. This will be not null only when reading a split file.
1208    * @param reader the base reader, if not {@code null}, from previous RegionObserver in the chain
1209    * @return a Reader instance to use instead of the base reader if overriding
1210    * default behavior, null otherwise
1211    * @throws IOException
1212    */
1213   StoreFile.Reader preStoreFileReaderOpen(final ObserverContext<RegionCoprocessorEnvironment> ctx,
1214       final FileSystem fs, final Path p, final FSDataInputStreamWrapper in, long size,
1215       final CacheConfig cacheConf, final Reference r, StoreFile.Reader reader) throws IOException;
1216 
1217   /**
1218    * Called after the creation of Reader for a store file.
1219    *
1220    * @param ctx the environment provided by the region server
1221    * @param fs fileystem to read from
1222    * @param p path to the file
1223    * @param in {@link FSDataInputStreamWrapper}
1224    * @param size Full size of the file
1225    * @param cacheConf
1226    * @param r original reference file. This will be not null only when reading a split file.
1227    * @param reader the base reader instance
1228    * @return The reader to use
1229    * @throws IOException
1230    */
1231   StoreFile.Reader postStoreFileReaderOpen(final ObserverContext<RegionCoprocessorEnvironment> ctx,
1232       final FileSystem fs, final Path p, final FSDataInputStreamWrapper in, long size,
1233       final CacheConfig cacheConf, final Reference r, StoreFile.Reader reader) throws IOException;
1234 
1235   /**
1236    * Called after a new cell has been created during an increment operation, but before
1237    * it is committed to the WAL or memstore.
1238    * Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
1239    * effect in this hook.
1240    * @param ctx the environment provided by the region server
1241    * @param opType the operation type
1242    * @param mutation the current mutation
1243    * @param oldCell old cell containing previous value
1244    * @param newCell the new cell containing the computed value
1245    * @return the new cell, possibly changed
1246    * @throws IOException
1247    */
1248   Cell postMutationBeforeWAL(ObserverContext<RegionCoprocessorEnvironment> ctx,
1249       MutationType opType, Mutation mutation, Cell oldCell, Cell newCell) throws IOException;
1250 
1251   /**
1252    * Called after the ScanQueryMatcher creates ScanDeleteTracker. Implementing
1253    * this hook would help in creating customised DeleteTracker and returning
1254    * the newly created DeleteTracker
1255    *
1256    * @param ctx the environment provided by the region server
1257    * @param delTracker the deleteTracker that is created by the QueryMatcher
1258    * @return the Delete Tracker
1259    * @throws IOException
1260    */
1261   DeleteTracker postInstantiateDeleteTracker(
1262       final ObserverContext<RegionCoprocessorEnvironment> ctx, DeleteTracker delTracker)
1263       throws IOException;
1264 }