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