View Javadoc

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