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 com.google.common.net.HostAndPort;
23  
24  import java.io.IOException;
25  import java.util.List;
26  import java.util.Set;
27  
28  import org.apache.hadoop.hbase.Coprocessor;
29  import org.apache.hadoop.hbase.HBaseInterfaceAudience;
30  import org.apache.hadoop.hbase.HColumnDescriptor;
31  import org.apache.hadoop.hbase.HRegionInfo;
32  import org.apache.hadoop.hbase.HTableDescriptor;
33  import org.apache.hadoop.hbase.NamespaceDescriptor;
34  import org.apache.hadoop.hbase.ProcedureInfo;
35  import org.apache.hadoop.hbase.ServerName;
36  import org.apache.hadoop.hbase.TableName;
37  import org.apache.hadoop.hbase.classification.InterfaceAudience;
38  import org.apache.hadoop.hbase.classification.InterfaceStability;
39  import org.apache.hadoop.hbase.client.Admin;
40  import org.apache.hadoop.hbase.master.RegionPlan;
41  import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
42  import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
43  import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
44  import org.apache.hadoop.hbase.protobuf.generated.QuotaProtos.Quotas;
45  
46  /**
47   * Defines coprocessor hooks for interacting with operations on the
48   * {@link org.apache.hadoop.hbase.master.HMaster} process.
49   */
50  @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
51  @InterfaceStability.Evolving
52  public interface MasterObserver extends Coprocessor {
53  
54    /**
55     * Called before a new table is created by
56     * {@link org.apache.hadoop.hbase.master.HMaster}.  Called as part of create
57     * table RPC call.
58     * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
59     * @param ctx the environment to interact with the framework and master
60     * @param desc the HTableDescriptor for the table
61     * @param regions the initial regions created for the table
62     * @throws IOException
63     */
64    void preCreateTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
65        HTableDescriptor desc, HRegionInfo[] regions) throws IOException;
66  
67    /**
68     * Called after the createTable operation has been requested.  Called as part
69     * of create table RPC call.
70     * @param ctx the environment to interact with the framework and master
71     * @param desc the HTableDescriptor for the table
72     * @param regions the initial regions created for the table
73     * @throws IOException
74     */
75    void postCreateTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
76        HTableDescriptor desc, HRegionInfo[] regions) throws IOException;
77    /**
78     * Called before a new table is created by
79     * {@link org.apache.hadoop.hbase.master.HMaster}.  Called as part of create
80     * table handler and it is async to the create RPC call.
81     * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
82     * @param ctx the environment to interact with the framework and master
83     * @param desc the HTableDescriptor for the table
84     * @param regions the initial regions created for the table
85     * @throws IOException
86     */
87    void preCreateTableHandler(final ObserverContext<MasterCoprocessorEnvironment>
88        ctx, HTableDescriptor desc, HRegionInfo[] regions) throws IOException;
89  
90    /**
91     * Called after the createTable operation has been requested.  Called as part
92     * of create table RPC call.  Called as part of create table handler and
93     * it is async to the create RPC call.
94     * @param ctx the environment to interact with the framework and master
95     * @param desc the HTableDescriptor for the table
96     * @param regions the initial regions created for the table
97     * @throws IOException
98     */
99    void postCreateTableHandler(final ObserverContext<MasterCoprocessorEnvironment>
100   ctx, HTableDescriptor desc, HRegionInfo[] regions) throws IOException;
101 
102   /**
103    * Called before {@link org.apache.hadoop.hbase.master.HMaster} deletes a
104    * table.  Called as part of delete table RPC call.
105    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
106    * @param ctx the environment to interact with the framework and master
107    * @param tableName the name of the table
108    */
109   void preDeleteTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
110       TableName tableName) throws IOException;
111 
112   /**
113    * Called after the deleteTable operation has been requested.  Called as part
114    * of delete table RPC call.
115    * @param ctx the environment to interact with the framework and master
116    * @param tableName the name of the table
117    */
118   void postDeleteTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
119       TableName tableName) throws IOException;
120 
121   /**
122    * Called before {@link org.apache.hadoop.hbase.master.HMaster} deletes a
123    * table.  Called as part of delete table handler and
124    * it is async to the delete RPC call.
125    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
126    * @param ctx the environment to interact with the framework and master
127    * @param tableName the name of the table
128    */
129   void preDeleteTableHandler(
130       final ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName)
131       throws IOException;
132 
133   /**
134    * Called after {@link org.apache.hadoop.hbase.master.HMaster} deletes a
135    * table.  Called as part of delete table handler and it is async to the
136    * delete RPC call.
137    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
138    * @param ctx the environment to interact with the framework and master
139    * @param tableName the name of the table
140    */
141   void postDeleteTableHandler(
142       final ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName)
143       throws IOException;
144 
145 
146   /**
147    * Called before {@link org.apache.hadoop.hbase.master.HMaster} truncates a
148    * table.  Called as part of truncate table RPC call.
149    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
150    * @param ctx the environment to interact with the framework and master
151    * @param tableName the name of the table
152    */
153   void preTruncateTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
154       TableName tableName) throws IOException;
155 
156   /**
157    * Called after the truncateTable operation has been requested.  Called as part
158    * of truncate table RPC call.
159    * The truncate is synchronous, so this method will be called when the
160    * truncate operation is terminated.
161    * @param ctx the environment to interact with the framework and master
162    * @param tableName the name of the table
163    */
164   void postTruncateTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
165       TableName tableName) throws IOException;
166 
167   /**
168    * Called before {@link org.apache.hadoop.hbase.master.HMaster} truncates a
169    * table.  Called as part of truncate table handler and it is sync
170    * to the truncate RPC call.
171    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
172    * @param ctx the environment to interact with the framework and master
173    * @param tableName the name of the table
174    */
175   void preTruncateTableHandler(
176       final ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName)
177       throws IOException;
178 
179   /**
180    * Called after {@link org.apache.hadoop.hbase.master.HMaster} truncates a
181    * table.  Called as part of truncate table handler and it is sync to the
182    * truncate RPC call.
183    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
184    * @param ctx the environment to interact with the framework and master
185    * @param tableName the name of the table
186    */
187   void postTruncateTableHandler(
188       final ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName)
189       throws IOException;
190 
191   /**
192    * Called prior to modifying a table's properties.  Called as part of modify
193    * table RPC call.
194    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
195    * @param ctx the environment to interact with the framework and master
196    * @param tableName the name of the table
197    * @param htd the HTableDescriptor
198    */
199   void preModifyTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
200       final TableName tableName, HTableDescriptor htd) throws IOException;
201 
202   /**
203    * Called after the modifyTable operation has been requested.  Called as part
204    * of modify table RPC call.
205    * @param ctx the environment to interact with the framework and master
206    * @param tableName the name of the table
207    * @param htd the HTableDescriptor
208    */
209   void postModifyTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
210       final TableName tableName, HTableDescriptor htd) throws IOException;
211 
212   /**
213    * Called prior to modifying a table's properties.  Called as part of modify
214    * table handler and it is async to the modify table RPC call.
215    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
216    * @param ctx the environment to interact with the framework and master
217    * @param tableName the name of the table
218    * @param htd the HTableDescriptor
219    */
220   void preModifyTableHandler(
221       final ObserverContext<MasterCoprocessorEnvironment> ctx,
222       final TableName tableName, HTableDescriptor htd) throws IOException;
223 
224   /**
225    * Called after to modifying a table's properties.  Called as part of modify
226    * table handler and it is async to the modify table RPC call.
227    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
228    * @param ctx the environment to interact with the framework and master
229    * @param tableName the name of the table
230    * @param htd the HTableDescriptor
231    */
232   void postModifyTableHandler(
233       final ObserverContext<MasterCoprocessorEnvironment> ctx,
234       final TableName tableName, HTableDescriptor htd) throws IOException;
235 
236   /**
237    * Called prior to adding a new column family to the table.  Called as part of
238    * add column RPC call.
239    * @param ctx the environment to interact with the framework and master
240    * @param tableName the name of the table
241    * @param columnFamily the HColumnDescriptor
242    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
243    *             (<a href="https://issues.apache.org/jira/browse/HBASE-13645">HBASE-13645</a>).
244    *             Use {@link #preAddColumnFamily(ObserverContext, TableName, HColumnDescriptor)}.
245    */
246   @Deprecated
247   void preAddColumn(final ObserverContext<MasterCoprocessorEnvironment> ctx,
248       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
249 
250   /**
251    * Called prior to adding a new column family to the table.  Called as part of
252    * add column RPC call.
253    *
254    * Implementation note: This replaces the deprecated
255    * {@link #preAddColumn(ObserverContext, TableName, HColumnDescriptor)} method.
256    * Make sure to implement only one of the two as both are called.
257    *
258    * @param ctx the environment to interact with the framework and master
259    * @param tableName the name of the table
260    * @param columnFamily the HColumnDescriptor
261    */
262   void preAddColumnFamily(final ObserverContext<MasterCoprocessorEnvironment> ctx,
263       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
264 
265   /**
266    * Called after the new column family has been created.  Called as part of
267    * add column RPC call.
268    * @param ctx the environment to interact with the framework and master
269    * @param tableName the name of the table
270    * @param columnFamily the HColumnDescriptor
271    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
272    *             (<a href="https://issues.apache.org/jira/browse/HBASE-13645">HBASE-13645</a>).
273    *             Use {@link #postAddColumnFamily(ObserverContext, TableName, HColumnDescriptor)}.
274    */
275   @Deprecated
276   void postAddColumn(final ObserverContext<MasterCoprocessorEnvironment> ctx,
277       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
278 
279   /**
280    * Called after the new column family has been created.  Called as part of
281    * add column RPC call.
282    *
283    * Implementation note: This replaces the deprecated
284    * {@link #postAddColumn(ObserverContext, TableName, HColumnDescriptor)} method.
285    * Make sure to implement only one of the two as both are called.
286    *
287    * @param ctx the environment to interact with the framework and master
288    * @param tableName the name of the table
289    * @param columnFamily the HColumnDescriptor
290    */
291   void postAddColumnFamily(final ObserverContext<MasterCoprocessorEnvironment> ctx,
292       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
293 
294   /**
295    * Called prior to adding a new column family to the table.  Called as part of
296    * add column handler.
297    * @param ctx the environment to interact with the framework and master
298    * @param tableName the name of the table
299    * @param columnFamily the HColumnDescriptor
300    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
301    *             (<a href="https://issues.apache.org/jira/browse/HBASE-13645">HBASE-13645</a>). Use
302    *             {@link #preAddColumnFamilyHandler(ObserverContext, TableName, HColumnDescriptor)}.
303    */
304   @Deprecated
305   void preAddColumnHandler(
306       final ObserverContext<MasterCoprocessorEnvironment> ctx,
307       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
308 
309   /**
310    * Called prior to adding a new column family to the table.  Called as part of
311    * add column handler.
312    *
313    * Implementation note: This replaces the deprecated
314    * {@link #preAddColumnHandler(ObserverContext, TableName, HColumnDescriptor)} method.
315    * Make sure to implement only one of the two as both are called.
316    *
317    * @param ctx the environment to interact with the framework and master
318    * @param tableName the name of the table
319    * @param columnFamily the HColumnDescriptor
320    */
321   void preAddColumnFamilyHandler(
322       final ObserverContext<MasterCoprocessorEnvironment> ctx,
323       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
324 
325 
326   /**
327    * Called after the new column family has been created.  Called as part of
328    * add column handler.
329    * @param ctx the environment to interact with the framework and master
330    * @param tableName the name of the table
331    * @param columnFamily the HColumnDescriptor
332    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
333    *             (<a href="https://issues.apache.org/jira/browse/HBASE-13645">HBASE-13645</a>). Use
334    *             {@link #postAddColumnFamilyHandler(ObserverContext, TableName, HColumnDescriptor)}.
335    */
336   @Deprecated
337   void postAddColumnHandler(
338       final ObserverContext<MasterCoprocessorEnvironment> ctx,
339       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
340 
341   /**
342    * Called after the new column family has been created.  Called as part of
343    * add column handler.
344    *
345    * Implementation note: This replaces the deprecated
346    * {@link #postAddColumnHandler(ObserverContext, TableName, HColumnDescriptor)} method.
347    * Make sure to implement only one of the two as both are called.
348    *
349    * @param ctx the environment to interact with the framework and master
350    * @param tableName the name of the table
351    * @param columnFamily the HColumnDescriptor
352    */
353   void postAddColumnFamilyHandler(
354       final ObserverContext<MasterCoprocessorEnvironment> ctx,
355       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
356 
357   /**
358    * Called prior to modifying a column family's attributes.  Called as part of
359    * modify column RPC call.
360    * @param ctx the environment to interact with the framework and master
361    * @param tableName the name of the table
362    * @param columnFamily the HColumnDescriptor
363    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
364    *             (<a href="https://issues.apache.org/jira/browse/HBASE-13645">HBASE-13645</a>).
365    *             Use {@link #preModifyColumnFamily(ObserverContext, TableName, HColumnDescriptor)}.
366    */
367   @Deprecated
368   void preModifyColumn(final ObserverContext<MasterCoprocessorEnvironment> ctx,
369       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
370 
371   /**
372    * Called prior to modifying a column family's attributes.  Called as part of
373    * modify column RPC call.
374    *
375    * Implementation note: This replaces the deprecated
376    * {@link #preModifyColumn(ObserverContext, TableName, HColumnDescriptor)} method.
377    * Make sure to implement only one of the two as both are called.
378    *
379    * @param ctx the environment to interact with the framework and master
380    * @param tableName the name of the table
381    * @param columnFamily the HColumnDescriptor
382    */
383   void preModifyColumnFamily(final ObserverContext<MasterCoprocessorEnvironment> ctx,
384       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
385 
386   /**
387    * Called after the column family has been updated.  Called as part of modify
388    * column RPC call.
389    * @param ctx the environment to interact with the framework and master
390    * @param tableName the name of the table
391    * @param columnFamily the HColumnDescriptor
392    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
393    *             (<a href="https://issues.apache.org/jira/browse/HBASE-13645">HBASE-13645</a>).
394    *             Use {@link #postModifyColumnFamily(ObserverContext, TableName, HColumnDescriptor)}.
395    */
396   @Deprecated
397   void postModifyColumn(final ObserverContext<MasterCoprocessorEnvironment> ctx,
398       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
399 
400   /**
401    * Called after the column family has been updated.  Called as part of modify
402    * column RPC call.
403    *
404    * Implementation note: This replaces the deprecated
405    * {@link #postModifyColumn(ObserverContext, TableName, HColumnDescriptor)} method.
406    * Make sure to implement only one of the two as both are called.
407    *
408    * @param ctx the environment to interact with the framework and master
409    * @param tableName the name of the table
410    * @param columnFamily the HColumnDescriptor
411    */
412   void postModifyColumnFamily(final ObserverContext<MasterCoprocessorEnvironment> ctx,
413       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
414 
415   /**
416    * Called prior to modifying a column family's attributes.  Called as part of
417    * modify column handler.
418    * @param ctx the environment to interact with the framework and master
419    * @param tableName the name of the table
420    * @param columnFamily the HColumnDescriptor
421    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
422    *       (<a href="https://issues.apache.org/jira/browse/HBASE-13645">HBASE-13645</a>).
423    *       Use {@link #preModifyColumnFamilyHandler(ObserverContext, TableName, HColumnDescriptor)}.
424    */
425   @Deprecated
426   void preModifyColumnHandler(
427       final ObserverContext<MasterCoprocessorEnvironment> ctx,
428       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
429 
430   /**
431    * Called prior to modifying a column family's attributes.  Called as part of
432    * modify column handler.
433    *
434    * Implementation note: This replaces the deprecated
435    * {@link #preModifyColumnHandler(ObserverContext, TableName, HColumnDescriptor)} method.
436    * Make sure to implement only one of the two as both are called.
437    *
438    * @param ctx the environment to interact with the framework and master
439    * @param tableName the name of the table
440    * @param columnFamily the HColumnDescriptor
441    */
442   void preModifyColumnFamilyHandler(
443       final ObserverContext<MasterCoprocessorEnvironment> ctx,
444       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
445 
446   /**
447    * Called after the column family has been updated.  Called as part of modify
448    * column handler.
449    * @param ctx the environment to interact with the framework and master
450    * @param tableName the name of the table
451    * @param columnFamily the HColumnDescriptor
452    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
453    *      (<a href="https://issues.apache.org/jira/browse/HBASE-13645">HBASE-13645</a>).
454    *      Use {@link #postModifyColumnFamilyHandler(ObserverContext, TableName, HColumnDescriptor)}.
455    */
456   @Deprecated
457   void postModifyColumnHandler(
458       final ObserverContext<MasterCoprocessorEnvironment> ctx,
459       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
460 
461   /**
462    * Called after the column family has been updated.  Called as part of modify
463    * column handler.
464    *
465    * Implementation note: This replaces the deprecated
466    * {@link #postModifyColumnHandler(ObserverContext, TableName, HColumnDescriptor)} method.
467    * Make sure to implement only one of the two as both are called.
468    *
469    * @param ctx the environment to interact with the framework and master
470    * @param tableName the name of the table
471    * @param columnFamily the HColumnDescriptor
472    */
473   void postModifyColumnFamilyHandler(
474       final ObserverContext<MasterCoprocessorEnvironment> ctx,
475       TableName tableName, HColumnDescriptor columnFamily) throws IOException;
476 
477   /**
478    * Called prior to deleting the entire column family.  Called as part of
479    * delete column RPC call.
480    * @param ctx the environment to interact with the framework and master
481    * @param tableName the name of the table
482    * @param columnFamily the column family
483    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
484    *             (<a href="https://issues.apache.org/jira/browse/HBASE-13645">HBASE-13645</a>).
485    *             Use {@link #preDeleteColumnFamily(ObserverContext, TableName, byte[])}.
486    */
487   @Deprecated
488   void preDeleteColumn(final ObserverContext<MasterCoprocessorEnvironment> ctx,
489       final TableName tableName, final byte[] columnFamily) throws IOException;
490 
491   /**
492    * Called prior to deleting the entire column family.  Called as part of
493    * delete column RPC call.
494    *
495    * Implementation note: This replaces the deprecated
496    * {@link #preDeleteColumn(ObserverContext, TableName, byte[])} method.
497    * Make sure to implement only one of the two as both are called.
498    *
499    * @param ctx the environment to interact with the framework and master
500    * @param tableName the name of the table
501    * @param columnFamily the column
502    */
503   void preDeleteColumnFamily(final ObserverContext<MasterCoprocessorEnvironment> ctx,
504       final TableName tableName, final byte[] columnFamily) throws IOException;
505 
506   /**
507    * Called after the column family has been deleted.  Called as part of delete
508    * column RPC call.
509    * @param ctx the environment to interact with the framework and master
510    * @param tableName the name of the table
511    * @param columnFamily the column family
512    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
513    *             (<a href="https://issues.apache.org/jira/browse/HBASE-13645">HBASE-13645</a>).
514    *             Use {@link #postDeleteColumnFamily(ObserverContext, TableName, byte[])}.
515    */
516   @Deprecated
517   void postDeleteColumn(final ObserverContext<MasterCoprocessorEnvironment> ctx,
518       final TableName tableName, final byte[] columnFamily) throws IOException;
519 
520   /**
521    * Called after the column family has been deleted.  Called as part of delete
522    * column RPC call.
523    *
524    * Implementation note: This replaces the deprecated
525    * {@link #postDeleteColumn(ObserverContext, TableName, byte[])} method.
526    * Make sure to implement only one of the two as both are called.
527    *
528    * @param ctx the environment to interact with the framework and master
529    * @param tableName the name of the table
530    * @param columnFamily the column family
531    */
532   void postDeleteColumnFamily(final ObserverContext<MasterCoprocessorEnvironment> ctx,
533       final TableName tableName, final byte[] columnFamily) throws IOException;
534 
535   /**
536    * Called prior to deleting the entire column family.  Called as part of
537    * delete column handler.
538    * @param ctx the environment to interact with the framework and master
539    * @param tableName the name of the table
540    * @param columnFamily the column family
541    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
542    *             (<a href="https://issues.apache.org/jira/browse/HBASE-13645">HBASE-13645</a>).
543    *             Use {@link #preDeleteColumnFamilyHandler(ObserverContext, TableName, byte[])}.
544    */
545   @Deprecated
546   void preDeleteColumnHandler(
547       final ObserverContext<MasterCoprocessorEnvironment> ctx,
548       final TableName tableName, final byte[] columnFamily) throws IOException;
549 
550   /**
551    * Called prior to deleting the entire column family.  Called as part of
552    * delete column handler.
553    *
554    * Implementation note: This replaces the deprecated
555    * {@link #preDeleteColumnHandler(ObserverContext, TableName, byte[])} method.
556    * Make sure to implement only one of the two as both are called.
557    *
558    * @param ctx the environment to interact with the framework and master
559    * @param tableName the name of the table
560    * @param columnFamily the column family
561    */
562   void preDeleteColumnFamilyHandler(
563       final ObserverContext<MasterCoprocessorEnvironment> ctx,
564       final TableName tableName, final byte[] columnFamily) throws IOException;
565 
566   /**
567    * Called after the column family has been deleted.  Called as part of
568    * delete column handler.
569    * @param ctx the environment to interact with the framework and master
570    * @param tableName the name of the table
571    * @param columnFamily the column family
572    * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
573    *             (<a href="https://issues.apache.org/jira/browse/HBASE-13645">HBASE-13645</a>).
574    *             Use {@link #postDeleteColumnFamilyHandler(ObserverContext, TableName, byte[])}.
575    */
576   @Deprecated
577   void postDeleteColumnHandler(
578       final ObserverContext<MasterCoprocessorEnvironment> ctx,
579       final TableName tableName, final byte[] columnFamily) throws IOException;
580 
581   /**
582    * Called after the column family has been deleted.  Called as part of
583    * delete column handler.
584    *
585    * Implementation note: This replaces the deprecated
586    * {@link #postDeleteColumnHandler(ObserverContext, TableName, byte[])} method.
587    * Make sure to implement only one of the two as both are called.
588    *
589    * @param ctx the environment to interact with the framework and master
590    * @param tableName the name of the table
591    * @param columnFamily the column family
592    */
593   void postDeleteColumnFamilyHandler(
594       final ObserverContext<MasterCoprocessorEnvironment> ctx,
595       final TableName tableName, final byte[] columnFamily) throws IOException;
596 
597   /**
598    * Called prior to enabling a table.  Called as part of enable table RPC call.
599    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
600    * @param ctx the environment to interact with the framework and master
601    * @param tableName the name of the table
602    */
603   void preEnableTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
604       final TableName tableName) throws IOException;
605 
606   /**
607    * Called after the enableTable operation has been requested.  Called as part
608    * of enable table RPC call.
609    * @param ctx the environment to interact with the framework and master
610    * @param tableName the name of the table
611    */
612   void postEnableTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
613       final TableName tableName) throws IOException;
614 
615   /**
616    * Called prior to enabling a table.  Called as part of enable table handler
617    * and it is async to the enable table RPC call.
618    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
619    * @param ctx the environment to interact with the framework and master
620    * @param tableName the name of the table
621    */
622   void preEnableTableHandler(
623       final ObserverContext<MasterCoprocessorEnvironment> ctx,
624       final TableName tableName) throws IOException;
625 
626   /**
627    * Called after the enableTable operation has been requested.  Called as part
628    * of enable table handler and it is async to the enable table RPC call.
629    * @param ctx the environment to interact with the framework and master
630    * @param tableName the name of the table
631    */
632   void postEnableTableHandler(
633       final ObserverContext<MasterCoprocessorEnvironment> ctx,
634       final TableName tableName) throws IOException;
635 
636   /**
637    * Called prior to disabling a table.  Called as part of disable table RPC
638    * call.
639    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
640    * @param ctx the environment to interact with the framework and master
641    * @param tableName the name of the table
642    */
643   void preDisableTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
644       final TableName tableName) throws IOException;
645 
646   /**
647    * Called after the disableTable operation has been requested.  Called as part
648    * of disable table RPC call.
649    * @param ctx the environment to interact with the framework and master
650    * @param tableName the name of the table
651    */
652   void postDisableTable(final ObserverContext<MasterCoprocessorEnvironment> ctx,
653       final TableName tableName) throws IOException;
654 
655   /**
656    * Called prior to disabling a table.  Called as part of disable table handler
657    * and it is asyn to the disable table RPC call.
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 tableName the name of the table
661    */
662   void preDisableTableHandler(
663       final ObserverContext<MasterCoprocessorEnvironment> ctx,
664       final TableName tableName) throws IOException;
665 
666   /**
667    * Called after the disableTable operation has been requested.  Called as part
668    * of disable table handler and it is asyn to the disable table RPC call.
669    * @param ctx the environment to interact with the framework and master
670    * @param tableName the name of the table
671    */
672   void postDisableTableHandler(
673       final ObserverContext<MasterCoprocessorEnvironment> ctx,
674       final TableName tableName) throws IOException;
675 
676   /**
677    * Called before a abortProcedure request has been processed.
678    * @param ctx the environment to interact with the framework and master
679    * @throws IOException
680    */
681   public void preAbortProcedure(
682       ObserverContext<MasterCoprocessorEnvironment> ctx,
683       final ProcedureExecutor<MasterProcedureEnv> procEnv,
684       final long procId) throws IOException;
685 
686   /**
687    * Called after a abortProcedure request has been processed.
688    * @param ctx the environment to interact with the framework and master
689    */
690   public void postAbortProcedure(ObserverContext<MasterCoprocessorEnvironment> ctx)
691       throws IOException;
692 
693   /**
694    * Called before a listProcedures request has been processed.
695    * @param ctx the environment to interact with the framework and master
696    * @throws IOException
697    */
698   void preListProcedures(ObserverContext<MasterCoprocessorEnvironment> ctx)
699       throws IOException;
700 
701   /**
702    * Called after a listProcedures request has been processed.
703    * @param ctx the environment to interact with the framework and master
704    * @param procInfoList the list of procedures about to be returned
705    */
706   void postListProcedures(
707       ObserverContext<MasterCoprocessorEnvironment> ctx,
708       List<ProcedureInfo> procInfoList) throws IOException;
709 
710   /**
711    * Called prior to moving a given region from one region server to another.
712    * @param ctx the environment to interact with the framework and master
713    * @param region the HRegionInfo
714    * @param srcServer the source ServerName
715    * @param destServer the destination ServerName
716    */
717   void preMove(final ObserverContext<MasterCoprocessorEnvironment> ctx,
718       final HRegionInfo region, final ServerName srcServer,
719       final ServerName destServer)
720     throws IOException;
721 
722   /**
723    * Called after the region move has been requested.
724    * @param ctx the environment to interact with the framework and master
725    * @param region the HRegionInfo
726    * @param srcServer the source ServerName
727    * @param destServer the destination ServerName
728    */
729   void postMove(final ObserverContext<MasterCoprocessorEnvironment> ctx,
730       final HRegionInfo region, final ServerName srcServer,
731       final ServerName destServer)
732     throws IOException;
733 
734   /**
735    * Called prior to assigning a specific region.
736    * @param ctx the environment to interact with the framework and master
737    * @param regionInfo the regionInfo of the region
738    */
739   void preAssign(final ObserverContext<MasterCoprocessorEnvironment> ctx,
740       final HRegionInfo regionInfo) throws IOException;
741 
742   /**
743    * Called after the region assignment has been requested.
744    * @param ctx the environment to interact with the framework and master
745    * @param regionInfo the regionInfo of the region
746    */
747   void postAssign(final ObserverContext<MasterCoprocessorEnvironment> ctx,
748       final HRegionInfo regionInfo) throws IOException;
749 
750   /**
751    * Called prior to unassigning a given region.
752    * @param ctx the environment to interact with the framework and master
753    * @param regionInfo
754    * @param force whether to force unassignment or not
755    */
756   void preUnassign(final ObserverContext<MasterCoprocessorEnvironment> ctx,
757       final HRegionInfo regionInfo, final boolean force) throws IOException;
758 
759   /**
760    * Called after the region unassignment has been requested.
761    * @param ctx the environment to interact with the framework and master
762    * @param regionInfo
763    * @param force whether to force unassignment or not
764    */
765   void postUnassign(final ObserverContext<MasterCoprocessorEnvironment> ctx,
766       final HRegionInfo regionInfo, final boolean force) throws IOException;
767 
768   /**
769    * Called prior to marking a given region as offline. <code>ctx.bypass()</code> will not have any
770    * impact on this hook.
771    * @param ctx the environment to interact with the framework and master
772    * @param regionInfo
773    */
774   void preRegionOffline(final ObserverContext<MasterCoprocessorEnvironment> ctx,
775       final HRegionInfo regionInfo) throws IOException;
776 
777   /**
778    * Called after the region has been marked offline.
779    * @param ctx the environment to interact with the framework and master
780    * @param regionInfo
781    */
782   void postRegionOffline(final ObserverContext<MasterCoprocessorEnvironment> ctx,
783       final HRegionInfo regionInfo) throws IOException;
784 
785   /**
786    * Called prior to requesting rebalancing of the cluster regions, though after
787    * the initial checks for regions in transition and the balance switch flag.
788    * @param ctx the environment to interact with the framework and master
789    */
790   void preBalance(final ObserverContext<MasterCoprocessorEnvironment> ctx)
791       throws IOException;
792 
793   /**
794    * Called after the balancing plan has been submitted.
795    * @param ctx the environment to interact with the framework and master
796    * @param plans the RegionPlans which master has executed. RegionPlan serves as hint
797    * as for the final destination for the underlying region but may not represent the
798    * final state of assignment
799    */
800   void postBalance(final ObserverContext<MasterCoprocessorEnvironment> ctx, List<RegionPlan> plans)
801       throws IOException;
802 
803   /**
804    * Called prior to setting split / merge switch
805    * @param ctx the coprocessor instance's environment
806    * @param newValue the new value submitted in the call
807    * @param switchType type of switch
808    */
809   boolean preSetSplitOrMergeEnabled(final ObserverContext<MasterCoprocessorEnvironment> ctx,
810       final boolean newValue, final Admin.MasterSwitchType switchType) throws IOException;
811 
812   /**
813    * Called after setting split / merge switch
814    * @param ctx the coprocessor instance's environment
815    * @param newValue the new value submitted in the call
816    * @param switchType type of switch
817    */
818   void postSetSplitOrMergeEnabled(final ObserverContext<MasterCoprocessorEnvironment> ctx,
819       final boolean newValue, final Admin.MasterSwitchType switchType) throws IOException;
820 
821   /**
822    * Called prior to modifying the flag used to enable/disable region balancing.
823    * @param ctx the coprocessor instance's environment
824    * @param newValue the new flag value submitted in the call
825    */
826   boolean preBalanceSwitch(final ObserverContext<MasterCoprocessorEnvironment> ctx,
827       final boolean newValue) throws IOException;
828 
829   /**
830    * Called after the flag to enable/disable balancing has changed.
831    * @param ctx the coprocessor instance's environment
832    * @param oldValue the previously set balanceSwitch value
833    * @param newValue the newly set balanceSwitch value
834    */
835   void postBalanceSwitch(final ObserverContext<MasterCoprocessorEnvironment> ctx,
836       final boolean oldValue, final boolean newValue) throws IOException;
837 
838   /**
839    * Called prior to shutting down the full HBase cluster, including this
840    * {@link org.apache.hadoop.hbase.master.HMaster} process.
841    */
842   void preShutdown(final ObserverContext<MasterCoprocessorEnvironment> ctx)
843       throws IOException;
844 
845 
846   /**
847    * Called immediately prior to stopping this
848    * {@link org.apache.hadoop.hbase.master.HMaster} process.
849    */
850   void preStopMaster(final ObserverContext<MasterCoprocessorEnvironment> ctx)
851       throws IOException;
852 
853   /**
854    * Called immediately after an active master instance has completed
855    * initialization.  Will not be called on standby master instances unless
856    * they take over the active role.
857    */
858   void postStartMaster(final ObserverContext<MasterCoprocessorEnvironment> ctx)
859       throws IOException;
860 
861   /**
862    * Call before the master initialization is set to true.
863    * {@link org.apache.hadoop.hbase.master.HMaster} process.
864    */
865   void preMasterInitialization(final ObserverContext<MasterCoprocessorEnvironment> ctx)
866       throws IOException;
867 
868   /**
869    * Called before a new snapshot is taken.
870    * Called as part of snapshot RPC call.
871    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
872    * @param ctx the environment to interact with the framework and master
873    * @param snapshot the SnapshotDescriptor for the snapshot
874    * @param hTableDescriptor the hTableDescriptor of the table to snapshot
875    * @throws IOException
876    */
877   void preSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx,
878       final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor)
879       throws IOException;
880 
881   /**
882    * Called after the snapshot operation has been requested.
883    * Called as part of snapshot RPC call.
884    * @param ctx the environment to interact with the framework and master
885    * @param snapshot the SnapshotDescriptor for the snapshot
886    * @param hTableDescriptor the hTableDescriptor of the table to snapshot
887    * @throws IOException
888    */
889   void postSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx,
890       final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor)
891       throws IOException;
892 
893   /**
894    * Called before listSnapshots request has been processed.
895    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
896    * @param ctx the environment to interact with the framework and master
897    * @param snapshot the SnapshotDescriptor of the snapshot to list
898    * @throws IOException
899    */
900   void preListSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx,
901       final SnapshotDescription snapshot) throws IOException;
902 
903   /**
904    * Called after listSnapshots request has been processed.
905    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
906    * @param ctx the environment to interact with the framework and master
907    * @param snapshot the SnapshotDescriptor of the snapshot to list
908    * @throws IOException
909    */
910   void postListSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx,
911       final SnapshotDescription snapshot) throws IOException;
912 
913   /**
914    * Called before a snapshot is cloned.
915    * Called as part of restoreSnapshot RPC call.
916    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
917    * @param ctx the environment to interact with the framework and master
918    * @param snapshot the SnapshotDescriptor for the snapshot
919    * @param hTableDescriptor the hTableDescriptor of the table to create
920    * @throws IOException
921    */
922   void preCloneSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx,
923       final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor)
924       throws IOException;
925 
926   /**
927    * Called after a snapshot clone operation has been requested.
928    * Called as part of restoreSnapshot RPC call.
929    * @param ctx the environment to interact with the framework and master
930    * @param snapshot the SnapshotDescriptor for the snapshot
931    * @param hTableDescriptor the hTableDescriptor of the table to create
932    * @throws IOException
933    */
934   void postCloneSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx,
935       final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor)
936       throws IOException;
937 
938   /**
939    * Called before a snapshot is restored.
940    * Called as part of restoreSnapshot RPC call.
941    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
942    * @param ctx the environment to interact with the framework and master
943    * @param snapshot the SnapshotDescriptor for the snapshot
944    * @param hTableDescriptor the hTableDescriptor of the table to restore
945    * @throws IOException
946    */
947   void preRestoreSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx,
948       final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor)
949       throws IOException;
950 
951   /**
952    * Called after a snapshot restore operation has been requested.
953    * Called as part of restoreSnapshot RPC call.
954    * @param ctx the environment to interact with the framework and master
955    * @param snapshot the SnapshotDescriptor for the snapshot
956    * @param hTableDescriptor the hTableDescriptor of the table to restore
957    * @throws IOException
958    */
959   void postRestoreSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx,
960       final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor)
961       throws IOException;
962 
963   /**
964    * Called before a snapshot is deleted.
965    * Called as part of deleteSnapshot RPC call.
966    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
967    * @param ctx the environment to interact with the framework and master
968    * @param snapshot the SnapshotDescriptor of the snapshot to delete
969    * @throws IOException
970    */
971   void preDeleteSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx,
972       final SnapshotDescription snapshot) throws IOException;
973 
974   /**
975    * Called after the delete snapshot operation has been requested.
976    * Called as part of deleteSnapshot RPC call.
977    * @param ctx the environment to interact with the framework and master
978    * @param snapshot the SnapshotDescriptor of the snapshot to delete
979    * @throws IOException
980    */
981   void postDeleteSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx,
982       final SnapshotDescription snapshot) throws IOException;
983 
984   /**
985    * Called before a getTableDescriptors request has been processed.
986    * @param ctx the environment to interact with the framework and master
987    * @param tableNamesList the list of table names, or null if querying for all
988    * @param descriptors an empty list, can be filled with what to return if bypassing
989    * @param regex regular expression used for filtering the table names
990    * @throws IOException
991    */
992   void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
993       List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
994       String regex) throws IOException;
995 
996   /**
997    * Called after a getTableDescriptors request has been processed.
998    * @param ctx the environment to interact with the framework and master
999    * @param tableNamesList the list of table names, or null if querying for all
1000    * @param descriptors the list of descriptors about to be returned
1001    * @param regex regular expression used for filtering the table names
1002    * @throws IOException
1003    */
1004   void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
1005       List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
1006       String regex) throws IOException;
1007 
1008   /**
1009    * Called before a getTableNames request has been processed.
1010    * @param ctx the environment to interact with the framework and master
1011    * @param descriptors an empty list, can be filled with what to return if bypassing
1012    * @param regex regular expression used for filtering the table names
1013    * @throws IOException
1014    */
1015   void preGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
1016       List<HTableDescriptor> descriptors, String regex) throws IOException;
1017 
1018   /**
1019    * Called after a getTableNames request has been processed.
1020    * @param ctx the environment to interact with the framework and master
1021    * @param descriptors the list of descriptors about to be returned
1022    * @param regex regular expression used for filtering the table names
1023    * @throws IOException
1024    */
1025   void postGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
1026       List<HTableDescriptor> descriptors, String regex) throws IOException;
1027 
1028 
1029 
1030   /**
1031    * Called before a new namespace is created by
1032    * {@link org.apache.hadoop.hbase.master.HMaster}.
1033    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
1034    * @param ctx the environment to interact with the framework and master
1035    * @param ns the NamespaceDescriptor for the table
1036    * @throws IOException
1037    */
1038   void preCreateNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1039       NamespaceDescriptor ns) throws IOException;
1040   /**
1041    * Called after the createNamespace operation has been requested.
1042    * @param ctx the environment to interact with the framework and master
1043    * @param ns the NamespaceDescriptor for the table
1044    * @throws IOException
1045    */
1046   void postCreateNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1047        NamespaceDescriptor ns) throws IOException;
1048 
1049   /**
1050    * Called before {@link org.apache.hadoop.hbase.master.HMaster} deletes a
1051    * namespace
1052    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
1053    * @param ctx the environment to interact with the framework and master
1054    * @param namespace the name of the namespace
1055    */
1056   void preDeleteNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1057       String namespace) throws IOException;
1058 
1059   /**
1060    * Called after the deleteNamespace operation has been requested.
1061    * @param ctx the environment to interact with the framework and master
1062    * @param namespace the name of the namespace
1063    */
1064   void postDeleteNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1065       String namespace) throws IOException;
1066 
1067   /**
1068    * Called prior to modifying a namespace's properties.
1069    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
1070    * @param ctx the environment to interact with the framework and master
1071    * @param ns the NamespaceDescriptor
1072    */
1073   void preModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1074       NamespaceDescriptor ns) throws IOException;
1075 
1076   /**
1077    * Called after the modifyNamespace operation has been requested.
1078    * @param ctx the environment to interact with the framework and master
1079    * @param ns the NamespaceDescriptor
1080    */
1081   void postModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1082       NamespaceDescriptor ns) throws IOException;
1083 
1084   /**
1085    * Called before a getNamespaceDescriptor request has been processed.
1086    * @param ctx the environment to interact with the framework and master
1087    * @param namespace the name of the namespace
1088    * @throws IOException
1089    */
1090   void preGetNamespaceDescriptor(ObserverContext<MasterCoprocessorEnvironment> ctx,
1091       String namespace) throws IOException;
1092 
1093   /**
1094    * Called after a getNamespaceDescriptor request has been processed.
1095    * @param ctx the environment to interact with the framework and master
1096    * @param ns the NamespaceDescriptor
1097    * @throws IOException
1098    */
1099   void postGetNamespaceDescriptor(ObserverContext<MasterCoprocessorEnvironment> ctx,
1100       NamespaceDescriptor ns) throws IOException;
1101 
1102   /**
1103    * Called before a listNamespaceDescriptors request has been processed.
1104    * @param ctx the environment to interact with the framework and master
1105    * @param descriptors an empty list, can be filled with what to return if bypassing
1106    * @throws IOException
1107    */
1108   void preListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
1109       List<NamespaceDescriptor> descriptors) throws IOException;
1110 
1111   /**
1112    * Called after a listNamespaceDescriptors request has been processed.
1113    * @param ctx the environment to interact with the framework and master
1114    * @param descriptors the list of descriptors about to be returned
1115    * @throws IOException
1116    */
1117   void postListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
1118       List<NamespaceDescriptor> descriptors) throws IOException;
1119 
1120 
1121   /**
1122    * Called before the table memstore is flushed to disk.
1123    * @param ctx the environment to interact with the framework and master
1124    * @param tableName the name of the table
1125    * @throws IOException
1126    */
1127   void preTableFlush(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1128       final TableName tableName) throws IOException;
1129 
1130   /**
1131    * Called after the table memstore is flushed to disk.
1132    * @param ctx the environment to interact with the framework and master
1133    * @param tableName the name of the table
1134    * @throws IOException
1135    */
1136   void postTableFlush(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1137       final TableName tableName) throws IOException;
1138 
1139   /**
1140    * Called before the quota for the user is stored.
1141    * @param ctx the environment to interact with the framework and master
1142    * @param userName the name of user
1143    * @param quotas the quota settings
1144    * @throws IOException
1145    */
1146   void preSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1147       final String userName, final Quotas quotas) throws IOException;
1148 
1149   /**
1150    * Called after the quota for the user is stored.
1151    * @param ctx the environment to interact with the framework and master
1152    * @param userName the name of user
1153    * @param quotas the quota settings
1154    * @throws IOException
1155    */
1156   void postSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1157       final String userName, final Quotas quotas) throws IOException;
1158 
1159   /**
1160    * Called before the quota for the user on the specified table is stored.
1161    * @param ctx the environment to interact with the framework and master
1162    * @param userName the name of user
1163    * @param tableName the name of the table
1164    * @param quotas the quota settings
1165    * @throws IOException
1166    */
1167   void preSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1168       final String userName, final TableName tableName, final Quotas quotas) throws IOException;
1169 
1170   /**
1171    * Called after the quota for the user on the specified table is stored.
1172    * @param ctx the environment to interact with the framework and master
1173    * @param userName the name of user
1174    * @param tableName the name of the table
1175    * @param quotas the quota settings
1176    * @throws IOException
1177    */
1178   void postSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1179       final String userName, final TableName tableName, final Quotas quotas) throws IOException;
1180 
1181   /**
1182    * Called before the quota for the user on the specified namespace is stored.
1183    * @param ctx the environment to interact with the framework and master
1184    * @param userName the name of user
1185    * @param namespace the name of the namespace
1186    * @param quotas the quota settings
1187    * @throws IOException
1188    */
1189   void preSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1190       final String userName, final String namespace, final Quotas quotas) throws IOException;
1191 
1192   /**
1193    * Called after the quota for the user on the specified namespace is stored.
1194    * @param ctx the environment to interact with the framework and master
1195    * @param userName the name of user
1196    * @param namespace the name of the namespace
1197    * @param quotas the quota settings
1198    * @throws IOException
1199    */
1200   void postSetUserQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1201       final String userName, final String namespace, final Quotas quotas) throws IOException;
1202 
1203   /**
1204    * Called before the quota for the table is stored.
1205    * @param ctx the environment to interact with the framework and master
1206    * @param tableName the name of the table
1207    * @param quotas the quota settings
1208    * @throws IOException
1209    */
1210   void preSetTableQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1211       final TableName tableName, final Quotas quotas) throws IOException;
1212 
1213   /**
1214    * Called after the quota for the table is stored.
1215    * @param ctx the environment to interact with the framework and master
1216    * @param tableName the name of the table
1217    * @param quotas the quota settings
1218    * @throws IOException
1219    */
1220   void postSetTableQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1221       final TableName tableName, final Quotas quotas) throws IOException;
1222 
1223   /**
1224    * Called before the quota for the namespace is stored.
1225    * @param ctx the environment to interact with the framework and master
1226    * @param namespace the name of the namespace
1227    * @param quotas the quota settings
1228    * @throws IOException
1229    */
1230   void preSetNamespaceQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1231       final String namespace, final Quotas quotas) throws IOException;
1232 
1233   /**
1234    * Called after the quota for the namespace is stored.
1235    * @param ctx the environment to interact with the framework and master
1236    * @param namespace the name of the namespace
1237    * @param quotas the quota settings
1238    * @throws IOException
1239    */
1240   void postSetNamespaceQuota(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1241       final String namespace, final Quotas quotas) throws IOException;
1242 
1243   /**
1244    * Called before dispatching region merge request. 
1245    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.
1246    * @param ctx coprocessor environment
1247    * @param regionA first region to be merged
1248    * @param regionB second region to be merged
1249    * @throws IOException if an error occurred on the coprocessor
1250    */
1251   public void preDispatchMerge(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1252       HRegionInfo regionA, HRegionInfo regionB) throws IOException;
1253   
1254   /**
1255    * called after dispatching the region merge request.
1256    * @param c coprocessor environment
1257    * @param regionA first region to be merged
1258    * @param regionB second region to be merged
1259    * @throws IOException if an error occurred on the coprocessor
1260    */
1261   void postDispatchMerge(final ObserverContext<MasterCoprocessorEnvironment> c,
1262       final HRegionInfo regionA, final HRegionInfo regionB) throws IOException;
1263 
1264   /**
1265    * Called before servers are moved to target region server group
1266    * @param ctx the environment to interact with the framework and master
1267    * @param servers set of servers to move
1268    * @param targetGroup destination group
1269    * @throws IOException on failure
1270    */
1271   void preMoveServers(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1272                       Set<HostAndPort> servers, String targetGroup) throws IOException;
1273 
1274   /**
1275    * Called after servers are moved to target region server group
1276    * @param ctx the environment to interact with the framework and master
1277    * @param servers set of servers to move
1278    * @param targetGroup name of group
1279    * @throws IOException on failure
1280    */
1281   void postMoveServers(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1282                        Set<HostAndPort> servers, String targetGroup) throws IOException;
1283 
1284   /**
1285    * Called before tables are moved to target region server group
1286    * @param ctx the environment to interact with the framework and master
1287    * @param tables set of tables to move
1288    * @param targetGroup name of group
1289    * @throws IOException on failure
1290    */
1291   void preMoveTables(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1292                      Set<TableName> tables, String targetGroup) throws IOException;
1293 
1294   /**
1295    * Called after servers are moved to target region server group
1296    * @param ctx the environment to interact with the framework and master
1297    * @param tables set of tables to move
1298    * @param targetGroup name of group
1299    * @throws IOException on failure
1300    */
1301   void postMoveTables(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1302                       Set<TableName> tables, String targetGroup) throws IOException;
1303 
1304   /**
1305    * Called before a new region server group is added
1306    * @param ctx the environment to interact with the framework and master
1307    * @param name group name
1308    * @throws IOException on failure
1309    */
1310   void preAddRSGroup(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1311                      String name) throws IOException;
1312 
1313   /**
1314    * Called after a new region server group is added
1315    * @param ctx the environment to interact with the framework and master
1316    * @param name group name
1317    * @throws IOException on failure
1318    */
1319   void postAddRSGroup(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1320                       String name) throws IOException;
1321 
1322   /**
1323    * Called before a region server group is removed
1324    * @param ctx the environment to interact with the framework and master
1325    * @param name group name
1326    * @throws IOException on failure
1327    */
1328   void preRemoveRSGroup(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1329                         String name) throws IOException;
1330 
1331   /**
1332    * Called after a region server group is removed
1333    * @param ctx the environment to interact with the framework and master
1334    * @param name group name
1335    * @throws IOException on failure
1336    */
1337   void postRemoveRSGroup(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1338                          String name) throws IOException;
1339 
1340   /**
1341    * Called before a region server group is removed
1342    * @param ctx the environment to interact with the framework and master
1343    * @param groupName group name
1344    * @throws IOException on failure
1345    */
1346   void preBalanceRSGroup(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1347                          String groupName) throws IOException;
1348 
1349   /**
1350    * Called after a region server group is removed
1351    * @param ctx the environment to interact with the framework and master
1352    * @param groupName group name
1353    * @throws IOException on failure
1354    */
1355   void postBalanceRSGroup(final ObserverContext<MasterCoprocessorEnvironment> ctx,
1356                           String groupName, boolean balancerRan) throws IOException;
1357 
1358 }