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