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.classification.InterfaceAudience;
23  import org.apache.hadoop.classification.InterfaceStability;
24  import org.apache.hadoop.hbase.Cell;
25  import org.apache.hadoop.hbase.Coprocessor;
26  import org.apache.hadoop.hbase.HBaseInterfaceAudience;
27  import org.apache.hadoop.hbase.HRegionInfo;
28  import org.apache.hadoop.hbase.KeyValue;
29  import org.apache.hadoop.hbase.client.Append;
30  import org.apache.hadoop.hbase.client.Delete;
31  import org.apache.hadoop.hbase.client.Get;
32  import org.apache.hadoop.hbase.client.Increment;
33  import org.apache.hadoop.hbase.client.Mutation;
34  import org.apache.hadoop.hbase.client.Put;
35  import org.apache.hadoop.hbase.client.Result;
36  import org.apache.hadoop.hbase.client.Scan;
37  import org.apache.hadoop.hbase.client.Durability;
38  import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
39  import org.apache.hadoop.hbase.filter.ByteArrayComparable;
40  import org.apache.hadoop.hbase.regionserver.HRegion;
41  import org.apache.hadoop.hbase.regionserver.InternalScanner;
42  import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
43  import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress;
44  import org.apache.hadoop.hbase.regionserver.RegionScanner;
45  import org.apache.hadoop.hbase.regionserver.ScanType;
46  import org.apache.hadoop.hbase.regionserver.Store;
47  import org.apache.hadoop.hbase.regionserver.StoreFile;
48  import org.apache.hadoop.hbase.regionserver.StoreFileScanner;
49  import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
50  import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
51  import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
52  
53  import com.google.common.collect.ImmutableList;
54  import org.apache.hadoop.hbase.util.Pair;
55  
56  /**
57   * Coprocessors implement this interface to observe and mediate client actions
58   * on the region.
59   */
60  @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
61  @InterfaceStability.Evolving
62  public interface RegionObserver extends Coprocessor {
63  
64    /**
65     * Called before the region is reported as open to the master.
66     * @param c the environment provided by the region server
67     * @throws IOException if an error occurred on the coprocessor
68     */
69    void preOpen(final ObserverContext<RegionCoprocessorEnvironment> c) throws IOException;
70  
71    /**
72     * Called after the region is reported as open to the master.
73     * @param c the environment provided by the region server
74     */
75    void postOpen(final ObserverContext<RegionCoprocessorEnvironment> c);
76  
77    /**
78     * Called before a memstore is flushed to disk and prior to creating the scanner to read from
79     * the memstore.  To override or modify how a memstore is flushed,
80     * implementing classes can return a new scanner to provide the KeyValues to be
81     * stored into the new {@code StoreFile} or null to perform the default processing.
82     * Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
83     * effect in this hook.
84     * @param c the environment provided by the region server
85     * @param store the store being flushed
86     * @param memstoreScanner the scanner for the memstore that is flushed
87     * @param s the base scanner, if not {@code null}, from previous RegionObserver in the chain
88     * @return the scanner to use during the flush.  {@code null} if the default implementation
89     * is to be used.
90     * @throws IOException if an error occurred on the coprocessor
91     */
92    InternalScanner preFlushScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
93        final Store store, final KeyValueScanner memstoreScanner, final InternalScanner s)
94        throws IOException;
95  
96    /**
97     * Called before the memstore is flushed to disk.
98     * @param c the environment provided by the region server
99     * @throws IOException if an error occurred on the coprocessor
100    * @deprecated use {@link #preFlush(ObserverContext, Store, InternalScanner)} instead
101    */
102   void preFlush(final ObserverContext<RegionCoprocessorEnvironment> c) throws IOException;
103 
104   /**
105    * Called before a Store's memstore is flushed to disk.
106    * @param c the environment provided by the region server
107    * @param store the store where compaction is being requested
108    * @param scanner the scanner over existing data used in the store file
109    * @return the scanner to use during compaction.  Should not be {@code null}
110    * unless the implementation is writing new store files on its own.
111    * @throws IOException if an error occurred on the coprocessor
112    */
113   InternalScanner preFlush(final ObserverContext<RegionCoprocessorEnvironment> c, final Store store,
114       final InternalScanner scanner) throws IOException;
115 
116   /**
117    * Called after 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   void postFlush(final ObserverContext<RegionCoprocessorEnvironment> c) throws IOException;
123 
124   /**
125    * Called after a Store's memstore is flushed to disk.
126    * @param c the environment provided by the region server
127    * @param store the store being flushed
128    * @param resultFile the new store file written out during compaction
129    * @throws IOException if an error occurred on the coprocessor
130    */
131   void postFlush(final ObserverContext<RegionCoprocessorEnvironment> c, final Store store,
132       final StoreFile resultFile) throws IOException;
133 
134   /**
135    * Called prior to selecting the {@link StoreFile StoreFiles} to compact from the list of
136    * available candidates. To alter the files used for compaction, you may mutate the passed in list
137    * of candidates.
138    * @param c the environment provided by the region server
139    * @param store the store where compaction is being requested
140    * @param candidates the store files currently available for compaction
141    * @param request custom compaction request
142    * @throws IOException if an error occurred on the coprocessor
143    */
144   void preCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
145       final Store store, final List<StoreFile> candidates, final CompactionRequest request)
146       throws IOException;
147 
148   /**
149    * Called prior to selecting the {@link StoreFile}s to compact from the list of available
150    * candidates. To alter the files used for compaction, you may mutate the passed in list of
151    * candidates.
152    * @param c the environment provided by the region server
153    * @param store the store where compaction is being requested
154    * @param candidates the store files currently available for compaction
155    * @throws IOException if an error occurred on the coprocessor
156    * @deprecated Use {@link #preCompactSelection(ObserverContext, Store, List, CompactionRequest)}
157    *             instead
158    */
159   @Deprecated
160   void preCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
161       final Store store, final List<StoreFile> candidates) throws IOException;
162 
163   /**
164    * Called after the {@link StoreFile}s to compact have been selected from the available
165    * candidates.
166    * @param c the environment provided by the region server
167    * @param store the store being compacted
168    * @param selected the store files selected to compact
169    * @param request custom compaction request
170    */
171   void postCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
172       final Store store, final ImmutableList<StoreFile> selected, CompactionRequest request);
173 
174   /**
175    * Called after the {@link StoreFile}s to compact have been selected from the available
176    * candidates.
177    * @param c the environment provided by the region server
178    * @param store the store being compacted
179    * @param selected the store files selected to compact
180    * @deprecated use {@link #postCompactSelection(ObserverContext, Store, ImmutableList,
181    *             CompactionRequest)} instead.
182    */
183   @Deprecated
184   void postCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
185       final Store store, final ImmutableList<StoreFile> selected);
186 
187   /**
188    * Called prior to writing the {@link StoreFile}s selected for compaction into a new
189    * {@code StoreFile}. To override or modify the compaction process, implementing classes have two
190    * options:
191    * <ul>
192    * <li>Wrap the provided {@link InternalScanner} with a custom implementation that is returned
193    * from this method. The custom scanner can then inspect {@link KeyValue}s from the wrapped
194    * scanner, applying its own policy to what gets written.</li>
195    * <li>Call {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} and provide a
196    * custom implementation for writing of new {@link StoreFile}s. <strong>Note: any implementations
197    * bypassing core compaction using this approach must write out new store files themselves or the
198    * existing data will no longer be available after compaction.</strong></li>
199    * </ul>
200    * @param c the environment provided by the region server
201    * @param store the store being compacted
202    * @param scanner the scanner over existing data used in the store file rewriting
203    * @param scanType type of Scan
204    * @param request the requested compaction
205    * @return the scanner to use during compaction. Should not be {@code null} unless the
206    *         implementation is writing new store files on its own.
207    * @throws IOException if an error occurred on the coprocessor
208    */
209   InternalScanner preCompact(final ObserverContext<RegionCoprocessorEnvironment> c,
210       final Store store, final InternalScanner scanner, final ScanType scanType,
211       CompactionRequest request) throws IOException;
212 
213   /**
214    * Called prior to writing the {@link StoreFile}s selected for compaction into a new
215    * {@code StoreFile}. To override or modify the compaction process, implementing classes have two
216    * options:
217    * <ul>
218    * <li>Wrap the provided {@link InternalScanner} with a custom implementation that is returned
219    * from this method. The custom scanner can then inspect {@link KeyValue}s from the wrapped
220    * scanner, applying its own policy to what gets written.</li>
221    * <li>Call {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} and provide a
222    * custom implementation for writing of new {@link StoreFile}s. <strong>Note: any implementations
223    * bypassing core compaction using this approach must write out new store files themselves or the
224    * existing data will no longer be available after compaction.</strong></li>
225    * </ul>
226    * @param c the environment provided by the region server
227    * @param store the store being compacted
228    * @param scanner the scanner over existing data used in the store file rewriting
229    * @param scanType type of Scan
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    * @deprecated use
234    *             {@link #preCompact(ObserverContext, Store, InternalScanner,
235    *             ScanType, CompactionRequest)} instead
236    */
237   @Deprecated
238   InternalScanner preCompact(final ObserverContext<RegionCoprocessorEnvironment> c,
239       final Store store, final InternalScanner scanner, final ScanType scanType) throws IOException;
240 
241   /**
242    * Called prior to writing the {@link StoreFile}s selected for compaction into a new
243    * {@code StoreFile} and prior to creating the scanner used to read the input files. To override
244    * or modify the compaction process, implementing classes can return a new scanner to provide the
245    * KeyValues to be stored into the new {@code StoreFile} or null to perform the default
246    * processing. Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
247    * effect in this hook.
248    * @param c the environment provided by the region server
249    * @param store the store being compacted
250    * @param scanners the list {@link StoreFileScanner}s to be read from
251    * @param scanType the {@link ScanType} indicating whether this is a major or minor compaction
252    * @param earliestPutTs timestamp of the earliest put that was found in any of the involved store
253    *          files
254    * @param s the base scanner, if not {@code null}, from previous RegionObserver in the chain
255    * @param request the requested compaction
256    * @return the scanner to use during compaction. {@code null} if the default implementation is to
257    *         be used.
258    * @throws IOException if an error occurred on the coprocessor
259    */
260   InternalScanner preCompactScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
261       final Store store, List<? extends KeyValueScanner> scanners, final ScanType scanType,
262       final long earliestPutTs, final InternalScanner s, CompactionRequest request)
263       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 StoreFileScanner}s to be read from
275    * @param scanType the {@link ScanType} indicating whether this is a major or minor compaction
276    * @param earliestPutTs timestamp of the earliest put that was found in any of the involved store
277    *          files
278    * @param s the base scanner, if not {@code null}, from previous RegionObserver in the chain
279    * @return the scanner to use during compaction. {@code null} if the default implementation is to
280    *         be used.
281    * @throws IOException if an error occurred on the coprocessor
282    * @deprecated Use
283    *             {@link #preCompactScannerOpen(ObserverContext, Store, List, ScanType, long,
284    *             InternalScanner, CompactionRequest)} instead.
285    */
286   @Deprecated
287   InternalScanner preCompactScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
288       final Store store, List<? extends KeyValueScanner> scanners, final ScanType scanType,
289       final long earliestPutTs, final InternalScanner s) throws IOException;
290 
291   /**
292    * Called after compaction has completed and the new store file has been moved in to place.
293    * @param c the environment provided by the region server
294    * @param store the store being compacted
295    * @param resultFile the new store file written out during compaction
296    * @param request the requested compaction
297    * @throws IOException if an error occurred on the coprocessor
298    */
299   void postCompact(final ObserverContext<RegionCoprocessorEnvironment> c, final Store store,
300       StoreFile resultFile, CompactionRequest request) throws IOException;
301 
302   /**
303    * Called after compaction has completed and the new store file has been moved in to place.
304    * @param c the environment provided by the region server
305    * @param store the store being compacted
306    * @param resultFile the new store file written out during compaction
307    * @throws IOException if an error occurred on the coprocessor
308    * @deprecated Use {@link #postCompact(ObserverContext, Store, StoreFile, CompactionRequest)}
309    *             instead
310    */
311   @Deprecated
312   void postCompact(final ObserverContext<RegionCoprocessorEnvironment> c, final Store store,
313       StoreFile resultFile) throws IOException;
314 
315   /**
316    * Called before the region is split.
317    * @param c the environment provided by the region server
318    * (e.getRegion() returns the parent region)
319    * @throws IOException if an error occurred on the coprocessor
320    * @deprecated Use preSplit(
321    *    final ObserverContext<RegionCoprocessorEnvironment> c, byte[] splitRow)
322    */
323   void preSplit(final ObserverContext<RegionCoprocessorEnvironment> c) throws IOException;
324 
325   /**
326    * Called before the region is split.
327    * @param c the environment provided by the region server
328    * (e.getRegion() returns the parent region)
329    * @throws IOException if an error occurred on the coprocessor
330    */
331   void preSplit(final ObserverContext<RegionCoprocessorEnvironment> c, byte[] splitRow)
332       throws IOException;
333 
334   /**
335    * Called after the region is split.
336    * @param c the environment provided by the region server
337    * (e.getRegion() returns the parent region)
338    * @param l the left daughter region
339    * @param r the right daughter region
340    * @throws IOException if an error occurred on the coprocessor
341    * @deprecated Use postCompleteSplit() instead
342    */
343   void postSplit(final ObserverContext<RegionCoprocessorEnvironment> c, final HRegion l,
344       final HRegion r) throws IOException;
345 
346   /**
347    * This will be called before the roll back of the split region is completed 
348    * @param ctx
349    * @throws IOException
350    */
351   void preRollBackSplit(final ObserverContext<RegionCoprocessorEnvironment> ctx) throws IOException;
352 
353   /**
354    * This will be called after the roll back of the split region is completed
355    * @param ctx
356    * @throws IOException
357    */
358   void postRollBackSplit(final ObserverContext<RegionCoprocessorEnvironment> ctx)
359     throws IOException;
360 
361   /**
362    * Called after any split request is processed.  This will be called irrespective of success or
363    * failure of the split.
364    * @param ctx
365    * @throws IOException
366    */
367   void postCompleteSplit(final ObserverContext<RegionCoprocessorEnvironment> ctx)
368     throws IOException;
369   /**
370    * Called before the region is reported as closed to the master.
371    * @param c the environment provided by the region server
372    * @param abortRequested true if the region server is aborting
373    * @throws IOException 
374    */
375   void preClose(final ObserverContext<RegionCoprocessorEnvironment> c,
376       boolean abortRequested) throws IOException;
377 
378   /**
379    * Called after the region is reported as closed to the master.
380    * @param c the environment provided by the region server
381    * @param abortRequested true if the region server is aborting
382    */
383   void postClose(final ObserverContext<RegionCoprocessorEnvironment> c,
384       boolean abortRequested);
385 
386   /**
387    * Called before a client makes a GetClosestRowBefore request.
388    * <p>
389    * Call CoprocessorEnvironment#bypass to skip default actions
390    * <p>
391    * Call CoprocessorEnvironment#complete to skip any subsequent chained
392    * coprocessors
393    * @param c the environment provided by the region server
394    * @param row the row
395    * @param family the family
396    * @param result The result to return to the client if default processing
397    * is bypassed. Can be modified. Will not be used if default processing
398    * is not bypassed.
399    * @throws IOException if an error occurred on the coprocessor
400    */
401   void preGetClosestRowBefore(final ObserverContext<RegionCoprocessorEnvironment> c,
402       final byte [] row, final byte [] family, final Result result)
403     throws IOException;
404 
405   /**
406    * Called after a client makes a GetClosestRowBefore request.
407    * <p>
408    * Call CoprocessorEnvironment#complete to skip any subsequent chained
409    * coprocessors
410    * @param c the environment provided by the region server
411    * @param row the row
412    * @param family the desired family
413    * @param result the result to return to the client, modify as necessary
414    * @throws IOException if an error occurred on the coprocessor
415    */
416   void postGetClosestRowBefore(final ObserverContext<RegionCoprocessorEnvironment> c,
417       final byte [] row, final byte [] family, final Result result)
418     throws IOException;
419 
420   /**
421    * Called before the client performs a Get
422    * <p>
423    * Call CoprocessorEnvironment#bypass to skip default actions
424    * <p>
425    * Call CoprocessorEnvironment#complete to skip any subsequent chained
426    * coprocessors
427    * @param c the environment provided by the region server
428    * @param get the Get request
429    * @param result The result to return to the client if default processing
430    * is bypassed. Can be modified. Will not be used if default processing
431    * is not bypassed.
432    * @throws IOException if an error occurred on the coprocessor
433    */
434   void preGetOp(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
435       final List<Cell> result)
436     throws IOException;
437 
438   /**
439    * WARNING: please override preGetOp instead of this method.  This is to maintain some
440    * compatibility and to ease the transition from 0.94 -> 0.96.
441    */
442   @Deprecated
443   void preGet(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
444       final List<KeyValue> result)
445     throws IOException;
446 
447   /**
448    * Called after the client performs a Get
449    * <p>
450    * Call CoprocessorEnvironment#complete to skip any subsequent chained
451    * coprocessors
452    * @param c the environment provided by the region server
453    * @param get the Get request
454    * @param result the result to return to the client, modify as necessary
455    * @throws IOException if an error occurred on the coprocessor
456    */
457   void postGetOp(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
458       final List<Cell> result)
459     throws IOException;
460 
461   /**
462    * WARNING: please override postGetOp instead of this method.  This is to maintain some
463    * compatibility and to ease the transition from 0.94 -> 0.96.
464    */
465   @Deprecated
466   void postGet(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
467       final List<KeyValue> result)
468     throws IOException;
469 
470   /**
471    * Called before the client tests for existence using a Get.
472    * <p>
473    * Call CoprocessorEnvironment#bypass to skip default actions
474    * <p>
475    * Call CoprocessorEnvironment#complete to skip any subsequent chained
476    * coprocessors
477    * @param c the environment provided by the region server
478    * @param get the Get request
479    * @param exists
480    * @return the value to return to the client if bypassing default processing
481    * @throws IOException if an error occurred on the coprocessor
482    */
483   boolean preExists(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
484       final boolean exists)
485     throws IOException;
486 
487   /**
488    * Called after the client tests for existence using 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 exists the result returned by the region server
495    * @return the result to return to the client
496    * @throws IOException if an error occurred on the coprocessor
497    */
498   boolean postExists(final ObserverContext<RegionCoprocessorEnvironment> c, final Get get,
499       final boolean exists)
500     throws IOException;
501 
502   /**
503    * Called before the client stores a value.
504    * <p>
505    * Call CoprocessorEnvironment#bypass to skip default actions
506    * <p>
507    * Call CoprocessorEnvironment#complete to skip any subsequent chained
508    * coprocessors
509    * @param c the environment provided by the region server
510    * @param put The Put object
511    * @param edit The WALEdit object that will be written to the wal
512    * @param durability Persistence guarantee for this Put
513    * @throws IOException if an error occurred on the coprocessor
514    */
515   void prePut(final ObserverContext<RegionCoprocessorEnvironment> c, 
516       final Put put, final WALEdit edit, final Durability durability)
517     throws IOException;
518 
519   /**
520    * Called after the client stores a value.
521    * <p>
522    * Call CoprocessorEnvironment#complete to skip any subsequent chained
523    * coprocessors
524    * @param c the environment provided by the region server
525    * @param put The Put object
526    * @param edit The WALEdit object for the wal
527    * @param durability Persistence guarantee for this Put
528    * @throws IOException if an error occurred on the coprocessor
529    */
530   void postPut(final ObserverContext<RegionCoprocessorEnvironment> c, 
531       final Put put, final WALEdit edit, final Durability durability)
532     throws IOException;
533 
534   /**
535    * Called before the client deletes a value.
536    * <p>
537    * Call CoprocessorEnvironment#bypass to skip default actions
538    * <p>
539    * Call CoprocessorEnvironment#complete to skip any subsequent chained
540    * coprocessors
541    * @param c the environment provided by the region server
542    * @param delete The Delete object
543    * @param edit The WALEdit object for the wal
544    * @param durability Persistence guarantee for this Delete
545    * @throws IOException if an error occurred on the coprocessor
546    */
547   void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c, 
548       final Delete delete, final WALEdit edit, final Durability durability)
549     throws IOException;
550 
551   /**
552    * Called after the client deletes a value.
553    * <p>
554    * Call CoprocessorEnvironment#complete to skip any subsequent chained
555    * coprocessors
556    * @param c the environment provided by the region server
557    * @param delete The Delete object
558    * @param edit The WALEdit object for the wal
559    * @param durability Persistence guarantee for this Delete
560    * @throws IOException if an error occurred on the coprocessor
561    */
562   void postDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
563       final Delete delete, final WALEdit edit, final Durability durability)
564     throws IOException;
565   
566   /**
567    * This will be called for every batch mutation operation happening at the server. This will be
568    * called after acquiring the locks on the mutating rows and after applying the proper timestamp
569    * for each Mutation at the server. The batch may contain Put/Delete. By setting OperationStatus
570    * of Mutations ({@link MiniBatchOperationInProgress#setOperationStatus(int, OperationStatus)}),
571    * {@link RegionObserver} can make HRegion to skip these Mutations.
572    * @param c the environment provided by the region server
573    * @param miniBatchOp batch of Mutations getting applied to region.
574    * @throws IOException if an error occurred on the coprocessor
575    */
576   void preBatchMutate(final ObserverContext<RegionCoprocessorEnvironment> c,
577       final MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException;
578 
579   /**
580    * This will be called after applying a batch of Mutations on a region. The Mutations are added to
581    * memstore and WAL.
582    * @param c the environment provided by the region server
583    * @param miniBatchOp batch of Mutations applied to region.
584    * @throws IOException if an error occurred on the coprocessor
585    */
586   void postBatchMutate(final ObserverContext<RegionCoprocessorEnvironment> c,
587       final MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException;
588 
589   /**
590    * Called before checkAndPut
591    * <p>
592    * Call CoprocessorEnvironment#bypass to skip default actions
593    * <p>
594    * Call CoprocessorEnvironment#complete to skip any subsequent chained
595    * coprocessors
596    * @param c the environment provided by the region server
597    * @param row row to check
598    * @param family column family
599    * @param qualifier column qualifier
600    * @param compareOp the comparison operation
601    * @param comparator the comparator
602    * @param put data to put if check succeeds
603    * @param result 
604    * @return the return value to return to client if bypassing default
605    * processing
606    * @throws IOException if an error occurred on the coprocessor
607    */
608   boolean preCheckAndPut(final ObserverContext<RegionCoprocessorEnvironment> c,
609       final byte [] row, final byte [] family, final byte [] qualifier,
610       final CompareOp compareOp, final ByteArrayComparable comparator,
611       final Put put, final boolean result)
612     throws IOException;
613 
614   /**
615    * Called after checkAndPut
616    * <p>
617    * Call CoprocessorEnvironment#complete to skip any subsequent chained
618    * coprocessors
619    * @param c the environment provided by the region server
620    * @param row row to check
621    * @param family column family
622    * @param qualifier column qualifier
623    * @param compareOp the comparison operation
624    * @param comparator the comparator
625    * @param put data to put if check succeeds
626    * @param result from the checkAndPut
627    * @return the possibly transformed return value to return to client
628    * @throws IOException if an error occurred on the coprocessor
629    */
630   boolean postCheckAndPut(final ObserverContext<RegionCoprocessorEnvironment> c,
631       final byte [] row, final byte [] family, final byte [] qualifier,
632       final CompareOp compareOp, final ByteArrayComparable comparator,
633       final Put put, final boolean result)
634     throws IOException;
635 
636   /**
637    * Called before checkAndDelete
638    * <p>
639    * Call CoprocessorEnvironment#bypass to skip default actions
640    * <p>
641    * Call CoprocessorEnvironment#complete to skip any subsequent chained
642    * coprocessors
643    * @param c the environment provided by the region server
644    * @param row row to check
645    * @param family column family
646    * @param qualifier column qualifier
647    * @param compareOp the comparison operation
648    * @param comparator the comparator
649    * @param delete delete to commit if check succeeds
650    * @param result 
651    * @return the value to return to client if bypassing default processing
652    * @throws IOException if an error occurred on the coprocessor
653    */
654   boolean preCheckAndDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
655       final byte [] row, final byte [] family, final byte [] qualifier,
656       final CompareOp compareOp, final ByteArrayComparable comparator,
657       final Delete delete, final boolean result)
658     throws IOException;
659 
660   /**
661    * Called after checkAndDelete
662    * <p>
663    * Call CoprocessorEnvironment#complete to skip any subsequent chained
664    * coprocessors
665    * @param c the environment provided by the region server
666    * @param row row to check
667    * @param family column family
668    * @param qualifier column qualifier
669    * @param compareOp the comparison operation
670    * @param comparator the comparator
671    * @param delete delete to commit if check succeeds
672    * @param result from the CheckAndDelete
673    * @return the possibly transformed returned value to return to client
674    * @throws IOException if an error occurred on the coprocessor
675    */
676   boolean postCheckAndDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
677       final byte [] row, final byte [] family, final byte [] qualifier,
678       final CompareOp compareOp, final ByteArrayComparable comparator,
679       final Delete delete, final boolean result)
680     throws IOException;
681 
682   /**
683    * Called before incrementColumnValue
684    * <p>
685    * Call CoprocessorEnvironment#bypass to skip default actions
686    * <p>
687    * Call CoprocessorEnvironment#complete to skip any subsequent chained
688    * coprocessors
689    * @param c the environment provided by the region server
690    * @param row row to check
691    * @param family column family
692    * @param qualifier column qualifier
693    * @param amount long amount to increment
694    * @param writeToWAL true if the change should be written to the WAL
695    * @return value to return to the client if bypassing default processing
696    * @throws IOException if an error occurred on the coprocessor
697    * @deprecated This hook is no longer called by the RegionServer
698    */
699   @Deprecated
700   long preIncrementColumnValue(final ObserverContext<RegionCoprocessorEnvironment> c,
701       final byte [] row, final byte [] family, final byte [] qualifier,
702       final long amount, final boolean writeToWAL)
703     throws IOException;
704 
705   /**
706    * Called after incrementColumnValue
707    * <p>
708    * Call CoprocessorEnvironment#complete to skip any subsequent chained
709    * coprocessors
710    * @param c the environment provided by the region server
711    * @param row row to check
712    * @param family column family
713    * @param qualifier column qualifier
714    * @param amount long amount to increment
715    * @param writeToWAL true if the change should be written to the WAL
716    * @param result the result returned by incrementColumnValue
717    * @return the result to return to the client
718    * @throws IOException if an error occurred on the coprocessor
719    * @deprecated This hook is no longer called by the RegionServer
720    */
721   @Deprecated
722   long postIncrementColumnValue(final ObserverContext<RegionCoprocessorEnvironment> c,
723       final byte [] row, final byte [] family, final byte [] qualifier,
724       final long amount, final boolean writeToWAL, final long result)
725     throws IOException;
726 
727   /**
728    * Called before Append
729    * <p>
730    * Call CoprocessorEnvironment#bypass to skip default actions
731    * <p>
732    * Call CoprocessorEnvironment#complete to skip any subsequent chained
733    * coprocessors
734    * @param c the environment provided by the region server
735    * @param append Append object
736    * @return result to return to the client if bypassing default processing
737    * @throws IOException if an error occurred on the coprocessor
738    */
739   Result preAppend(final ObserverContext<RegionCoprocessorEnvironment> c,
740       final Append append)
741     throws IOException;
742 
743   /**
744    * Called after Append
745    * <p>
746    * Call CoprocessorEnvironment#complete to skip any subsequent chained
747    * coprocessors
748    * @param c the environment provided by the region server
749    * @param append Append object
750    * @param result the result returned by increment
751    * @return the result to return to the client
752    * @throws IOException if an error occurred on the coprocessor
753    */
754   Result postAppend(final ObserverContext<RegionCoprocessorEnvironment> c,
755       final Append append, final Result result)
756     throws IOException;
757 
758   /**
759    * Called before Increment
760    * <p>
761    * Call CoprocessorEnvironment#bypass to skip default actions
762    * <p>
763    * Call CoprocessorEnvironment#complete to skip any subsequent chained
764    * coprocessors
765    * @param c the environment provided by the region server
766    * @param increment increment object
767    * @return result to return to the client if bypassing default processing
768    * @throws IOException if an error occurred on the coprocessor
769    */
770   Result preIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
771       final Increment increment)
772     throws IOException;
773 
774   /**
775    * Called after increment
776    * <p>
777    * Call CoprocessorEnvironment#complete to skip any subsequent chained
778    * coprocessors
779    * @param c the environment provided by the region server
780    * @param increment increment object
781    * @param result the result returned by increment
782    * @return the result to return to the client
783    * @throws IOException if an error occurred on the coprocessor
784    */
785   Result postIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
786       final Increment increment, final Result result)
787     throws IOException;
788 
789   /**
790    * Called before the client opens a new scanner.
791    * <p>
792    * Call CoprocessorEnvironment#bypass to skip default actions
793    * <p>
794    * Call CoprocessorEnvironment#complete to skip any subsequent chained
795    * coprocessors
796    * @param c the environment provided by the region server
797    * @param scan the Scan specification
798    * @param s if not null, the base scanner
799    * @return an RegionScanner instance to use instead of the base scanner if
800    * overriding default behavior, null otherwise
801    * @throws IOException if an error occurred on the coprocessor
802    */
803   RegionScanner preScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
804       final Scan scan, final RegionScanner s)
805     throws IOException;
806 
807   /**
808    * Called before a store opens a new scanner.
809    * This hook is called when a "user" scanner is opened.
810    * <p>
811    * See {@link #preFlushScannerOpen(ObserverContext, Store, KeyValueScanner, InternalScanner)}
812    * and {@link #preCompactScannerOpen(ObserverContext,
813    *  Store, List, ScanType, long, InternalScanner)}
814    * to override scanners created for flushes or compactions, resp.
815    * <p>
816    * Call CoprocessorEnvironment#complete to skip any subsequent chained
817    * coprocessors.
818    * Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
819    * effect in this hook.
820    * @param c the environment provided by the region server
821    * @param store the store being scanned
822    * @param scan the Scan specification
823    * @param targetCols columns to be used in the scanner
824    * @param s the base scanner, if not {@code null}, from previous RegionObserver in the chain
825    * @return a KeyValueScanner instance to use or {@code null} to use the default implementation
826    * @throws IOException if an error occurred on the coprocessor
827    */
828   KeyValueScanner preStoreScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
829       final Store store, final Scan scan, final NavigableSet<byte[]> targetCols,
830       final KeyValueScanner s) throws IOException;
831 
832   /**
833    * Called after the client opens a new scanner.
834    * <p>
835    * Call CoprocessorEnvironment#complete to skip any subsequent chained
836    * coprocessors
837    * @param c the environment provided by the region server
838    * @param scan the Scan specification
839    * @param s if not null, the base scanner
840    * @return the scanner instance to use
841    * @throws IOException if an error occurred on the coprocessor
842    */
843   RegionScanner postScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
844       final Scan scan, final RegionScanner s)
845     throws IOException;
846 
847   /**
848    * Called before the client asks for the next row on a scanner.
849    * <p>
850    * Call CoprocessorEnvironment#bypass to skip default actions
851    * <p>
852    * Call CoprocessorEnvironment#complete to skip any subsequent chained
853    * coprocessors
854    * @param c the environment provided by the region server
855    * @param s the scanner
856    * @param result The result to return to the client if default processing
857    * is bypassed. Can be modified. Will not be returned if default processing
858    * is not bypassed.
859    * @param limit the maximum number of results to return
860    * @param hasNext the 'has more' indication
861    * @return 'has more' indication that should be sent to client
862    * @throws IOException if an error occurred on the coprocessor
863    */
864   boolean preScannerNext(final ObserverContext<RegionCoprocessorEnvironment> c,
865       final InternalScanner s, final List<Result> result,
866       final int limit, final boolean hasNext)
867     throws IOException;
868 
869   /**
870    * Called after the client asks for the next row on a scanner.
871    * <p>
872    * Call CoprocessorEnvironment#complete to skip any subsequent chained
873    * coprocessors
874    * @param c the environment provided by the region server
875    * @param s the scanner
876    * @param result the result to return to the client, can be modified
877    * @param limit the maximum number of results to return
878    * @param hasNext the 'has more' indication
879    * @return 'has more' indication that should be sent to client
880    * @throws IOException if an error occurred on the coprocessor
881    */
882   boolean postScannerNext(final ObserverContext<RegionCoprocessorEnvironment> c,
883       final InternalScanner s, final List<Result> result, final int limit,
884       final boolean hasNext)
885     throws IOException;
886 
887   /**
888    * This will be called by the scan flow when the current scanned row is being filtered out by the
889    * filter. The filter may be filtering out the row via any of the below scenarios
890    * <ol>
891    * <li>
892    * <code>boolean filterRowKey(byte [] buffer, int offset, int length)</code> returning true</li>
893    * <li>
894    * <code>boolean filterRow()</code> returning true</li>
895    * <li>
896    * <code>void filterRow(List<KeyValue> kvs)</code> removing all the kvs from the passed List</li>
897    * </ol>
898    * @param c the environment provided by the region server
899    * @param s the scanner
900    * @param currentRow The current rowkey which got filtered out
901    * @param hasMore the 'has more' indication
902    * @return whether more rows are available for the scanner or not
903    * @throws IOException
904    */
905   boolean postScannerFilterRow(final ObserverContext<RegionCoprocessorEnvironment> c,
906       final InternalScanner s, final byte[] currentRow, final boolean hasMore) throws IOException;
907   
908   /**
909    * Called before the client closes a scanner.
910    * <p>
911    * Call CoprocessorEnvironment#bypass to skip default actions
912    * <p>
913    * Call CoprocessorEnvironment#complete to skip any subsequent chained
914    * coprocessors
915    * @param c the environment provided by the region server
916    * @param s the scanner
917    * @throws IOException if an error occurred on the coprocessor
918    */
919   void preScannerClose(final ObserverContext<RegionCoprocessorEnvironment> c,
920       final InternalScanner s)
921     throws IOException;
922 
923   /**
924    * Called after the client closes a scanner.
925    * <p>
926    * Call CoprocessorEnvironment#complete to skip any subsequent chained
927    * coprocessors
928    * @param c the environment provided by the region server
929    * @param s the scanner
930    * @throws IOException if an error occurred on the coprocessor
931    */
932   void postScannerClose(final ObserverContext<RegionCoprocessorEnvironment> c,
933       final InternalScanner s)
934     throws IOException;
935 
936   /**
937    * Called before a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit}
938    * replayed for this region.
939    *
940    * @param ctx
941    * @param info
942    * @param logKey
943    * @param logEdit
944    * @throws IOException
945    */
946   void preWALRestore(final ObserverContext<RegionCoprocessorEnvironment> ctx,
947       HRegionInfo info, HLogKey logKey, WALEdit logEdit) throws IOException;
948 
949   /**
950    * Called after a {@link org.apache.hadoop.hbase.regionserver.wal.WALEdit}
951    * replayed for this region.
952    *
953    * @param ctx
954    * @param info
955    * @param logKey
956    * @param logEdit
957    * @throws IOException
958    */
959   void postWALRestore(final ObserverContext<RegionCoprocessorEnvironment> ctx,
960       HRegionInfo info, HLogKey logKey, WALEdit logEdit) throws IOException;
961 
962   /**
963    * Called before bulkLoadHFile. Users can create a StoreFile instance to
964    * access the contents of a HFile.
965    *
966    * @param ctx
967    * @param familyPaths pairs of { CF, HFile path } submitted for bulk load. Adding
968    * or removing from this list will add or remove HFiles to be bulk loaded.
969    * @throws IOException
970    */
971   void preBulkLoadHFile(final ObserverContext<RegionCoprocessorEnvironment> ctx,
972     List<Pair<byte[], String>> familyPaths) throws IOException;
973 
974   /**
975    * Called after bulkLoadHFile.
976    *
977    * @param ctx
978    * @param familyPaths pairs of { CF, HFile path } submitted for bulk load
979    * @param hasLoaded whether the bulkLoad was successful
980    * @return the new value of hasLoaded
981    * @throws IOException
982    */
983   boolean postBulkLoadHFile(final ObserverContext<RegionCoprocessorEnvironment> ctx,
984     List<Pair<byte[], String>> familyPaths, boolean hasLoaded) throws IOException;
985 }