View Javadoc

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.Coprocessor;
26  import org.apache.hadoop.hbase.HBaseInterfaceAudience;
27  import org.apache.hadoop.hbase.HColumnDescriptor;
28  import org.apache.hadoop.hbase.HRegionInfo;
29  import org.apache.hadoop.hbase.HTableDescriptor;
30  import org.apache.hadoop.hbase.NamespaceDescriptor;
31  import org.apache.hadoop.hbase.ServerName;
32  import org.apache.hadoop.hbase.TableName;
33  import org.apache.hadoop.hbase.classification.InterfaceAudience;
34  import org.apache.hadoop.hbase.classification.InterfaceStability;
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    * @param regex regular expression used for filtering the table names
697    * @throws IOException
698    */
699   void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
700       List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
701       String regex) 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 tableNamesList the list of table names, or null if querying for all
707    * @param descriptors the list of descriptors about to be returned
708    * @param regex regular expression used for filtering the table names
709    * @throws IOException
710    */
711   void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
712       List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
713       String regex) throws IOException;
714 
715   /**
716    * Called before a getTableNames request has been processed.
717    * @param ctx the environment to interact with the framework and master
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 preGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
723       List<HTableDescriptor> descriptors, String regex) throws IOException;
724 
725   /**
726    * Called after a getTableNames request has been processed.
727    * @param ctx the environment to interact with the framework and master
728    * @param descriptors the list of descriptors about to be returned
729    * @param regex regular expression used for filtering the table names
730    * @throws IOException
731    */
732   void postGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
733       List<HTableDescriptor> descriptors, String regex) throws IOException;
734 
735 
736 
737   /**
738    * Called before a new namespace is created by
739    * {@link org.apache.hadoop.hbase.master.HMaster}.
740    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
741    * @param ctx the environment to interact with the framework and master
742    * @param ns the NamespaceDescriptor for the table
743    * @throws IOException
744    */
745   void preCreateNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
746       NamespaceDescriptor ns) throws IOException;
747   /**
748    * Called after the createNamespace operation has been requested.
749    * @param ctx the environment to interact with the framework and master
750    * @param ns the NamespaceDescriptor for the table
751    * @throws IOException
752    */
753   void postCreateNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
754        NamespaceDescriptor ns) throws IOException;
755 
756   /**
757    * Called before {@link org.apache.hadoop.hbase.master.HMaster} deletes a
758    * namespace
759    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
760    * @param ctx the environment to interact with the framework and master
761    * @param namespace the name of the namespace
762    */
763   void preDeleteNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
764       String namespace) throws IOException;
765 
766   /**
767    * Called after the deleteNamespace operation has been requested.
768    * @param ctx the environment to interact with the framework and master
769    * @param namespace the name of the namespace
770    */
771   void postDeleteNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
772       String namespace) throws IOException;
773 
774   /**
775    * Called prior to modifying a namespace's properties.
776    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
777    * @param ctx the environment to interact with the framework and master
778    * @param ns the NamespaceDescriptor
779    */
780   void preModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
781       NamespaceDescriptor ns) throws IOException;
782 
783   /**
784    * Called after the modifyNamespace operation has been requested.
785    * @param ctx the environment to interact with the framework and master
786    * @param ns the NamespaceDescriptor
787    */
788   void postModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
789       NamespaceDescriptor ns) throws IOException;
790 
791   /**
792    * Called before a getNamespaceDescriptor request has been processed.
793    * @param ctx the environment to interact with the framework and master
794    * @param namespace the name of the namespace
795    * @throws IOException
796    */
797   void preGetNamespaceDescriptor(ObserverContext<MasterCoprocessorEnvironment> ctx,
798       String namespace) throws IOException;
799 
800   /**
801    * Called after a getNamespaceDescriptor request has been processed.
802    * @param ctx the environment to interact with the framework and master
803    * @param ns the NamespaceDescriptor
804    * @throws IOException
805    */
806   void postGetNamespaceDescriptor(ObserverContext<MasterCoprocessorEnvironment> ctx,
807       NamespaceDescriptor ns) throws IOException;
808 
809   /**
810    * Called before a listNamespaceDescriptors request has been processed.
811    * @param ctx the environment to interact with the framework and master
812    * @param descriptors an empty list, can be filled with what to return if bypassing
813    * @throws IOException
814    */
815   void preListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
816       List<NamespaceDescriptor> descriptors) throws IOException;
817 
818   /**
819    * Called after a listNamespaceDescriptors request has been processed.
820    * @param ctx the environment to interact with the framework and master
821    * @param descriptors the list of descriptors about to be returned
822    * @throws IOException
823    */
824   void postListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
825       List<NamespaceDescriptor> descriptors) throws IOException;
826 
827 
828   /**
829    * Called before the table memstore is flushed to disk.
830    * @param ctx the environment to interact with the framework and master
831    * @param tableName the name of the table
832    * @throws IOException
833    */
834   void preTableFlush(final ObserverContext<MasterCoprocessorEnvironment> ctx,
835       final TableName tableName) throws IOException;
836 
837   /**
838    * Called after the table memstore is flushed to disk.
839    * @param ctx the environment to interact with the framework and master
840    * @param tableName the name of the table
841    * @throws IOException
842    */
843   void postTableFlush(final ObserverContext<MasterCoprocessorEnvironment> ctx,
844       final TableName tableName) throws IOException;
845 
846   /**
847    * Called before the quota for the user is stored.
848    * @param ctx the environment to interact with the framework and master
849    * @param userName the name of user
850    * @param quotas the quota settings
851    * @throws IOException
852    */
853   void preSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
854       final String userName, final Quotas quotas) throws IOException;
855 
856   /**
857    * Called after the quota for the user is stored.
858    * @param ctx the environment to interact with the framework and master
859    * @param userName the name of user
860    * @param quotas the quota settings
861    * @throws IOException
862    */
863   void postSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
864       final String userName, final Quotas quotas) throws IOException;
865 
866   /**
867    * Called before the quota for the user on the specified table is stored.
868    * @param ctx the environment to interact with the framework and master
869    * @param userName the name of user
870    * @param tableName the name of the table
871    * @param quotas the quota settings
872    * @throws IOException
873    */
874   void preSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
875       final String userName, final TableName tableName, final Quotas quotas) throws IOException;
876 
877   /**
878    * Called after the quota for the user on the specified table is stored.
879    * @param ctx the environment to interact with the framework and master
880    * @param userName the name of user
881    * @param tableName the name of the table
882    * @param quotas the quota settings
883    * @throws IOException
884    */
885   void postSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
886       final String userName, final TableName tableName, final Quotas quotas) throws IOException;
887 
888   /**
889    * Called before the quota for the user on the specified namespace is stored.
890    * @param ctx the environment to interact with the framework and master
891    * @param userName the name of user
892    * @param namespace the name of the namespace
893    * @param quotas the quota settings
894    * @throws IOException
895    */
896   void preSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
897       final String userName, final String namespace, final Quotas quotas) throws IOException;
898 
899   /**
900    * Called after the quota for the user on the specified namespace is stored.
901    * @param ctx the environment to interact with the framework and master
902    * @param userName the name of user
903    * @param namespace the name of the namespace
904    * @param quotas the quota settings
905    * @throws IOException
906    */
907   void postSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
908       final String userName, final String namespace, final Quotas quotas) throws IOException;
909 
910   /**
911    * Called before the quota for the table is stored.
912    * @param ctx the environment to interact with the framework and master
913    * @param tableName the name of the table
914    * @param quotas the quota settings
915    * @throws IOException
916    */
917   void preSetTableQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
918       final TableName tableName, final Quotas quotas) throws IOException;
919 
920   /**
921    * Called after the quota for the table is stored.
922    * @param ctx the environment to interact with the framework and master
923    * @param tableName the name of the table
924    * @param quotas the quota settings
925    * @throws IOException
926    */
927   void postSetTableQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
928       final TableName tableName, final Quotas quotas) throws IOException;
929 
930   /**
931    * Called before the quota for the namespace is stored.
932    * @param ctx the environment to interact with the framework and master
933    * @param namespace the name of the namespace
934    * @param quotas the quota settings
935    * @throws IOException
936    */
937   void preSetNamespaceQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
938       final String namespace, final Quotas quotas) throws IOException;
939 
940   /**
941    * Called after the quota for the namespace is stored.
942    * @param ctx the environment to interact with the framework and master
943    * @param namespace the name of the namespace
944    * @param quotas the quota settings
945    * @throws IOException
946    */
947   void postSetNamespaceQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
948       final String namespace, final Quotas quotas) throws IOException;
949 }