1 /* 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 package org.apache.hadoop.hbase.coprocessor; 21 22 import java.io.IOException; 23 import java.util.List; 24 25 import org.apache.hadoop.hbase.classification.InterfaceAudience; 26 import org.apache.hadoop.hbase.classification.InterfaceStability; 27 import org.apache.hadoop.hbase.Coprocessor; 28 import org.apache.hadoop.hbase.HBaseInterfaceAudience; 29 import org.apache.hadoop.hbase.ProcedureInfo; 30 import org.apache.hadoop.hbase.TableName; 31 import org.apache.hadoop.hbase.HColumnDescriptor; 32 import org.apache.hadoop.hbase.HRegionInfo; 33 import org.apache.hadoop.hbase.HTableDescriptor; 34 import org.apache.hadoop.hbase.NamespaceDescriptor; 35 import org.apache.hadoop.hbase.ServerName; 36 import org.apache.hadoop.hbase.master.RegionPlan; 37 import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv; 38 import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; 39 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription; 40 import org.apache.hadoop.hbase.protobuf.generated.QuotaProtos.Quotas; 41 42 /** 43 * Defines coprocessor hooks for interacting with operations on the 44 * {@link org.apache.hadoop.hbase.master.HMaster} process. 45 */ 46 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC) 47 @InterfaceStability.Evolving 48 public interface MasterObserver extends Coprocessor { 49 50 /** 51 * Called before a new table is created by 52 * {@link org.apache.hadoop.hbase.master.HMaster}. Called as part of create 53 * table RPC call. 54 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 55 * @param ctx the environment to interact with the framework and master 56 * @param desc the HTableDescriptor for the table 57 * @param regions the initial regions created for the table 58 * @throws IOException 59 */ 60 void preCreateTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, 61 HTableDescriptor desc, HRegionInfo[] regions) throws IOException; 62 63 /** 64 * Called after the createTable operation has been requested. Called as part 65 * of create table RPC call. 66 * @param ctx the environment to interact with the framework and master 67 * @param desc the HTableDescriptor for the table 68 * @param regions the initial regions created for the table 69 * @throws IOException 70 */ 71 void postCreateTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, 72 HTableDescriptor desc, HRegionInfo[] regions) throws IOException; 73 /** 74 * Called before a new table is created by 75 * {@link org.apache.hadoop.hbase.master.HMaster}. Called as part of create 76 * table handler and it is async to the create RPC call. 77 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 78 * @param ctx the environment to interact with the framework and master 79 * @param desc the HTableDescriptor for the table 80 * @param regions the initial regions created for the table 81 * @throws IOException 82 */ 83 void preCreateTableHandler(final ObserverContext<MasterCoprocessorEnvironment> 84 ctx, HTableDescriptor desc, HRegionInfo[] regions) throws IOException; 85 86 /** 87 * Called after the createTable operation has been requested. Called as part 88 * of create table RPC call. Called as part of create table handler and 89 * it is async to the create RPC call. 90 * @param ctx the environment to interact with the framework and master 91 * @param desc the HTableDescriptor for the table 92 * @param regions the initial regions created for the table 93 * @throws IOException 94 */ 95 void postCreateTableHandler(final ObserverContext<MasterCoprocessorEnvironment> 96 ctx, HTableDescriptor desc, HRegionInfo[] regions) throws IOException; 97 98 /** 99 * Called before {@link org.apache.hadoop.hbase.master.HMaster} deletes a 100 * table. Called as part of delete table RPC call. 101 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 102 * @param ctx the environment to interact with the framework and master 103 * @param tableName the name of the table 104 */ 105 void preDeleteTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, 106 TableName tableName) throws IOException; 107 108 /** 109 * Called after the deleteTable operation has been requested. Called as part 110 * of delete table RPC call. 111 * @param ctx the environment to interact with the framework and master 112 * @param tableName the name of the table 113 */ 114 void postDeleteTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, 115 TableName tableName) throws IOException; 116 117 /** 118 * Called before {@link org.apache.hadoop.hbase.master.HMaster} deletes a 119 * table. Called as part of delete table handler and 120 * it is async to the delete RPC call. 121 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 122 * @param ctx the environment to interact with the framework and master 123 * @param tableName the name of the table 124 */ 125 void preDeleteTableHandler( 126 final ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName) 127 throws IOException; 128 129 /** 130 * Called after {@link org.apache.hadoop.hbase.master.HMaster} deletes a 131 * table. Called as part of delete table handler and it is async to the 132 * delete RPC call. 133 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 134 * @param ctx the environment to interact with the framework and master 135 * @param tableName the name of the table 136 */ 137 void postDeleteTableHandler( 138 final ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName) 139 throws IOException; 140 141 142 /** 143 * Called before {@link org.apache.hadoop.hbase.master.HMaster} truncates a 144 * table. Called as part of truncate table RPC call. 145 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 146 * @param ctx the environment to interact with the framework and master 147 * @param tableName the name of the table 148 */ 149 void preTruncateTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, 150 TableName tableName) throws IOException; 151 152 /** 153 * Called after the truncateTable operation has been requested. Called as part 154 * of truncate table RPC call. 155 * The truncate is synchronous, so this method will be called when the 156 * truncate operation is terminated. 157 * @param ctx the environment to interact with the framework and master 158 * @param tableName the name of the table 159 */ 160 void postTruncateTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, 161 TableName tableName) throws IOException; 162 163 /** 164 * Called before {@link org.apache.hadoop.hbase.master.HMaster} truncates a 165 * table. Called as part of truncate table handler and it is sync 166 * to the truncate RPC call. 167 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 168 * @param ctx the environment to interact with the framework and master 169 * @param tableName the name of the table 170 */ 171 void preTruncateTableHandler( 172 final ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName) 173 throws IOException; 174 175 /** 176 * Called after {@link org.apache.hadoop.hbase.master.HMaster} truncates a 177 * table. Called as part of truncate table handler and it is sync to the 178 * truncate RPC call. 179 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 180 * @param ctx the environment to interact with the framework and master 181 * @param tableName the name of the table 182 */ 183 void postTruncateTableHandler( 184 final ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName) 185 throws IOException; 186 187 /** 188 * Called prior to modifying a table's properties. Called as part of modify 189 * table RPC call. 190 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 191 * @param ctx the environment to interact with the framework and master 192 * @param tableName the name of the table 193 * @param htd the HTableDescriptor 194 */ 195 void preModifyTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, 196 final TableName tableName, HTableDescriptor htd) throws IOException; 197 198 /** 199 * Called after the modifyTable operation has been requested. Called as part 200 * of modify table RPC call. 201 * @param ctx the environment to interact with the framework and master 202 * @param tableName the name of the table 203 * @param htd the HTableDescriptor 204 */ 205 void postModifyTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, 206 final TableName tableName, HTableDescriptor htd) throws IOException; 207 208 /** 209 * Called prior to modifying a table's properties. Called as part of modify 210 * table handler and it is async to the modify table RPC call. 211 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 212 * @param ctx the environment to interact with the framework and master 213 * @param tableName the name of the table 214 * @param htd the HTableDescriptor 215 */ 216 void preModifyTableHandler( 217 final ObserverContext<MasterCoprocessorEnvironment> ctx, 218 final TableName tableName, HTableDescriptor htd) throws IOException; 219 220 /** 221 * Called after to modifying a table's properties. Called as part of modify 222 * table handler and it is async to the modify table RPC call. 223 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 224 * @param ctx the environment to interact with the framework and master 225 * @param tableName the name of the table 226 * @param htd the HTableDescriptor 227 */ 228 void postModifyTableHandler( 229 final ObserverContext<MasterCoprocessorEnvironment> ctx, 230 final TableName tableName, HTableDescriptor htd) throws IOException; 231 232 /** 233 * Called prior to adding a new column family to the table. Called as part of 234 * add column RPC call. 235 * @param ctx the environment to interact with the framework and master 236 * @param tableName the name of the table 237 * @param column the HColumnDescriptor 238 */ 239 void preAddColumn(final ObserverContext<MasterCoprocessorEnvironment> ctx, 240 TableName tableName, HColumnDescriptor column) throws IOException; 241 242 /** 243 * Called after the new column family has been created. Called as part of 244 * add column RPC call. 245 * @param ctx the environment to interact with the framework and master 246 * @param tableName the name of the table 247 * @param column the HColumnDescriptor 248 */ 249 void postAddColumn(final ObserverContext<MasterCoprocessorEnvironment> ctx, 250 TableName tableName, HColumnDescriptor column) throws IOException; 251 252 /** 253 * Called prior to adding a new column family to the table. Called as part of 254 * add column handler. 255 * @param ctx the environment to interact with the framework and master 256 * @param tableName the name of the table 257 * @param column the HColumnDescriptor 258 */ 259 void preAddColumnHandler( 260 final ObserverContext<MasterCoprocessorEnvironment> ctx, 261 TableName tableName, HColumnDescriptor column) throws IOException; 262 263 /** 264 * Called after the new column family has been created. Called as part of 265 * add column handler. 266 * @param ctx the environment to interact with the framework and master 267 * @param tableName the name of the table 268 * @param column the HColumnDescriptor 269 */ 270 void postAddColumnHandler( 271 final ObserverContext<MasterCoprocessorEnvironment> ctx, 272 TableName tableName, HColumnDescriptor column) throws IOException; 273 274 /** 275 * Called prior to modifying a column family's attributes. Called as part of 276 * modify column RPC call. 277 * @param ctx the environment to interact with the framework and master 278 * @param tableName the name of the table 279 * @param descriptor the HColumnDescriptor 280 */ 281 void preModifyColumn(final ObserverContext<MasterCoprocessorEnvironment> ctx, 282 TableName tableName, HColumnDescriptor descriptor) throws IOException; 283 284 /** 285 * Called after the column family has been updated. Called as part of modify 286 * column RPC call. 287 * @param ctx the environment to interact with the framework and master 288 * @param tableName the name of the table 289 * @param descriptor the HColumnDescriptor 290 */ 291 void postModifyColumn(final ObserverContext<MasterCoprocessorEnvironment> ctx, 292 TableName tableName, HColumnDescriptor descriptor) throws IOException; 293 294 /** 295 * Called prior to modifying a column family's attributes. Called as part of 296 * modify column handler. 297 * @param ctx the environment to interact with the framework and master 298 * @param tableName the name of the table 299 * @param descriptor the HColumnDescriptor 300 */ 301 void preModifyColumnHandler( 302 final ObserverContext<MasterCoprocessorEnvironment> ctx, 303 TableName tableName, HColumnDescriptor descriptor) throws IOException; 304 305 /** 306 * Called after the column family has been updated. Called as part of modify 307 * column handler. 308 * @param ctx the environment to interact with the framework and master 309 * @param tableName the name of the table 310 * @param descriptor the HColumnDescriptor 311 */ 312 void postModifyColumnHandler( 313 final ObserverContext<MasterCoprocessorEnvironment> ctx, 314 TableName tableName, HColumnDescriptor descriptor) throws IOException; 315 316 317 /** 318 * Called prior to deleting the entire column family. Called as part of 319 * delete column RPC call. 320 * @param ctx the environment to interact with the framework and master 321 * @param tableName the name of the table 322 * @param c the column 323 */ 324 void preDeleteColumn(final ObserverContext<MasterCoprocessorEnvironment> ctx, 325 final TableName tableName, final byte[] c) throws IOException; 326 327 /** 328 * Called after the column family has been deleted. Called as part of delete 329 * column RPC call. 330 * @param ctx the environment to interact with the framework and master 331 * @param tableName the name of the table 332 * @param c the column 333 */ 334 void postDeleteColumn(final ObserverContext<MasterCoprocessorEnvironment> ctx, 335 final TableName tableName, final byte[] c) throws IOException; 336 337 /** 338 * Called prior to deleting the entire column family. Called as part of 339 * delete column handler. 340 * @param ctx the environment to interact with the framework and master 341 * @param tableName the name of the table 342 * @param c the column 343 */ 344 void preDeleteColumnHandler( 345 final ObserverContext<MasterCoprocessorEnvironment> ctx, 346 final TableName tableName, final byte[] c) throws IOException; 347 348 /** 349 * Called after the column family has been deleted. Called as part of 350 * delete column handler. 351 * @param ctx the environment to interact with the framework and master 352 * @param tableName the name of the table 353 * @param c the column 354 */ 355 void postDeleteColumnHandler( 356 final ObserverContext<MasterCoprocessorEnvironment> ctx, 357 final TableName tableName, final byte[] c) throws IOException; 358 359 /** 360 * Called prior to enabling a table. Called as part of enable table RPC call. 361 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 362 * @param ctx the environment to interact with the framework and master 363 * @param tableName the name of the table 364 */ 365 void preEnableTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, 366 final TableName tableName) throws IOException; 367 368 /** 369 * Called after the enableTable operation has been requested. Called as part 370 * of enable table RPC call. 371 * @param ctx the environment to interact with the framework and master 372 * @param tableName the name of the table 373 */ 374 void postEnableTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, 375 final TableName tableName) throws IOException; 376 377 /** 378 * Called prior to enabling a table. Called as part of enable table handler 379 * and it is async to the enable table RPC call. 380 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 381 * @param ctx the environment to interact with the framework and master 382 * @param tableName the name of the table 383 */ 384 void preEnableTableHandler( 385 final ObserverContext<MasterCoprocessorEnvironment> ctx, 386 final TableName tableName) throws IOException; 387 388 /** 389 * Called after the enableTable operation has been requested. Called as part 390 * of enable table handler and it is async to the enable table RPC call. 391 * @param ctx the environment to interact with the framework and master 392 * @param tableName the name of the table 393 */ 394 void postEnableTableHandler( 395 final ObserverContext<MasterCoprocessorEnvironment> ctx, 396 final TableName tableName) throws IOException; 397 398 /** 399 * Called prior to disabling a table. Called as part of disable table RPC 400 * call. 401 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 402 * @param ctx the environment to interact with the framework and master 403 * @param tableName the name of the table 404 */ 405 void preDisableTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, 406 final TableName tableName) throws IOException; 407 408 /** 409 * Called after the disableTable operation has been requested. Called as part 410 * of disable table RPC call. 411 * @param ctx the environment to interact with the framework and master 412 * @param tableName the name of the table 413 */ 414 void postDisableTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, 415 final TableName tableName) throws IOException; 416 417 /** 418 * Called prior to disabling a table. Called as part of disable table handler 419 * and it is asyn to the disable table RPC call. 420 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 421 * @param ctx the environment to interact with the framework and master 422 * @param tableName the name of the table 423 */ 424 void preDisableTableHandler( 425 final ObserverContext<MasterCoprocessorEnvironment> ctx, 426 final TableName tableName) throws IOException; 427 428 /** 429 * Called after the disableTable operation has been requested. Called as part 430 * of disable table handler and it is asyn to the disable table RPC call. 431 * @param ctx the environment to interact with the framework and master 432 * @param tableName the name of the table 433 */ 434 void postDisableTableHandler( 435 final ObserverContext<MasterCoprocessorEnvironment> ctx, 436 final TableName tableName) throws IOException; 437 438 /** 439 * Called prior to moving a given region from one region server to another. 440 * @param ctx the environment to interact with the framework and master 441 * @param region the HRegionInfo 442 * @param srcServer the source ServerName 443 * @param destServer the destination ServerName 444 */ 445 void preMove(final ObserverContext<MasterCoprocessorEnvironment> ctx, 446 final HRegionInfo region, final ServerName srcServer, 447 final ServerName destServer) 448 throws IOException; 449 450 /** 451 * Called after the region move has been requested. 452 * @param ctx the environment to interact with the framework and master 453 * @param region the HRegionInfo 454 * @param srcServer the source ServerName 455 * @param destServer the destination ServerName 456 */ 457 void postMove(final ObserverContext<MasterCoprocessorEnvironment> ctx, 458 final HRegionInfo region, final ServerName srcServer, 459 final ServerName destServer) 460 throws IOException; 461 462 /** 463 * Called before a abortProcedure request has been processed. 464 * @param ctx the environment to interact with the framework and master 465 * @throws IOException 466 */ 467 void preAbortProcedure( 468 ObserverContext<MasterCoprocessorEnvironment> ctx, 469 final ProcedureExecutor<MasterProcedureEnv> procEnv, 470 final long procId) throws IOException; 471 472 /** 473 * Called after a abortProcedure request has been processed. 474 * @param ctx the environment to interact with the framework and master 475 */ 476 void postAbortProcedure(ObserverContext<MasterCoprocessorEnvironment> ctx) 477 throws IOException; 478 479 /** 480 * Called before a listProcedures request has been processed. 481 * @param ctx the environment to interact with the framework and master 482 * @throws IOException 483 */ 484 void preListProcedures(ObserverContext<MasterCoprocessorEnvironment> ctx) 485 throws IOException; 486 487 /** 488 * Called after a listProcedures request has been processed. 489 * @param ctx the environment to interact with the framework and master 490 * @param procInfoList the list of procedures about to be returned 491 */ 492 void postListProcedures( 493 ObserverContext<MasterCoprocessorEnvironment> ctx, 494 List<ProcedureInfo> procInfoList) throws IOException; 495 496 /** 497 * Called prior to assigning a specific region. 498 * @param ctx the environment to interact with the framework and master 499 * @param regionInfo the regionInfo of the region 500 */ 501 void preAssign(final ObserverContext<MasterCoprocessorEnvironment> ctx, 502 final HRegionInfo regionInfo) throws IOException; 503 504 /** 505 * Called after the region assignment has been requested. 506 * @param ctx the environment to interact with the framework and master 507 * @param regionInfo the regionInfo of the region 508 */ 509 void postAssign(final ObserverContext<MasterCoprocessorEnvironment> ctx, 510 final HRegionInfo regionInfo) throws IOException; 511 512 /** 513 * Called prior to unassigning a given region. 514 * @param ctx the environment to interact with the framework and master 515 * @param regionInfo 516 * @param force whether to force unassignment or not 517 */ 518 void preUnassign(final ObserverContext<MasterCoprocessorEnvironment> ctx, 519 final HRegionInfo regionInfo, final boolean force) throws IOException; 520 521 /** 522 * Called after the region unassignment has been requested. 523 * @param ctx the environment to interact with the framework and master 524 * @param regionInfo 525 * @param force whether to force unassignment or not 526 */ 527 void postUnassign(final ObserverContext<MasterCoprocessorEnvironment> ctx, 528 final HRegionInfo regionInfo, final boolean force) throws IOException; 529 530 /** 531 * Called prior to marking a given region as offline. <code>ctx.bypass()</code> will not have any 532 * impact on this hook. 533 * @param ctx the environment to interact with the framework and master 534 * @param regionInfo 535 */ 536 void preRegionOffline(final ObserverContext<MasterCoprocessorEnvironment> ctx, 537 final HRegionInfo regionInfo) throws IOException; 538 539 /** 540 * Called after the region has been marked offline. 541 * @param ctx the environment to interact with the framework and master 542 * @param regionInfo 543 */ 544 void postRegionOffline(final ObserverContext<MasterCoprocessorEnvironment> ctx, 545 final HRegionInfo regionInfo) throws IOException; 546 547 /** 548 * Called prior to requesting rebalancing of the cluster regions, though after 549 * the initial checks for regions in transition and the balance switch flag. 550 * @param ctx the environment to interact with the framework and master 551 */ 552 void preBalance(final ObserverContext<MasterCoprocessorEnvironment> ctx) 553 throws IOException; 554 555 /** 556 * Called after the balancing plan has been submitted. 557 * @param ctx the environment to interact with the framework and master 558 * @param plans the RegionPlans which master has executed. RegionPlan serves as hint 559 * as for the final destination for the underlying region but may not represent the 560 * final state of assignment 561 */ 562 void postBalance(final ObserverContext<MasterCoprocessorEnvironment> ctx, List<RegionPlan> plans) 563 throws IOException; 564 565 /** 566 * Called prior to modifying the flag used to enable/disable region balancing. 567 * @param ctx the coprocessor instance's environment 568 * @param newValue the new flag value submitted in the call 569 */ 570 boolean preBalanceSwitch(final ObserverContext<MasterCoprocessorEnvironment> ctx, 571 final boolean newValue) throws IOException; 572 573 /** 574 * Called after the flag to enable/disable balancing has changed. 575 * @param ctx the coprocessor instance's environment 576 * @param oldValue the previously set balanceSwitch value 577 * @param newValue the newly set balanceSwitch value 578 */ 579 void postBalanceSwitch(final ObserverContext<MasterCoprocessorEnvironment> ctx, 580 final boolean oldValue, final boolean newValue) throws IOException; 581 582 /** 583 * Called prior to shutting down the full HBase cluster, including this 584 * {@link org.apache.hadoop.hbase.master.HMaster} process. 585 */ 586 void preShutdown(final ObserverContext<MasterCoprocessorEnvironment> ctx) 587 throws IOException; 588 589 590 /** 591 * Called immediately prior to stopping this 592 * {@link org.apache.hadoop.hbase.master.HMaster} process. 593 */ 594 void preStopMaster(final ObserverContext<MasterCoprocessorEnvironment> ctx) 595 throws IOException; 596 597 /** 598 * Called immediately after an active master instance has completed 599 * initialization. Will not be called on standby master instances unless 600 * they take over the active role. 601 */ 602 void postStartMaster(final ObserverContext<MasterCoprocessorEnvironment> ctx) 603 throws IOException; 604 605 /** 606 * Call before the master initialization is set to true. 607 * {@link org.apache.hadoop.hbase.master.HMaster} process. 608 */ 609 void preMasterInitialization(final ObserverContext<MasterCoprocessorEnvironment> ctx) 610 throws IOException; 611 612 /** 613 * Called before a new snapshot is taken. 614 * Called as part of snapshot RPC call. 615 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 616 * @param ctx the environment to interact with the framework and master 617 * @param snapshot the SnapshotDescriptor for the snapshot 618 * @param hTableDescriptor the hTableDescriptor of the table to snapshot 619 * @throws IOException 620 */ 621 void preSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx, 622 final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor) 623 throws IOException; 624 625 /** 626 * Called after the snapshot operation has been requested. 627 * Called as part of snapshot RPC call. 628 * @param ctx the environment to interact with the framework and master 629 * @param snapshot the SnapshotDescriptor for the snapshot 630 * @param hTableDescriptor the hTableDescriptor of the table to snapshot 631 * @throws IOException 632 */ 633 void postSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx, 634 final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor) 635 throws IOException; 636 637 /** 638 * Called before listSnapshots request has been processed. 639 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 640 * @param ctx the environment to interact with the framework and master 641 * @param snapshot the SnapshotDescriptor of the snapshot to list 642 * @throws IOException 643 */ 644 void preListSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx, 645 final SnapshotDescription snapshot) throws IOException; 646 647 /** 648 * Called after listSnapshots request has been processed. 649 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 650 * @param ctx the environment to interact with the framework and master 651 * @param snapshot the SnapshotDescriptor of the snapshot to list 652 * @throws IOException 653 */ 654 void postListSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx, 655 final SnapshotDescription snapshot) throws IOException; 656 657 /** 658 * Called before a snapshot is cloned. 659 * Called as part of restoreSnapshot RPC call. 660 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 661 * @param ctx the environment to interact with the framework and master 662 * @param snapshot the SnapshotDescriptor for the snapshot 663 * @param hTableDescriptor the hTableDescriptor of the table to create 664 * @throws IOException 665 */ 666 void preCloneSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx, 667 final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor) 668 throws IOException; 669 670 /** 671 * Called after a snapshot clone operation has been requested. 672 * Called as part of restoreSnapshot RPC call. 673 * @param ctx the environment to interact with the framework and master 674 * @param snapshot the SnapshotDescriptor for the snapshot 675 * @param hTableDescriptor the hTableDescriptor of the table to create 676 * @throws IOException 677 */ 678 void postCloneSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx, 679 final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor) 680 throws IOException; 681 682 /** 683 * Called before a snapshot is restored. 684 * Called as part of restoreSnapshot RPC call. 685 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 686 * @param ctx the environment to interact with the framework and master 687 * @param snapshot the SnapshotDescriptor for the snapshot 688 * @param hTableDescriptor the hTableDescriptor of the table to restore 689 * @throws IOException 690 */ 691 void preRestoreSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx, 692 final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor) 693 throws IOException; 694 695 /** 696 * Called after a snapshot restore operation has been requested. 697 * Called as part of restoreSnapshot RPC call. 698 * @param ctx the environment to interact with the framework and master 699 * @param snapshot the SnapshotDescriptor for the snapshot 700 * @param hTableDescriptor the hTableDescriptor of the table to restore 701 * @throws IOException 702 */ 703 void postRestoreSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx, 704 final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor) 705 throws IOException; 706 707 /** 708 * Called before a snapshot is deleted. 709 * Called as part of deleteSnapshot RPC call. 710 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 711 * @param ctx the environment to interact with the framework and master 712 * @param snapshot the SnapshotDescriptor of the snapshot to delete 713 * @throws IOException 714 */ 715 void preDeleteSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx, 716 final SnapshotDescription snapshot) throws IOException; 717 718 /** 719 * Called after the delete snapshot operation has been requested. 720 * Called as part of deleteSnapshot RPC call. 721 * @param ctx the environment to interact with the framework and master 722 * @param snapshot the SnapshotDescriptor of the snapshot to delete 723 * @throws IOException 724 */ 725 void postDeleteSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx, 726 final SnapshotDescription snapshot) throws IOException; 727 728 /** 729 * Called before a getTableDescriptors request has been processed. 730 * @param ctx the environment to interact with the framework and master 731 * @param tableNamesList the list of table names, or null if querying for all 732 * @param descriptors an empty list, can be filled with what to return if bypassing 733 * @throws IOException 734 * @deprecated Use preGetTableDescriptors with regex instead. 735 */ 736 @Deprecated 737 void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, 738 List<TableName> tableNamesList, List<HTableDescriptor> descriptors) throws IOException; 739 740 /** 741 * Called after a getTableDescriptors request has been processed. 742 * @param ctx the environment to interact with the framework and master 743 * @param descriptors the list of descriptors about to be returned 744 * @throws IOException 745 * @deprecated Use postGetTableDescriptors with regex instead. 746 */ 747 @Deprecated 748 void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, 749 List<HTableDescriptor> descriptors) throws IOException; 750 751 /** 752 * Called before a getTableDescriptors request has been processed. 753 * @param ctx the environment to interact with the framework and master 754 * @param tableNamesList the list of table names, or null if querying for all 755 * @param descriptors an empty list, can be filled with what to return if bypassing 756 * @param regex regular expression used for filtering the table names 757 * @throws IOException 758 */ 759 void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, 760 List<TableName> tableNamesList, List<HTableDescriptor> descriptors, 761 String regex) throws IOException; 762 763 /** 764 * Called after a getTableDescriptors request has been processed. 765 * @param ctx the environment to interact with the framework and master 766 * @param tableNamesList the list of table names, or null if querying for all 767 * @param descriptors the list of descriptors about to be returned 768 * @param regex regular expression used for filtering the table names 769 * @throws IOException 770 */ 771 void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, 772 List<TableName> tableNamesList, List<HTableDescriptor> descriptors, 773 String regex) throws IOException; 774 775 /** 776 * Called before a getTableNames request has been processed. 777 * @param ctx the environment to interact with the framework and master 778 * @param descriptors an empty list, can be filled with what to return if bypassing 779 * @param regex regular expression used for filtering the table names 780 * @throws IOException 781 */ 782 void preGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx, 783 List<HTableDescriptor> descriptors, String regex) throws IOException; 784 785 /** 786 * Called after a getTableNames request has been processed. 787 * @param ctx the environment to interact with the framework and master 788 * @param descriptors the list of descriptors about to be returned 789 * @param regex regular expression used for filtering the table names 790 * @throws IOException 791 */ 792 void postGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx, 793 List<HTableDescriptor> descriptors, String regex) throws IOException; 794 795 /** 796 * Called before a new namespace is created by 797 * {@link org.apache.hadoop.hbase.master.HMaster}. 798 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 799 * @param ctx the environment to interact with the framework and master 800 * @param ns the NamespaceDescriptor for the table 801 * @throws IOException 802 */ 803 void preCreateNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx, 804 NamespaceDescriptor ns) throws IOException; 805 /** 806 * Called after the createNamespace operation has been requested. 807 * @param ctx the environment to interact with the framework and master 808 * @param ns the NamespaceDescriptor for the table 809 * @throws IOException 810 */ 811 void postCreateNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx, 812 NamespaceDescriptor ns) throws IOException; 813 814 /** 815 * Called before {@link org.apache.hadoop.hbase.master.HMaster} deletes a 816 * namespace 817 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 818 * @param ctx the environment to interact with the framework and master 819 * @param namespace the name of the namespace 820 */ 821 void preDeleteNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx, 822 String namespace) throws IOException; 823 824 /** 825 * Called after the deleteNamespace operation has been requested. 826 * @param ctx the environment to interact with the framework and master 827 * @param namespace the name of the namespace 828 */ 829 void postDeleteNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx, 830 String namespace) throws IOException; 831 832 /** 833 * Called prior to modifying a namespace's properties. 834 * It can't bypass the default action, e.g., ctx.bypass() won't have effect. 835 * @param ctx the environment to interact with the framework and master 836 * @param ns the NamespaceDescriptor 837 */ 838 void preModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx, 839 NamespaceDescriptor ns) throws IOException; 840 841 /** 842 * Called after the modifyNamespace operation has been requested. 843 * @param ctx the environment to interact with the framework and master 844 * @param ns the NamespaceDescriptor 845 */ 846 void postModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx, 847 NamespaceDescriptor ns) throws IOException; 848 849 /** 850 * Called before a getNamespaceDescriptor request has been processed. 851 * @param ctx the environment to interact with the framework and master 852 * @param namespace the name of the namespace 853 * @throws IOException 854 */ 855 void preGetNamespaceDescriptor(ObserverContext<MasterCoprocessorEnvironment> ctx, 856 String namespace) throws IOException; 857 858 /** 859 * Called after a getNamespaceDescriptor request has been processed. 860 * @param ctx the environment to interact with the framework and master 861 * @param ns the NamespaceDescriptor 862 * @throws IOException 863 */ 864 void postGetNamespaceDescriptor(ObserverContext<MasterCoprocessorEnvironment> ctx, 865 NamespaceDescriptor ns) throws IOException; 866 867 /** 868 * Called before a listNamespaceDescriptors request has been processed. 869 * @param ctx the environment to interact with the framework and master 870 * @param descriptors an empty list, can be filled with what to return if bypassing 871 * @throws IOException 872 */ 873 void preListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, 874 List<NamespaceDescriptor> descriptors) throws IOException; 875 876 /** 877 * Called after a listNamespaceDescriptors request has been processed. 878 * @param ctx the environment to interact with the framework and master 879 * @param descriptors the list of descriptors about to be returned 880 * @throws IOException 881 */ 882 void postListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, 883 List<NamespaceDescriptor> descriptors) throws IOException; 884 885 886 /** 887 * Called before the table memstore is flushed to disk. 888 * @param ctx the environment to interact with the framework and master 889 * @param tableName the name of the table 890 * @throws IOException 891 */ 892 void preTableFlush(final ObserverContext<MasterCoprocessorEnvironment> ctx, 893 final TableName tableName) throws IOException; 894 895 /** 896 * Called after the table memstore is flushed to disk. 897 * @param ctx the environment to interact with the framework and master 898 * @param tableName the name of the table 899 * @throws IOException 900 */ 901 void postTableFlush(final ObserverContext<MasterCoprocessorEnvironment> ctx, 902 final TableName tableName) throws IOException; 903 904 /** 905 * Called before the quota for the user is stored. 906 * @param ctx the environment to interact with the framework and master 907 * @param userName the name of user 908 * @param quotas the quota settings 909 * @throws IOException 910 */ 911 void preSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx, 912 final String userName, final Quotas quotas) throws IOException; 913 914 /** 915 * Called after the quota for the user is stored. 916 * @param ctx the environment to interact with the framework and master 917 * @param userName the name of user 918 * @param quotas the quota settings 919 * @throws IOException 920 */ 921 void postSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx, 922 final String userName, final Quotas quotas) throws IOException; 923 924 /** 925 * Called before the quota for the user on the specified table is stored. 926 * @param ctx the environment to interact with the framework and master 927 * @param userName the name of user 928 * @param tableName the name of the table 929 * @param quotas the quota settings 930 * @throws IOException 931 */ 932 void preSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx, 933 final String userName, final TableName tableName, final Quotas quotas) throws IOException; 934 935 /** 936 * Called after the quota for the user on the specified table is stored. 937 * @param ctx the environment to interact with the framework and master 938 * @param userName the name of user 939 * @param tableName the name of the table 940 * @param quotas the quota settings 941 * @throws IOException 942 */ 943 void postSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx, 944 final String userName, final TableName tableName, final Quotas quotas) throws IOException; 945 946 /** 947 * Called before the quota for the user on the specified namespace is stored. 948 * @param ctx the environment to interact with the framework and master 949 * @param userName the name of user 950 * @param namespace the name of the namespace 951 * @param quotas the quota settings 952 * @throws IOException 953 */ 954 void preSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx, 955 final String userName, final String namespace, final Quotas quotas) throws IOException; 956 957 /** 958 * Called after the quota for the user on the specified namespace is stored. 959 * @param ctx the environment to interact with the framework and master 960 * @param userName the name of user 961 * @param namespace the name of the namespace 962 * @param quotas the quota settings 963 * @throws IOException 964 */ 965 void postSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx, 966 final String userName, final String namespace, final Quotas quotas) throws IOException; 967 968 /** 969 * Called before the quota for the table is stored. 970 * @param ctx the environment to interact with the framework and master 971 * @param tableName the name of the table 972 * @param quotas the quota settings 973 * @throws IOException 974 */ 975 void preSetTableQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx, 976 final TableName tableName, final Quotas quotas) throws IOException; 977 978 /** 979 * Called after the quota for the table is stored. 980 * @param ctx the environment to interact with the framework and master 981 * @param tableName the name of the table 982 * @param quotas the quota settings 983 * @throws IOException 984 */ 985 void postSetTableQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx, 986 final TableName tableName, final Quotas quotas) throws IOException; 987 988 /** 989 * Called before the quota for the namespace is stored. 990 * @param ctx the environment to interact with the framework and master 991 * @param namespace the name of the namespace 992 * @param quotas the quota settings 993 * @throws IOException 994 */ 995 void preSetNamespaceQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx, 996 final String namespace, final Quotas quotas) throws IOException; 997 998 /** 999 * Called after the quota for the namespace is stored. 1000 * @param ctx the environment to interact with the framework and master 1001 * @param namespace the name of the namespace 1002 * @param quotas the quota settings 1003 * @throws IOException 1004 */ 1005 void postSetNamespaceQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx, 1006 final String namespace, final Quotas quotas) throws IOException; 1007 }