View Javadoc

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