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