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.HRegion;
46  import org.apache.hadoop.hbase.regionserver.HRegion.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<RegionCoprocessorEnvironment> 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 HRegion l,
372       final HRegion 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 a client makes a GetClosestRowBefore request.
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 row the row
444    * @param family the family
445    * @param result The result to return to the client if default processing
446    * is bypassed. Can be modified. Will not be used if default processing
447    * is not bypassed.
448    * @throws IOException if an error occurred on the coprocessor
449    */
450   void preGetClosestRowBefore(final ObserverContext<RegionCoprocessorEnvironment> c,
451       final byte [] row, final byte [] family, final Result result)
452     throws IOException;
453 
454   /**
455    * Called after a client makes a GetClosestRowBefore request.
456    * <p>
457    * Call CoprocessorEnvironment#complete to skip any subsequent chained
458    * coprocessors
459    * @param c the environment provided by the region server
460    * @param row the row
461    * @param family the desired family
462    * @param result the result to return to the client, modify as necessary
463    * @throws IOException if an error occurred on the coprocessor
464    */
465   void postGetClosestRowBefore(final ObserverContext<RegionCoprocessorEnvironment> c,
466       final byte [] row, final byte [] family, final Result result)
467     throws IOException;
468 
469   /**
470    * Called before the client performs a Get
471    * <p>
472    * Call CoprocessorEnvironment#bypass to skip default actions
473    * <p>
474    * Call CoprocessorEnvironment#complete to skip any subsequent chained
475    * coprocessors
476    * @param c the environment provided by the region server
477    * @param get the Get request
478    * @param result The result to return to the client if default processing
479    * is bypassed. Can be modified. Will not be used if default processing
480    * is not bypassed.
481    * @throws IOException if an error occurred on the coprocessor
482    */
483   void preGetOp(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
484       final List<Cell> result)
485     throws IOException;
486 
487   /**
488    * Called after the client performs a Get
489    * <p>
490    * Call CoprocessorEnvironment#complete to skip any subsequent chained
491    * coprocessors
492    * @param c the environment provided by the region server
493    * @param get the Get request
494    * @param result the result to return to the client, modify as necessary
495    * @throws IOException if an error occurred on the coprocessor
496    */
497   void postGetOp(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
498       final List<Cell> result)
499     throws IOException;
500 
501   /**
502    * Called before the client tests for existence using a Get.
503    * <p>
504    * Call CoprocessorEnvironment#bypass to skip default actions
505    * <p>
506    * Call CoprocessorEnvironment#complete to skip any subsequent chained
507    * coprocessors
508    * @param c the environment provided by the region server
509    * @param get the Get request
510    * @param exists
511    * @return the value to return to the client if bypassing default processing
512    * @throws IOException if an error occurred on the coprocessor
513    */
514   boolean preExists(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
515       final boolean exists)
516     throws IOException;
517 
518   /**
519    * Called after the client tests for existence using a Get.
520    * <p>
521    * Call CoprocessorEnvironment#complete to skip any subsequent chained
522    * coprocessors
523    * @param c the environment provided by the region server
524    * @param get the Get request
525    * @param exists the result returned by the region server
526    * @return the result to return to the client
527    * @throws IOException if an error occurred on the coprocessor
528    */
529   boolean postExists(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
530       final boolean exists)
531     throws IOException;
532 
533   /**
534    * Called before the client stores a value.
535    * <p>
536    * Call CoprocessorEnvironment#bypass to skip default actions
537    * <p>
538    * Call CoprocessorEnvironment#complete to skip any subsequent chained
539    * coprocessors
540    * @param c the environment provided by the region server
541    * @param put The Put object
542    * @param edit The WALEdit object that will be written to the wal
543    * @param durability Persistence guarantee for this Put
544    * @throws IOException if an error occurred on the coprocessor
545    */
546   void prePut(final ObserverContext<RegionCoprocessorEnvironment> c, 
547       final Put put, final WALEdit edit, final Durability durability)
548     throws IOException;
549 
550   /**
551    * Called after the client stores a value.
552    * <p>
553    * Call CoprocessorEnvironment#complete to skip any subsequent chained
554    * coprocessors
555    * @param c the environment provided by the region server
556    * @param put The Put object
557    * @param edit The WALEdit object for the wal
558    * @param durability Persistence guarantee for this Put
559    * @throws IOException if an error occurred on the coprocessor
560    */
561   void postPut(final ObserverContext<RegionCoprocessorEnvironment> c, 
562       final Put put, final WALEdit edit, final Durability durability)
563     throws IOException;
564 
565   /**
566    * Called before the client deletes a value.
567    * <p>
568    * Call CoprocessorEnvironment#bypass to skip default actions
569    * <p>
570    * Call CoprocessorEnvironment#complete to skip any subsequent chained
571    * coprocessors
572    * @param c the environment provided by the region server
573    * @param delete The Delete object
574    * @param edit The WALEdit object for the wal
575    * @param durability Persistence guarantee for this Delete
576    * @throws IOException if an error occurred on the coprocessor
577    */
578   void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c, 
579       final Delete delete, final WALEdit edit, final Durability durability)
580     throws IOException;
581 /**
582  * Called before the server updates the timestamp for version delete with latest timestamp.
583  * <p>
584  * Call CoprocessorEnvironment#bypass to skip default actions
585  * <p>
586  * Call CoprocessorEnvironment#complete to skip any subsequent chained
587  * coprocessors
588  * @param c the environment provided by the region server
589  * @param mutation - the parent mutation associated with this delete cell
590  * @param cell - The deleteColumn with latest version cell
591  * @param byteNow - timestamp bytes
592  * @param get - the get formed using the current cell's row.
593  * Note that the get does not specify the family and qualifier
594  * @throws IOException
595  */
596   void prePrepareTimeStampForDeleteVersion(final ObserverContext<RegionCoprocessorEnvironment> c,
597       final Mutation mutation, final Cell cell, final byte[] byteNow,
598       final Get get) throws IOException;
599 
600   /**
601    * Called after the client deletes a value.
602    * <p>
603    * Call CoprocessorEnvironment#complete to skip any subsequent chained
604    * coprocessors
605    * @param c the environment provided by the region server
606    * @param delete The Delete object
607    * @param edit The WALEdit object for the wal
608    * @param durability Persistence guarantee for this Delete
609    * @throws IOException if an error occurred on the coprocessor
610    */
611   void postDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
612       final Delete delete, final WALEdit edit, final Durability durability)
613     throws IOException;
614   
615   /**
616    * This will be called for every batch mutation operation happening at the server. This will be
617    * called after acquiring the locks on the mutating rows and after applying the proper timestamp
618    * for each Mutation at the server. The batch may contain Put/Delete. By setting OperationStatus
619    * of Mutations ({@link MiniBatchOperationInProgress#setOperationStatus(int, OperationStatus)}),
620    * {@link RegionObserver} can make HRegion to skip these Mutations.
621    * @param c the environment provided by the region server
622    * @param miniBatchOp batch of Mutations getting applied to region.
623    * @throws IOException if an error occurred on the coprocessor
624    */
625   void preBatchMutate(final ObserverContext<RegionCoprocessorEnvironment> c,
626       final MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException;
627 
628   /**
629    * This will be called after applying a batch of Mutations on a region. The Mutations are added to
630    * memstore and WAL.
631    * @param c the environment provided by the region server
632    * @param miniBatchOp batch of Mutations applied to region.
633    * @throws IOException if an error occurred on the coprocessor
634    */
635   void postBatchMutate(final ObserverContext<RegionCoprocessorEnvironment> c,
636       final MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException;
637 
638   /**
639    * This will be called for region operations where read lock is acquired in
640    * {@link HRegion#startRegionOperation()}.
641    * @param ctx
642    * @param operation The operation is about to be taken on the region
643    * @throws IOException
644    */
645   void postStartRegionOperation(final ObserverContext<RegionCoprocessorEnvironment> ctx,
646       Operation operation) throws IOException;
647 
648   /**
649    * Called after releasing read lock in {@link HRegion#closeRegionOperation(Operation)}.
650    * @param ctx
651    * @param operation
652    * @throws IOException
653    */
654   void postCloseRegionOperation(final ObserverContext<RegionCoprocessorEnvironment> ctx,
655       Operation operation) throws IOException;
656 
657   /**
658    * Called after the completion of batch put/delete and will be called even if the batch operation
659    * fails
660    * @param ctx
661    * @param miniBatchOp 
662    * @param success true if batch operation is successful otherwise false.
663    * @throws IOException
664    */
665   void postBatchMutateIndispensably(final ObserverContext<RegionCoprocessorEnvironment> ctx,
666       MiniBatchOperationInProgress<Mutation> miniBatchOp, final boolean success) throws IOException;
667 
668   /**
669    * Called before checkAndPut.
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 preCheckAndPut(final ObserverContext<RegionCoprocessorEnvironment> c,
688       final byte [] row, final byte [] family, final byte [] qualifier,
689       final CompareOp compareOp, final ByteArrayComparable comparator,
690       final Put put, final boolean result)
691     throws IOException;
692 
693   /**
694    * Called before checkAndPut but after acquiring rowlock.
695    * <p>
696    * <b>Note:</b> Caution to be taken for not doing any long time operation in this hook. 
697    * Row will be locked for longer time. Trying to acquire lock on another row, within this, 
698    * can lead to potential deadlock.
699    * <p>
700    * Call CoprocessorEnvironment#bypass to skip default actions
701    * <p>
702    * Call CoprocessorEnvironment#complete to skip any subsequent chained
703    * coprocessors
704    * @param c the environment provided by the region server
705    * @param row row to check
706    * @param family column family
707    * @param qualifier column qualifier
708    * @param compareOp the comparison operation
709    * @param comparator the comparator
710    * @param put data to put if check succeeds
711    * @param result 
712    * @return the return value to return to client if bypassing default
713    * processing
714    * @throws IOException if an error occurred on the coprocessor
715    */
716   boolean preCheckAndPutAfterRowLock(final ObserverContext<RegionCoprocessorEnvironment> c,
717       final byte[] row, final byte[] family, final byte[] qualifier, final CompareOp compareOp,
718       final ByteArrayComparable comparator, final Put put, 
719       final boolean result) throws IOException;
720 
721   /**
722    * Called after checkAndPut
723    * <p>
724    * Call CoprocessorEnvironment#complete to skip any subsequent chained
725    * coprocessors
726    * @param c the environment provided by the region server
727    * @param row row to check
728    * @param family column family
729    * @param qualifier column qualifier
730    * @param compareOp the comparison operation
731    * @param comparator the comparator
732    * @param put data to put if check succeeds
733    * @param result from the checkAndPut
734    * @return the possibly transformed return value to return to client
735    * @throws IOException if an error occurred on the coprocessor
736    */
737   boolean postCheckAndPut(final ObserverContext<RegionCoprocessorEnvironment> c,
738       final byte [] row, final byte [] family, final byte [] qualifier,
739       final CompareOp compareOp, final ByteArrayComparable comparator,
740       final Put put, final boolean result)
741     throws IOException;
742 
743   /**
744    * Called before checkAndDelete.
745    * <p>
746    * Call CoprocessorEnvironment#bypass to skip default actions
747    * <p>
748    * Call CoprocessorEnvironment#complete to skip any subsequent chained
749    * coprocessors
750    * @param c the environment provided by the region server
751    * @param row row to check
752    * @param family column family
753    * @param qualifier column qualifier
754    * @param compareOp the comparison operation
755    * @param comparator the comparator
756    * @param delete delete to commit if check succeeds
757    * @param result 
758    * @return the value to return to client if bypassing default processing
759    * @throws IOException if an error occurred on the coprocessor
760    */
761   boolean preCheckAndDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
762       final byte [] row, final byte [] family, final byte [] qualifier,
763       final CompareOp compareOp, final ByteArrayComparable comparator,
764       final Delete delete, final boolean result)
765     throws IOException;
766 
767   /**
768    * Called before checkAndDelete but after acquiring rowock.
769    * <p>
770    * <b>Note:</b> Caution to be taken for not doing any long time operation in this hook. 
771    * Row will be locked for longer time. Trying to acquire lock on another row, within this, 
772    * can lead to potential deadlock.
773    * <p>
774    * Call CoprocessorEnvironment#bypass to skip default actions
775    * <p>
776    * Call CoprocessorEnvironment#complete to skip any subsequent chained
777    * coprocessors
778    * @param c the environment provided by the region server
779    * @param row row to check
780    * @param family column family
781    * @param qualifier column qualifier
782    * @param compareOp the comparison operation
783    * @param comparator the comparator
784    * @param delete delete to commit if check succeeds
785    * @param result 
786    * @return the value to return to client if bypassing default processing
787    * @throws IOException if an error occurred on the coprocessor
788    */
789   boolean preCheckAndDeleteAfterRowLock(final ObserverContext<RegionCoprocessorEnvironment> c,
790       final byte[] row, final byte[] family, final byte[] qualifier, final CompareOp compareOp,
791       final ByteArrayComparable comparator, final Delete delete,
792       final boolean result) throws IOException;
793 
794   /**
795    * Called after checkAndDelete
796    * <p>
797    * Call CoprocessorEnvironment#complete to skip any subsequent chained
798    * coprocessors
799    * @param c the environment provided by the region server
800    * @param row row to check
801    * @param family column family
802    * @param qualifier column qualifier
803    * @param compareOp the comparison operation
804    * @param comparator the comparator
805    * @param delete delete to commit if check succeeds
806    * @param result from the CheckAndDelete
807    * @return the possibly transformed returned value to return to client
808    * @throws IOException if an error occurred on the coprocessor
809    */
810   boolean postCheckAndDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
811       final byte [] row, final byte [] family, final byte [] qualifier,
812       final CompareOp compareOp, final ByteArrayComparable comparator,
813       final Delete delete, final boolean result)
814     throws IOException;
815 
816   /**
817    * Called before incrementColumnValue
818    * <p>
819    * Call CoprocessorEnvironment#bypass to skip default actions
820    * <p>
821    * Call CoprocessorEnvironment#complete to skip any subsequent chained
822    * coprocessors
823    * @param c the environment provided by the region server
824    * @param row row to check
825    * @param family column family
826    * @param qualifier column qualifier
827    * @param amount long amount to increment
828    * @param writeToWAL true if the change should be written to the WAL
829    * @return value to return to the client if bypassing default processing
830    * @throws IOException if an error occurred on the coprocessor
831    * @deprecated This hook is no longer called by the RegionServer
832    */
833   @Deprecated
834   long preIncrementColumnValue(final ObserverContext<RegionCoprocessorEnvironment> c,
835       final byte [] row, final byte [] family, final byte [] qualifier,
836       final long amount, final boolean writeToWAL)
837     throws IOException;
838 
839   /**
840    * Called after incrementColumnValue
841    * <p>
842    * Call CoprocessorEnvironment#complete to skip any subsequent chained
843    * coprocessors
844    * @param c the environment provided by the region server
845    * @param row row to check
846    * @param family column family
847    * @param qualifier column qualifier
848    * @param amount long amount to increment
849    * @param writeToWAL true if the change should be written to the WAL
850    * @param result the result returned by incrementColumnValue
851    * @return the result to return to the client
852    * @throws IOException if an error occurred on the coprocessor
853    * @deprecated This hook is no longer called by the RegionServer
854    */
855   @Deprecated
856   long postIncrementColumnValue(final ObserverContext<RegionCoprocessorEnvironment> c,
857       final byte [] row, final byte [] family, final byte [] qualifier,
858       final long amount, final boolean writeToWAL, final long result)
859     throws IOException;
860 
861   /**
862    * Called before Append.
863    * <p>
864    * Call CoprocessorEnvironment#bypass to skip default actions
865    * <p>
866    * Call CoprocessorEnvironment#complete to skip any subsequent chained
867    * coprocessors
868    * @param c the environment provided by the region server
869    * @param append Append object
870    * @return result to return to the client if bypassing default processing
871    * @throws IOException if an error occurred on the coprocessor
872    */
873   Result preAppend(final ObserverContext<RegionCoprocessorEnvironment> c,
874       final Append append)
875     throws IOException;
876 
877   /**
878    * Called before Append but after acquiring rowlock.
879    * <p>
880    * <b>Note:</b> Caution to be taken for not doing any long time operation in this hook. 
881    * Row will be locked for longer time. Trying to acquire lock on another row, within this, 
882    * can lead to potential deadlock.
883    * <p>
884    * Call CoprocessorEnvironment#bypass to skip default actions
885    * <p>
886    * Call CoprocessorEnvironment#complete to skip any subsequent chained
887    * coprocessors
888    * @param c the environment provided by the region server
889    * @param append Append object
890    * @return result to return to the client if bypassing default processing
891    * @throws IOException if an error occurred on the coprocessor
892    */
893   Result preAppendAfterRowLock(final ObserverContext<RegionCoprocessorEnvironment> c,
894       final Append append) throws IOException;
895 
896   /**
897    * Called after Append
898    * <p>
899    * Call CoprocessorEnvironment#complete to skip any subsequent chained
900    * coprocessors
901    * @param c the environment provided by the region server
902    * @param append Append object
903    * @param result the result returned by increment
904    * @return the result to return to the client
905    * @throws IOException if an error occurred on the coprocessor
906    */
907   Result postAppend(final ObserverContext<RegionCoprocessorEnvironment> c,
908       final Append append, final Result result)
909     throws IOException;
910 
911   /**
912    * Called before Increment.
913    * <p>
914    * Call CoprocessorEnvironment#bypass to skip default actions
915    * <p>
916    * Call CoprocessorEnvironment#complete to skip any subsequent chained
917    * coprocessors
918    * @param c the environment provided by the region server
919    * @param increment increment object
920    * @return result to return to the client if bypassing default processing
921    * @throws IOException if an error occurred on the coprocessor
922    */
923   Result preIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
924       final Increment increment)
925     throws IOException;
926 
927   /**
928    * Called before Increment but after acquiring rowlock.
929    * <p>
930    * <b>Note:</b> Caution to be taken for not doing any long time operation in this hook. 
931    * Row will be locked for longer time. Trying to acquire lock on another row, within this, 
932    * can lead to potential deadlock.
933    * <p>
934    * Call CoprocessorEnvironment#bypass to skip default actions
935    * <p>
936    * Call CoprocessorEnvironment#complete to skip any subsequent chained coprocessors
937    * 
938    * @param c
939    *          the environment provided by the region server
940    * @param increment
941    *          increment object
942    * @return result to return to the client if bypassing default processing
943    * @throws IOException
944    *           if an error occurred on the coprocessor
945    */
946   Result preIncrementAfterRowLock(final ObserverContext<RegionCoprocessorEnvironment> c,
947       final Increment increment) throws IOException;
948 
949   /**
950    * Called after increment
951    * <p>
952    * Call CoprocessorEnvironment#complete to skip any subsequent chained
953    * coprocessors
954    * @param c the environment provided by the region server
955    * @param increment increment object
956    * @param result the result returned by increment
957    * @return the result to return to the client
958    * @throws IOException if an error occurred on the coprocessor
959    */
960   Result postIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
961       final Increment increment, final Result result)
962     throws IOException;
963 
964   /**
965    * Called before the client opens a new scanner.
966    * <p>
967    * Call CoprocessorEnvironment#bypass to skip default actions
968    * <p>
969    * Call CoprocessorEnvironment#complete to skip any subsequent chained
970    * coprocessors
971    * @param c the environment provided by the region server
972    * @param scan the Scan specification
973    * @param s if not null, the base scanner
974    * @return an RegionScanner instance to use instead of the base scanner if
975    * overriding default behavior, null otherwise
976    * @throws IOException if an error occurred on the coprocessor
977    */
978   RegionScanner preScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
979       final Scan scan, final RegionScanner s)
980     throws IOException;
981 
982   /**
983    * Called before a store opens a new scanner.
984    * This hook is called when a "user" scanner is opened.
985    * <p>
986    * See {@link #preFlushScannerOpen(ObserverContext, Store, KeyValueScanner, InternalScanner)}
987    * and {@link #preCompactScannerOpen(ObserverContext,
988    *  Store, List, ScanType, long, InternalScanner)}
989    * to override scanners created for flushes or compactions, resp.
990    * <p>
991    * Call CoprocessorEnvironment#complete to skip any subsequent chained
992    * coprocessors.
993    * Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
994    * effect in this hook.
995    * @param c the environment provided by the region server
996    * @param store the store being scanned
997    * @param scan the Scan specification
998    * @param targetCols columns to be used in the scanner
999    * @param s the base scanner, if not {@code null}, from previous RegionObserver in the chain
1000    * @return a KeyValueScanner instance to use or {@code null} to use the default implementation
1001    * @throws IOException if an error occurred on the coprocessor
1002    */
1003   KeyValueScanner preStoreScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
1004       final Store store, final Scan scan, final NavigableSet<byte[]> targetCols,
1005       final KeyValueScanner s) throws IOException;
1006 
1007   /**
1008    * Called after the client opens a new scanner.
1009    * <p>
1010    * Call CoprocessorEnvironment#complete to skip any subsequent chained
1011    * coprocessors
1012    * @param c the environment provided by the region server
1013    * @param scan the Scan specification
1014    * @param s if not null, the base scanner
1015    * @return the scanner instance to use
1016    * @throws IOException if an error occurred on the coprocessor
1017    */
1018   RegionScanner postScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
1019       final Scan scan, final RegionScanner s)
1020     throws IOException;
1021 
1022   /**
1023    * Called before the client asks for the next row on a scanner.
1024    * <p>
1025    * Call CoprocessorEnvironment#bypass to skip default actions
1026    * <p>
1027    * Call CoprocessorEnvironment#complete to skip any subsequent chained
1028    * coprocessors
1029    * @param c the environment provided by the region server
1030    * @param s the scanner
1031    * @param result The result to return to the client if default processing
1032    * is bypassed. Can be modified. Will not be returned if default processing
1033    * is not bypassed.
1034    * @param limit the maximum number of results to return
1035    * @param hasNext the 'has more' indication
1036    * @return 'has more' indication that should be sent to client
1037    * @throws IOException if an error occurred on the coprocessor
1038    */
1039   boolean preScannerNext(final ObserverContext<RegionCoprocessorEnvironment> c,
1040       final InternalScanner s, final List<Result> result,
1041       final int limit, final boolean hasNext)
1042     throws IOException;
1043 
1044   /**
1045    * Called after the client asks for the next row on a scanner.
1046    * <p>
1047    * Call CoprocessorEnvironment#complete to skip any subsequent chained
1048    * coprocessors
1049    * @param c the environment provided by the region server
1050    * @param s the scanner
1051    * @param result the result to return to the client, can be modified
1052    * @param limit the maximum number of results to return
1053    * @param hasNext the 'has more' indication
1054    * @return 'has more' indication that should be sent to client
1055    * @throws IOException if an error occurred on the coprocessor
1056    */
1057   boolean postScannerNext(final ObserverContext<RegionCoprocessorEnvironment> c,
1058       final InternalScanner s, final List<Result> result, final int limit,
1059       final boolean hasNext)
1060     throws IOException;
1061 
1062   /**
1063    * This will be called by the scan flow when the current scanned row is being filtered out by the
1064    * filter. The filter may be filtering out the row via any of the below scenarios
1065    * <ol>
1066    * <li>
1067    * <code>boolean filterRowKey(byte [] buffer, int offset, int length)</code> returning true</li>
1068    * <li>
1069    * <code>boolean filterRow()</code> returning true</li>
1070    * <li>
1071    * <code>void filterRow(List<KeyValue> kvs)</code> removing all the kvs from the passed List</li>
1072    * </ol>
1073    * @param c the environment provided by the region server
1074    * @param s the scanner
1075    * @param currentRow The current rowkey which got filtered out
1076    * @param offset offset to rowkey
1077    * @param length length of rowkey
1078    * @param hasMore the 'has more' indication
1079    * @return whether more rows are available for the scanner or not
1080    * @throws IOException
1081    */
1082   boolean postScannerFilterRow(final ObserverContext<RegionCoprocessorEnvironment> c,
1083       final InternalScanner s, final byte[] currentRow, final int offset, final short length,
1084       final boolean hasMore) throws IOException;
1085   
1086   /**
1087    * Called before the client closes a scanner.
1088    * <p>
1089    * Call CoprocessorEnvironment#bypass to skip default actions
1090    * <p>
1091    * Call CoprocessorEnvironment#complete to skip any subsequent chained
1092    * coprocessors
1093    * @param c the environment provided by the region server
1094    * @param s the scanner
1095    * @throws IOException if an error occurred on the coprocessor
1096    */
1097   void preScannerClose(final ObserverContext<RegionCoprocessorEnvironment> c,
1098       final InternalScanner s)
1099     throws IOException;
1100 
1101   /**
1102    * Called after the client closes a scanner.
1103    * <p>
1104    * Call CoprocessorEnvironment#complete to skip any subsequent chained
1105    * coprocessors
1106    * @param c the environment provided by the region server
1107    * @param s the scanner
1108    * @throws IOException if an error occurred on the coprocessor
1109    */
1110   void postScannerClose(final ObserverContext<RegionCoprocessorEnvironment> c,
1111       final InternalScanner s)
1112     throws IOException;
1113 
1114   /**
1115    * Called before a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit}
1116    * replayed for this region.
1117    */
1118   void preWALRestore(final ObserverContext<? extends RegionCoprocessorEnvironment> ctx,
1119       HRegionInfo info, WALKey logKey, WALEdit logEdit) throws IOException;
1120 
1121   /**
1122    * Called before a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit}
1123    * replayed for this region.
1124    *
1125    * This method is left in place to maintain binary compatibility with older
1126    * {@link RegionObserver}s. If an implementation directly overrides
1127    * {@link #preWALRestore(ObserverContext, HRegionInfo, WALKey, WALEdit)} then this version
1128    * won't be called at all, barring problems with the Security Manager. To work correctly
1129    * in the presence of a strict Security Manager, or in the case of an implementation that
1130    * relies on a parent class to implement preWALRestore, you should implement this method
1131    * as a call to the non-deprecated version.
1132    *
1133    * Users of this method will see all edits that can be treated as HLogKey. If there are
1134    * edits that can't be treated as HLogKey they won't be offered to coprocessors that rely
1135    * on this method. If a coprocessor gets skipped because of this mechanism, a log message
1136    * at ERROR will be generated per coprocessor on the logger for {@link CoprocessorHost} once per
1137    * classloader.
1138    *
1139    * @deprecated use {@link #preWALRestore(ObserverContext, HRegionInfo, WALKey, WALEdit)}
1140    */
1141   @Deprecated
1142   void preWALRestore(final ObserverContext<RegionCoprocessorEnvironment> ctx,
1143       HRegionInfo info, HLogKey logKey, WALEdit logEdit) throws IOException;
1144 
1145   /**
1146    * Called after a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit}
1147    * replayed for this region.
1148    */
1149   void postWALRestore(final ObserverContext<? extends RegionCoprocessorEnvironment> ctx,
1150       HRegionInfo info, WALKey logKey, WALEdit logEdit) throws IOException;
1151 
1152   /**
1153    * Called after a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit}
1154    * replayed for this region.
1155    *
1156    * This method is left in place to maintain binary compatibility with older
1157    * {@link RegionObserver}s. If an implementation directly overrides
1158    * {@link #postWALRestore(ObserverContext, HRegionInfo, WALKey, WALEdit)} then this version
1159    * won't be called at all, barring problems with the Security Manager. To work correctly
1160    * in the presence of a strict Security Manager, or in the case of an implementation that
1161    * relies on a parent class to implement preWALRestore, you should implement this method
1162    * as a call to the non-deprecated version.
1163    *
1164    * Users of this method will see all edits that can be treated as HLogKey. If there are
1165    * edits that can't be treated as HLogKey they won't be offered to coprocessors that rely
1166    * on this method. If a coprocessor gets skipped because of this mechanism, a log message
1167    * at ERROR will be generated per coprocessor on the logger for {@link CoprocessorHost} once per
1168    * classloader.
1169    *
1170    * @deprecated use {@link #postWALRestore(ObserverContext, HRegionInfo, WALKey, WALEdit)}
1171    */
1172   @Deprecated
1173   void postWALRestore(final ObserverContext<RegionCoprocessorEnvironment> ctx,
1174       HRegionInfo info, HLogKey logKey, WALEdit logEdit) throws IOException;
1175 
1176   /**
1177    * Called before bulkLoadHFile. Users can create a StoreFile instance to
1178    * access the contents of a HFile.
1179    *
1180    * @param ctx
1181    * @param familyPaths pairs of { CF, HFile path } submitted for bulk load. Adding
1182    * or removing from this list will add or remove HFiles to be bulk loaded.
1183    * @throws IOException
1184    */
1185   void preBulkLoadHFile(final ObserverContext<RegionCoprocessorEnvironment> ctx,
1186     List<Pair<byte[], String>> familyPaths) throws IOException;
1187 
1188   /**
1189    * Called after bulkLoadHFile.
1190    *
1191    * @param ctx
1192    * @param familyPaths pairs of { CF, HFile path } submitted for bulk load
1193    * @param hasLoaded whether the bulkLoad was successful
1194    * @return the new value of hasLoaded
1195    * @throws IOException
1196    */
1197   boolean postBulkLoadHFile(final ObserverContext<RegionCoprocessorEnvironment> ctx,
1198     List<Pair<byte[], String>> familyPaths, boolean hasLoaded) throws IOException;
1199 
1200   /**
1201    * Called before creation of Reader for a store file.
1202    * Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
1203    * effect in this hook.
1204    * 
1205    * @param ctx the environment provided by the region server
1206    * @param fs fileystem to read from
1207    * @param p path to the file
1208    * @param in {@link FSDataInputStreamWrapper}
1209    * @param size Full size of the file
1210    * @param cacheConf
1211    * @param r original reference file. This will be not null only when reading a split file.
1212    * @param reader the base reader, if not {@code null}, from previous RegionObserver in the chain
1213    * @return a Reader instance to use instead of the base reader if overriding
1214    * default behavior, null otherwise
1215    * @throws IOException
1216    */
1217   StoreFile.Reader preStoreFileReaderOpen(final ObserverContext<RegionCoprocessorEnvironment> ctx,
1218       final FileSystem fs, final Path p, final FSDataInputStreamWrapper in, long size,
1219       final CacheConfig cacheConf, final Reference r, StoreFile.Reader reader) throws IOException;
1220 
1221   /**
1222    * Called after the creation of Reader for a store file.
1223    * 
1224    * @param ctx the environment provided by the region server
1225    * @param fs fileystem to read from
1226    * @param p path to the file
1227    * @param in {@link FSDataInputStreamWrapper}
1228    * @param size Full size of the file
1229    * @param cacheConf
1230    * @param r original reference file. This will be not null only when reading a split file.
1231    * @param reader the base reader instance
1232    * @return The reader to use
1233    * @throws IOException
1234    */
1235   StoreFile.Reader postStoreFileReaderOpen(final ObserverContext<RegionCoprocessorEnvironment> ctx,
1236       final FileSystem fs, final Path p, final FSDataInputStreamWrapper in, long size,
1237       final CacheConfig cacheConf, final Reference r, StoreFile.Reader reader) throws IOException;
1238 
1239   /**
1240    * Called after a new cell has been created during an increment operation, but before
1241    * it is committed to the WAL or memstore.
1242    * Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
1243    * effect in this hook.
1244    * @param ctx the environment provided by the region server
1245    * @param opType the operation type
1246    * @param mutation the current mutation
1247    * @param oldCell old cell containing previous value
1248    * @param newCell the new cell containing the computed value
1249    * @return the new cell, possibly changed
1250    * @throws IOException
1251    */
1252   Cell postMutationBeforeWAL(ObserverContext<RegionCoprocessorEnvironment> ctx,
1253       MutationType opType, Mutation mutation, Cell oldCell, Cell newCell) throws IOException;
1254 
1255   /**
1256    * Called after the ScanQueryMatcher creates ScanDeleteTracker. Implementing
1257    * this hook would help in creating customised DeleteTracker and returning
1258    * the newly created DeleteTracker
1259    *
1260    * @param ctx the environment provided by the region server
1261    * @param delTracker the deleteTracker that is created by the QueryMatcher
1262    * @return the Delete Tracker
1263    * @throws IOException
1264    */
1265   DeleteTracker postInstantiateDeleteTracker(
1266       final ObserverContext<RegionCoprocessorEnvironment> ctx, DeleteTracker delTracker)
1267       throws IOException;
1268 }