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