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