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