001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.master;
019
020import java.io.IOException;
021import java.lang.reflect.InvocationTargetException;
022import java.util.List;
023import java.util.Map;
024import java.util.Set;
025import org.apache.hadoop.conf.Configuration;
026import org.apache.hadoop.hbase.ClusterMetrics;
027import org.apache.hadoop.hbase.MetaMutationAnnotation;
028import org.apache.hadoop.hbase.NamespaceDescriptor;
029import org.apache.hadoop.hbase.ServerName;
030import org.apache.hadoop.hbase.TableName;
031import org.apache.hadoop.hbase.client.BalanceRequest;
032import org.apache.hadoop.hbase.client.BalanceResponse;
033import org.apache.hadoop.hbase.client.Connection;
034import org.apache.hadoop.hbase.client.MasterSwitchType;
035import org.apache.hadoop.hbase.client.Mutation;
036import org.apache.hadoop.hbase.client.RegionInfo;
037import org.apache.hadoop.hbase.client.SharedConnection;
038import org.apache.hadoop.hbase.client.SnapshotDescription;
039import org.apache.hadoop.hbase.client.TableDescriptor;
040import org.apache.hadoop.hbase.coprocessor.BaseEnvironment;
041import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
042import org.apache.hadoop.hbase.coprocessor.CoreCoprocessor;
043import org.apache.hadoop.hbase.coprocessor.HasMasterServices;
044import org.apache.hadoop.hbase.coprocessor.MasterCoprocessor;
045import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
046import org.apache.hadoop.hbase.coprocessor.MasterObserver;
047import org.apache.hadoop.hbase.coprocessor.MetricsCoprocessor;
048import org.apache.hadoop.hbase.coprocessor.ObserverRpcCallContext;
049import org.apache.hadoop.hbase.master.locking.LockProcedure;
050import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
051import org.apache.hadoop.hbase.metrics.MetricRegistry;
052import org.apache.hadoop.hbase.net.Address;
053import org.apache.hadoop.hbase.procedure2.LockType;
054import org.apache.hadoop.hbase.procedure2.LockedResource;
055import org.apache.hadoop.hbase.procedure2.Procedure;
056import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
057import org.apache.hadoop.hbase.quotas.GlobalQuotaSettings;
058import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
059import org.apache.hadoop.hbase.replication.SyncReplicationState;
060import org.apache.hadoop.hbase.security.User;
061import org.apache.hadoop.hbase.security.access.Permission;
062import org.apache.hadoop.hbase.security.access.UserPermission;
063import org.apache.yetus.audience.InterfaceAudience;
064import org.slf4j.Logger;
065import org.slf4j.LoggerFactory;
066
067import org.apache.hbase.thirdparty.com.google.protobuf.Service;
068
069/**
070 * Provides the coprocessor framework and environment for master oriented operations.
071 * {@link HMaster} interacts with the loaded coprocessors through this class.
072 */
073@InterfaceAudience.Private
074public class MasterCoprocessorHost
075  extends CoprocessorHost<MasterCoprocessor, MasterCoprocessorEnvironment> {
076
077  private static final Logger LOG = LoggerFactory.getLogger(MasterCoprocessorHost.class);
078
079  /**
080   * Coprocessor environment extension providing access to master related services.
081   */
082  private static class MasterEnvironment extends BaseEnvironment<MasterCoprocessor>
083    implements MasterCoprocessorEnvironment {
084    private final MetricRegistry metricRegistry;
085    private final MasterServices services;
086
087    public MasterEnvironment(final MasterCoprocessor impl, final int priority, final int seq,
088      final Configuration conf, final MasterServices services) {
089      super(impl, priority, seq, conf);
090      this.services = services;
091      this.metricRegistry =
092        MetricsCoprocessor.createRegistryForMasterCoprocessor(impl.getClass().getName());
093    }
094
095    @Override
096    public ServerName getServerName() {
097      return this.services.getServerName();
098    }
099
100    @Override
101    public Connection getConnection() {
102      return new SharedConnection(this.services.getConnection());
103    }
104
105    @Override
106    public Connection createConnection(Configuration conf) throws IOException {
107      return this.services.createConnection(conf);
108    }
109
110    @Override
111    public MetricRegistry getMetricRegistryForMaster() {
112      return metricRegistry;
113    }
114
115    @Override
116    public MasterServices getMasterServices() {
117      return services;
118    }
119
120    @Override
121    public void shutdown() {
122      super.shutdown();
123      MetricsCoprocessor.removeRegistry(this.metricRegistry);
124    }
125  }
126
127  /**
128   * Special version of MasterEnvironment that exposes MasterServices for Core Coprocessors only.
129   * Temporary hack until Core Coprocessors are integrated into Core.
130   */
131  private static class MasterEnvironmentForCoreCoprocessors extends MasterEnvironment
132    implements HasMasterServices {
133    private final MasterServices masterServices;
134
135    public MasterEnvironmentForCoreCoprocessors(final MasterCoprocessor impl, final int priority,
136      final int seq, final Configuration conf, final MasterServices services) {
137      super(impl, priority, seq, conf, services);
138      this.masterServices = services;
139    }
140
141    /**
142     * @return An instance of MasterServices, an object NOT for general user-space Coprocessor
143     *         consumption.
144     */
145    @Override
146    public MasterServices getMasterServices() {
147      return this.masterServices;
148    }
149  }
150
151  private MasterServices masterServices;
152
153  public MasterCoprocessorHost(final MasterServices services, final Configuration conf) {
154    super(services);
155    this.conf = conf;
156    this.masterServices = services;
157    // Log the state of coprocessor loading here; should appear only once or
158    // twice in the daemon log, depending on HBase version, because there is
159    // only one MasterCoprocessorHost instance in the master process
160    boolean coprocessorsEnabled =
161      conf.getBoolean(COPROCESSORS_ENABLED_CONF_KEY, DEFAULT_COPROCESSORS_ENABLED);
162    LOG.trace("System coprocessor loading is {}", (coprocessorsEnabled ? "enabled" : "disabled"));
163    loadSystemCoprocessors(conf, MASTER_COPROCESSOR_CONF_KEY);
164  }
165
166  @Override
167  public MasterEnvironment createEnvironment(final MasterCoprocessor instance, final int priority,
168    final int seq, final Configuration conf) {
169    // If coprocessor exposes any services, register them.
170    for (Service service : instance.getServices()) {
171      masterServices.registerService(service);
172    }
173    // If a CoreCoprocessor, return a 'richer' environment, one laden with MasterServices.
174    return instance.getClass().isAnnotationPresent(CoreCoprocessor.class)
175      ? new MasterEnvironmentForCoreCoprocessors(instance, priority, seq, conf, masterServices)
176      : new MasterEnvironment(instance, priority, seq, conf, masterServices);
177  }
178
179  @Override
180  public MasterCoprocessor checkAndGetInstance(Class<?> implClass)
181    throws InstantiationException, IllegalAccessException {
182    try {
183      if (MasterCoprocessor.class.isAssignableFrom(implClass)) {
184        return implClass.asSubclass(MasterCoprocessor.class).getDeclaredConstructor().newInstance();
185      } else {
186        LOG.error("{} is not of type MasterCoprocessor. Check the configuration of {}",
187          implClass.getName(), CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY);
188        return null;
189      }
190    } catch (NoSuchMethodException | InvocationTargetException e) {
191      throw (InstantiationException) new InstantiationException(implClass.getName()).initCause(e);
192    }
193  }
194
195  private ObserverGetter<MasterCoprocessor, MasterObserver> masterObserverGetter =
196    MasterCoprocessor::getMasterObserver;
197
198  abstract class MasterObserverOperation extends ObserverOperationWithoutResult<MasterObserver> {
199    public MasterObserverOperation() {
200      super(masterObserverGetter);
201    }
202
203    public MasterObserverOperation(boolean bypassable) {
204      this(null, bypassable);
205    }
206
207    public MasterObserverOperation(User user) {
208      super(masterObserverGetter, user);
209    }
210
211    public MasterObserverOperation(ObserverRpcCallContext rpcCallContext) {
212      super(masterObserverGetter, rpcCallContext);
213    }
214
215    public MasterObserverOperation(ObserverRpcCallContext rpcCallContext, boolean bypassable) {
216      super(masterObserverGetter, rpcCallContext, bypassable);
217    }
218  }
219
220  //////////////////////////////////////////////////////////////////////////////////////////////////
221  // MasterObserver operations
222  //////////////////////////////////////////////////////////////////////////////////////////////////
223
224  public void preCreateNamespace(final NamespaceDescriptor ns) throws IOException {
225    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
226      @Override
227      public void call(MasterObserver observer) throws IOException {
228        observer.preCreateNamespace(this, ns);
229      }
230    });
231  }
232
233  public void postCreateNamespace(final NamespaceDescriptor ns) throws IOException {
234    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
235      @Override
236      public void call(MasterObserver observer) throws IOException {
237        observer.postCreateNamespace(this, ns);
238      }
239    });
240  }
241
242  public void preDeleteNamespace(final String namespaceName) throws IOException {
243    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
244      @Override
245      public void call(MasterObserver observer) throws IOException {
246        observer.preDeleteNamespace(this, namespaceName);
247      }
248    });
249  }
250
251  public void postDeleteNamespace(final String namespaceName) throws IOException {
252    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
253      @Override
254      public void call(MasterObserver observer) throws IOException {
255        observer.postDeleteNamespace(this, namespaceName);
256      }
257    });
258  }
259
260  public void preModifyNamespace(final NamespaceDescriptor currentNsDescriptor,
261    final NamespaceDescriptor newNsDescriptor) throws IOException {
262    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
263      @Override
264      public void call(MasterObserver observer) throws IOException {
265        observer.preModifyNamespace(this, currentNsDescriptor, newNsDescriptor);
266      }
267    });
268  }
269
270  public void postModifyNamespace(final NamespaceDescriptor oldNsDescriptor,
271    final NamespaceDescriptor currentNsDescriptor) throws IOException {
272    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
273      @Override
274      public void call(MasterObserver observer) throws IOException {
275        observer.postModifyNamespace(this, oldNsDescriptor, currentNsDescriptor);
276      }
277    });
278  }
279
280  public void preGetNamespaceDescriptor(final String namespaceName) throws IOException {
281    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
282      @Override
283      public void call(MasterObserver observer) throws IOException {
284        observer.preGetNamespaceDescriptor(this, namespaceName);
285      }
286    });
287  }
288
289  public void postGetNamespaceDescriptor(final NamespaceDescriptor ns) throws IOException {
290    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
291      @Override
292      public void call(MasterObserver observer) throws IOException {
293        observer.postGetNamespaceDescriptor(this, ns);
294      }
295    });
296  }
297
298  public void preListNamespaces(final List<String> namespaces) throws IOException {
299    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
300      @Override
301      public void call(MasterObserver oserver) throws IOException {
302        oserver.preListNamespaces(this, namespaces);
303      }
304    });
305  }
306
307  public void postListNamespaces(final List<String> namespaces) throws IOException {
308    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
309      @Override
310      public void call(MasterObserver oserver) throws IOException {
311        oserver.postListNamespaces(this, namespaces);
312      }
313    });
314  }
315
316  public void preListNamespaceDescriptors(final List<NamespaceDescriptor> descriptors)
317    throws IOException {
318    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
319      @Override
320      public void call(MasterObserver observer) throws IOException {
321        observer.preListNamespaceDescriptors(this, descriptors);
322      }
323    });
324  }
325
326  public void postListNamespaceDescriptors(final List<NamespaceDescriptor> descriptors)
327    throws IOException {
328    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
329      @Override
330      public void call(MasterObserver observer) throws IOException {
331        observer.postListNamespaceDescriptors(this, descriptors);
332      }
333    });
334  }
335
336  /* Implementation of hooks for invoking MasterObservers */
337
338  public TableDescriptor preCreateTableRegionsInfos(TableDescriptor desc) throws IOException {
339    if (coprocEnvironments.isEmpty()) {
340      return desc;
341    }
342    return execOperationWithResult(
343      new ObserverOperationWithResult<MasterObserver, TableDescriptor>(masterObserverGetter, desc) {
344
345        @Override
346        protected TableDescriptor call(MasterObserver observer) throws IOException {
347          return observer.preCreateTableRegionsInfos(this, getResult());
348        }
349      });
350  }
351
352  public void preCreateTable(final TableDescriptor htd, final RegionInfo[] regions)
353    throws IOException {
354    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
355      @Override
356      public void call(MasterObserver observer) throws IOException {
357        observer.preCreateTable(this, htd, regions);
358      }
359    });
360  }
361
362  public void postCreateTable(final TableDescriptor htd, final RegionInfo[] regions)
363    throws IOException {
364    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
365      @Override
366      public void call(MasterObserver observer) throws IOException {
367        observer.postCreateTable(this, htd, regions);
368      }
369    });
370  }
371
372  public void preCreateTableAction(final TableDescriptor htd, final RegionInfo[] regions,
373    final User user) throws IOException {
374    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
375      @Override
376      public void call(MasterObserver observer) throws IOException {
377        observer.preCreateTableAction(this, htd, regions);
378      }
379    });
380  }
381
382  public void postCompletedCreateTableAction(final TableDescriptor htd, final RegionInfo[] regions,
383    final User user) throws IOException {
384    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
385      @Override
386      public void call(MasterObserver observer) throws IOException {
387        observer.postCompletedCreateTableAction(this, htd, regions);
388      }
389    });
390  }
391
392  public void preDeleteTable(final TableName tableName) throws IOException {
393    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
394      @Override
395      public void call(MasterObserver observer) throws IOException {
396        observer.preDeleteTable(this, tableName);
397      }
398    });
399  }
400
401  public void postDeleteTable(final TableName tableName) throws IOException {
402    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
403      @Override
404      public void call(MasterObserver observer) throws IOException {
405        observer.postDeleteTable(this, tableName);
406      }
407    });
408  }
409
410  public void preDeleteTableAction(final TableName tableName, final User user) throws IOException {
411    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
412      @Override
413      public void call(MasterObserver observer) throws IOException {
414        observer.preDeleteTableAction(this, tableName);
415      }
416    });
417  }
418
419  public void postCompletedDeleteTableAction(final TableName tableName, final User user)
420    throws IOException {
421    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
422      @Override
423      public void call(MasterObserver observer) throws IOException {
424        observer.postCompletedDeleteTableAction(this, tableName);
425      }
426    });
427  }
428
429  public void preTruncateTable(final TableName tableName) throws IOException {
430    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
431      @Override
432      public void call(MasterObserver observer) throws IOException {
433        observer.preTruncateTable(this, tableName);
434      }
435    });
436  }
437
438  public void postTruncateTable(final TableName tableName) throws IOException {
439    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
440      @Override
441      public void call(MasterObserver observer) throws IOException {
442        observer.postTruncateTable(this, tableName);
443      }
444    });
445  }
446
447  public void preTruncateTableAction(final TableName tableName, final User user)
448    throws IOException {
449    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
450      @Override
451      public void call(MasterObserver observer) throws IOException {
452        observer.preTruncateTableAction(this, tableName);
453      }
454    });
455  }
456
457  public void postCompletedTruncateTableAction(final TableName tableName, final User user)
458    throws IOException {
459    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
460      @Override
461      public void call(MasterObserver observer) throws IOException {
462        observer.postCompletedTruncateTableAction(this, tableName);
463      }
464    });
465  }
466
467  public TableDescriptor preModifyTable(final TableName tableName,
468    final TableDescriptor currentDescriptor, final TableDescriptor newDescriptor)
469    throws IOException {
470    if (coprocEnvironments.isEmpty()) {
471      return newDescriptor;
472    }
473    return execOperationWithResult(new ObserverOperationWithResult<MasterObserver, TableDescriptor>(
474      masterObserverGetter, newDescriptor) {
475      @Override
476      protected TableDescriptor call(MasterObserver observer) throws IOException {
477        return observer.preModifyTable(this, tableName, currentDescriptor, getResult());
478      }
479    });
480  }
481
482  public void postModifyTable(final TableName tableName, final TableDescriptor oldDescriptor,
483    final TableDescriptor currentDescriptor) throws IOException {
484    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
485      @Override
486      public void call(MasterObserver observer) throws IOException {
487        observer.postModifyTable(this, tableName, oldDescriptor, currentDescriptor);
488      }
489    });
490  }
491
492  public String preModifyTableStoreFileTracker(final TableName tableName, final String dstSFT)
493    throws IOException {
494    if (coprocEnvironments.isEmpty()) {
495      return dstSFT;
496    }
497    return execOperationWithResult(
498      new ObserverOperationWithResult<MasterObserver, String>(masterObserverGetter, dstSFT) {
499        @Override
500        protected String call(MasterObserver observer) throws IOException {
501          return observer.preModifyTableStoreFileTracker(this, tableName, getResult());
502        }
503      });
504  }
505
506  public void postModifyTableStoreFileTracker(final TableName tableName, final String dstSFT)
507    throws IOException {
508    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
509      @Override
510      public void call(MasterObserver observer) throws IOException {
511        observer.postModifyTableStoreFileTracker(this, tableName, dstSFT);
512      }
513    });
514  }
515
516  public String preModifyColumnFamilyStoreFileTracker(final TableName tableName,
517    final byte[] family, final String dstSFT) throws IOException {
518    if (coprocEnvironments.isEmpty()) {
519      return dstSFT;
520    }
521    return execOperationWithResult(
522      new ObserverOperationWithResult<MasterObserver, String>(masterObserverGetter, dstSFT) {
523        @Override
524        protected String call(MasterObserver observer) throws IOException {
525          return observer.preModifyColumnFamilyStoreFileTracker(this, tableName, family,
526            getResult());
527        }
528      });
529  }
530
531  public void postModifyColumnFamilyStoreFileTracker(final TableName tableName, final byte[] family,
532    final String dstSFT) throws IOException {
533    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
534      @Override
535      public void call(MasterObserver observer) throws IOException {
536        observer.postModifyColumnFamilyStoreFileTracker(this, tableName, family, dstSFT);
537      }
538    });
539  }
540
541  public void preModifyTableAction(final TableName tableName,
542    final TableDescriptor currentDescriptor, final TableDescriptor newDescriptor, final User user)
543    throws IOException {
544    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
545      @Override
546      public void call(MasterObserver observer) throws IOException {
547        observer.preModifyTableAction(this, tableName, currentDescriptor, newDescriptor);
548      }
549    });
550  }
551
552  public void postCompletedModifyTableAction(final TableName tableName,
553    final TableDescriptor oldDescriptor, final TableDescriptor currentDescriptor, final User user)
554    throws IOException {
555    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
556      @Override
557      public void call(MasterObserver observer) throws IOException {
558        observer.postCompletedModifyTableAction(this, tableName, oldDescriptor, currentDescriptor);
559      }
560    });
561  }
562
563  public void preEnableTable(final TableName tableName) throws IOException {
564    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
565      @Override
566      public void call(MasterObserver observer) throws IOException {
567        observer.preEnableTable(this, tableName);
568      }
569    });
570  }
571
572  public void postEnableTable(final TableName tableName) throws IOException {
573    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
574      @Override
575      public void call(MasterObserver observer) throws IOException {
576        observer.postEnableTable(this, tableName);
577      }
578    });
579  }
580
581  public void preEnableTableAction(final TableName tableName, final User user) throws IOException {
582    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
583      @Override
584      public void call(MasterObserver observer) throws IOException {
585        observer.preEnableTableAction(this, tableName);
586      }
587    });
588  }
589
590  public void postCompletedEnableTableAction(final TableName tableName, final User user)
591    throws IOException {
592    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
593      @Override
594      public void call(MasterObserver observer) throws IOException {
595        observer.postCompletedEnableTableAction(this, tableName);
596      }
597    });
598  }
599
600  public void preDisableTable(final TableName tableName) throws IOException {
601    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
602      @Override
603      public void call(MasterObserver observer) throws IOException {
604        observer.preDisableTable(this, tableName);
605      }
606    });
607  }
608
609  public void postDisableTable(final TableName tableName) throws IOException {
610    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
611      @Override
612      public void call(MasterObserver observer) throws IOException {
613        observer.postDisableTable(this, tableName);
614      }
615    });
616  }
617
618  public void preDisableTableAction(final TableName tableName, final User user) throws IOException {
619    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
620      @Override
621      public void call(MasterObserver observer) throws IOException {
622        observer.preDisableTableAction(this, tableName);
623      }
624    });
625  }
626
627  public void postCompletedDisableTableAction(final TableName tableName, final User user)
628    throws IOException {
629    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
630      @Override
631      public void call(MasterObserver observer) throws IOException {
632        observer.postCompletedDisableTableAction(this, tableName);
633      }
634    });
635  }
636
637  public void preAbortProcedure(final ProcedureExecutor<MasterProcedureEnv> procEnv,
638    final long procId) throws IOException {
639    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
640      @Override
641      public void call(MasterObserver observer) throws IOException {
642        observer.preAbortProcedure(this, procId);
643      }
644    });
645  }
646
647  public void postAbortProcedure() throws IOException {
648    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
649      @Override
650      public void call(MasterObserver observer) throws IOException {
651        observer.postAbortProcedure(this);
652      }
653    });
654  }
655
656  public void preGetProcedures() throws IOException {
657    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
658      @Override
659      public void call(MasterObserver observer) throws IOException {
660        observer.preGetProcedures(this);
661      }
662    });
663  }
664
665  public void postGetProcedures(final List<Procedure<?>> procInfoList) throws IOException {
666    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
667      @Override
668      public void call(MasterObserver observer) throws IOException {
669        observer.postGetProcedures(this);
670      }
671    });
672  }
673
674  public void preGetLocks() throws IOException {
675    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
676      @Override
677      public void call(MasterObserver observer) throws IOException {
678        observer.preGetLocks(this);
679      }
680    });
681  }
682
683  public void postGetLocks(final List<LockedResource> lockedResources) throws IOException {
684    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
685      @Override
686      public void call(MasterObserver observer) throws IOException {
687        observer.postGetLocks(this);
688      }
689    });
690  }
691
692  public void preMove(final RegionInfo region, final ServerName srcServer,
693    final ServerName destServer) throws IOException {
694    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
695      @Override
696      public void call(MasterObserver observer) throws IOException {
697        observer.preMove(this, region, srcServer, destServer);
698      }
699    });
700  }
701
702  public void postMove(final RegionInfo region, final ServerName srcServer,
703    final ServerName destServer) throws IOException {
704    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
705      @Override
706      public void call(MasterObserver observer) throws IOException {
707        observer.postMove(this, region, srcServer, destServer);
708      }
709    });
710  }
711
712  public void preAssign(final RegionInfo regionInfo) throws IOException {
713    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
714      @Override
715      public void call(MasterObserver observer) throws IOException {
716        observer.preAssign(this, regionInfo);
717      }
718    });
719  }
720
721  public void postAssign(final RegionInfo regionInfo) throws IOException {
722    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
723      @Override
724      public void call(MasterObserver observer) throws IOException {
725        observer.postAssign(this, regionInfo);
726      }
727    });
728  }
729
730  public void preUnassign(final RegionInfo regionInfo) throws IOException {
731    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
732      @Override
733      public void call(MasterObserver observer) throws IOException {
734        observer.preUnassign(this, regionInfo);
735      }
736    });
737  }
738
739  public void postUnassign(final RegionInfo regionInfo) throws IOException {
740    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
741      @Override
742      public void call(MasterObserver observer) throws IOException {
743        observer.postUnassign(this, regionInfo);
744      }
745    });
746  }
747
748  public void preRegionOffline(final RegionInfo regionInfo) throws IOException {
749    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
750      @Override
751      public void call(MasterObserver observer) throws IOException {
752        observer.preRegionOffline(this, regionInfo);
753      }
754    });
755  }
756
757  public void postRegionOffline(final RegionInfo regionInfo) throws IOException {
758    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
759      @Override
760      public void call(MasterObserver observer) throws IOException {
761        observer.postRegionOffline(this, regionInfo);
762      }
763    });
764  }
765
766  public void preMergeRegions(final RegionInfo[] regionsToMerge) throws IOException {
767    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
768      @Override
769      public void call(MasterObserver observer) throws IOException {
770        observer.preMergeRegions(this, regionsToMerge);
771      }
772    });
773  }
774
775  public void postMergeRegions(final RegionInfo[] regionsToMerge) throws IOException {
776    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
777      @Override
778      public void call(MasterObserver observer) throws IOException {
779        observer.postMergeRegions(this, regionsToMerge);
780      }
781    });
782  }
783
784  public boolean preBalance(final BalanceRequest request) throws IOException {
785    return execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
786      @Override
787      public void call(MasterObserver observer) throws IOException {
788        observer.preBalance(this, request);
789      }
790    });
791  }
792
793  public void postBalance(final BalanceRequest request, final List<RegionPlan> plans)
794    throws IOException {
795    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
796      @Override
797      public void call(MasterObserver observer) throws IOException {
798        observer.postBalance(this, request, plans);
799      }
800    });
801  }
802
803  public void preSetSplitOrMergeEnabled(final boolean newValue, final MasterSwitchType switchType)
804    throws IOException {
805    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
806      @Override
807      public void call(MasterObserver observer) throws IOException {
808        observer.preSetSplitOrMergeEnabled(this, newValue, switchType);
809      }
810    });
811  }
812
813  public void postSetSplitOrMergeEnabled(final boolean newValue, final MasterSwitchType switchType)
814    throws IOException {
815    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
816      @Override
817      public void call(MasterObserver observer) throws IOException {
818        observer.postSetSplitOrMergeEnabled(this, newValue, switchType);
819      }
820    });
821  }
822
823  /**
824   * Invoked just before calling the split region procedure
825   * @param tableName the table where the region belongs to
826   * @param splitRow  the split point
827   */
828  public void preSplitRegion(final TableName tableName, final byte[] splitRow) throws IOException {
829    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
830      @Override
831      public void call(MasterObserver observer) throws IOException {
832        observer.preSplitRegion(this, tableName, splitRow);
833      }
834    });
835  }
836
837  /**
838   * Invoked just before a split
839   * @param tableName the table where the region belongs to
840   * @param splitRow  the split point
841   * @param user      the user
842   */
843  public void preSplitRegionAction(final TableName tableName, final byte[] splitRow,
844    final User user) throws IOException {
845    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
846      @Override
847      public void call(MasterObserver observer) throws IOException {
848        observer.preSplitRegionAction(this, tableName, splitRow);
849      }
850    });
851  }
852
853  /**
854   * Invoked just after a split
855   * @param regionInfoA the new left-hand daughter region
856   * @param regionInfoB the new right-hand daughter region
857   * @param user        the user
858   */
859  public void postCompletedSplitRegionAction(final RegionInfo regionInfoA,
860    final RegionInfo regionInfoB, final User user) throws IOException {
861    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
862      @Override
863      public void call(MasterObserver observer) throws IOException {
864        observer.postCompletedSplitRegionAction(this, regionInfoA, regionInfoB);
865      }
866    });
867  }
868
869  /**
870   * Invoked just before calling the truncate region procedure
871   * @param regionInfo region being truncated
872   */
873  public void preTruncateRegion(RegionInfo regionInfo) throws IOException {
874    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
875      @Override
876      public void call(MasterObserver observer) {
877        observer.preTruncateRegion(this, regionInfo);
878      }
879    });
880  }
881
882  /**
883   * Invoked after calling the truncate region procedure
884   * @param regionInfo region being truncated
885   */
886  public void postTruncateRegion(RegionInfo regionInfo) throws IOException {
887    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
888      @Override
889      public void call(MasterObserver observer) {
890        observer.postTruncateRegion(this, regionInfo);
891      }
892    });
893  }
894
895  /**
896   * Invoked just before calling the truncate region procedure
897   * @param region Region to be truncated
898   * @param user   The user
899   */
900  public void preTruncateRegionAction(final RegionInfo region, User user) throws IOException {
901    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
902      @Override
903      public void call(MasterObserver observer) throws IOException {
904        observer.preTruncateRegionAction(this, region);
905      }
906    });
907  }
908
909  /**
910   * Invoked after calling the truncate region procedure
911   * @param region Region which was truncated
912   * @param user   The user
913   */
914  public void postTruncateRegionAction(final RegionInfo region, User user) throws IOException {
915    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
916      @Override
917      public void call(MasterObserver observer) throws IOException {
918        observer.postTruncateRegionAction(this, region);
919      }
920    });
921  }
922
923  /**
924   * This will be called before update META step as part of split table region procedure.
925   * @param user the user
926   */
927  public void preSplitBeforeMETAAction(final byte[] splitKey, final List<Mutation> metaEntries,
928    final User user) throws IOException {
929    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
930      @Override
931      public void call(MasterObserver observer) throws IOException {
932        observer.preSplitRegionBeforeMETAAction(this, splitKey, metaEntries);
933      }
934    });
935  }
936
937  /**
938   * This will be called after update META step as part of split table region procedure.
939   * @param user the user
940   */
941  public void preSplitAfterMETAAction(final User user) throws IOException {
942    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
943      @Override
944      public void call(MasterObserver observer) throws IOException {
945        observer.preSplitRegionAfterMETAAction(this);
946      }
947    });
948  }
949
950  /**
951   * Invoked just after the rollback of a failed split
952   * @param user the user
953   */
954  public void postRollBackSplitRegionAction(final User user) throws IOException {
955    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
956      @Override
957      public void call(MasterObserver observer) throws IOException {
958        observer.postRollBackSplitRegionAction(this);
959      }
960    });
961  }
962
963  /**
964   * Invoked just before a merge
965   * @param regionsToMerge the regions to merge
966   * @param user           the user
967   */
968  public void preMergeRegionsAction(final RegionInfo[] regionsToMerge, final User user)
969    throws IOException {
970    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
971      @Override
972      public void call(MasterObserver observer) throws IOException {
973        observer.preMergeRegionsAction(this, regionsToMerge);
974      }
975    });
976  }
977
978  /**
979   * Invoked after completing merge regions operation
980   * @param regionsToMerge the regions to merge
981   * @param mergedRegion   the new merged region
982   * @param user           the user
983   */
984  public void postCompletedMergeRegionsAction(final RegionInfo[] regionsToMerge,
985    final RegionInfo mergedRegion, final User user) throws IOException {
986    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
987      @Override
988      public void call(MasterObserver observer) throws IOException {
989        observer.postCompletedMergeRegionsAction(this, regionsToMerge, mergedRegion);
990      }
991    });
992  }
993
994  /**
995   * Invoked before merge regions operation writes the new region to hbase:meta
996   * @param regionsToMerge the regions to merge
997   * @param metaEntries    the meta entry
998   * @param user           the user
999   */
1000  public void preMergeRegionsCommit(final RegionInfo[] regionsToMerge,
1001    final @MetaMutationAnnotation List<Mutation> metaEntries, final User user) throws IOException {
1002    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
1003      @Override
1004      public void call(MasterObserver observer) throws IOException {
1005        observer.preMergeRegionsCommitAction(this, regionsToMerge, metaEntries);
1006      }
1007    });
1008  }
1009
1010  /**
1011   * Invoked after merge regions operation writes the new region to hbase:meta
1012   * @param regionsToMerge the regions to merge
1013   * @param mergedRegion   the new merged region
1014   * @param user           the user
1015   */
1016  public void postMergeRegionsCommit(final RegionInfo[] regionsToMerge,
1017    final RegionInfo mergedRegion, final User user) throws IOException {
1018    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
1019      @Override
1020      public void call(MasterObserver observer) throws IOException {
1021        observer.postMergeRegionsCommitAction(this, regionsToMerge, mergedRegion);
1022      }
1023    });
1024  }
1025
1026  /**
1027   * Invoked after rollback merge regions operation
1028   * @param regionsToMerge the regions to merge
1029   * @param user           the user
1030   */
1031  public void postRollBackMergeRegionsAction(final RegionInfo[] regionsToMerge, final User user)
1032    throws IOException {
1033    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
1034      @Override
1035      public void call(MasterObserver observer) throws IOException {
1036        observer.postRollBackMergeRegionsAction(this, regionsToMerge);
1037      }
1038    });
1039  }
1040
1041  // This hook allows Coprocessor change value of balance switch.
1042  public void preBalanceSwitch(final boolean b) throws IOException {
1043    if (this.coprocEnvironments.isEmpty()) {
1044      return;
1045    }
1046    execOperation(new MasterObserverOperation() {
1047      @Override
1048      public void call(MasterObserver observer) throws IOException {
1049        observer.preBalanceSwitch(this, b);
1050      }
1051    });
1052  }
1053
1054  public void postBalanceSwitch(final boolean oldValue, final boolean newValue) throws IOException {
1055    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1056      @Override
1057      public void call(MasterObserver observer) throws IOException {
1058        observer.postBalanceSwitch(this, oldValue, newValue);
1059      }
1060    });
1061  }
1062
1063  public void preShutdown() throws IOException {
1064    // While stopping the cluster all coprocessors method should be executed first then the
1065    // coprocessor should be cleaned up.
1066    if (coprocEnvironments.isEmpty()) {
1067      return;
1068    }
1069    execShutdown(new MasterObserverOperation() {
1070      @Override
1071      public void call(MasterObserver observer) throws IOException {
1072        observer.preShutdown(this);
1073      }
1074
1075      @Override
1076      public void postEnvCall() {
1077        // invoke coprocessor stop method
1078        shutdown(this.getEnvironment());
1079      }
1080    });
1081  }
1082
1083  public void preStopMaster() throws IOException {
1084    // While stopping master all coprocessors method should be executed first then the coprocessor
1085    // environment should be cleaned up.
1086    if (coprocEnvironments.isEmpty()) {
1087      return;
1088    }
1089    execShutdown(new MasterObserverOperation() {
1090      @Override
1091      public void call(MasterObserver observer) throws IOException {
1092        observer.preStopMaster(this);
1093      }
1094
1095      @Override
1096      public void postEnvCall() {
1097        // invoke coprocessor stop method
1098        shutdown(this.getEnvironment());
1099      }
1100    });
1101  }
1102
1103  public void preMasterInitialization() throws IOException {
1104    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1105      @Override
1106      public void call(MasterObserver observer) throws IOException {
1107        observer.preMasterInitialization(this);
1108      }
1109    });
1110  }
1111
1112  public void postStartMaster() throws IOException {
1113    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1114      @Override
1115      public void call(MasterObserver observer) throws IOException {
1116        observer.postStartMaster(this);
1117      }
1118    });
1119  }
1120
1121  public void preSnapshot(final SnapshotDescription snapshot,
1122    final TableDescriptor hTableDescriptor, final User user) throws IOException {
1123    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
1124      @Override
1125      public void call(MasterObserver observer) throws IOException {
1126        observer.preSnapshot(this, snapshot, hTableDescriptor);
1127      }
1128    });
1129  }
1130
1131  public void postSnapshot(final SnapshotDescription snapshot,
1132    final TableDescriptor hTableDescriptor, final User user) throws IOException {
1133    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
1134      @Override
1135      public void call(MasterObserver observer) throws IOException {
1136        observer.postSnapshot(this, snapshot, hTableDescriptor);
1137      }
1138    });
1139  }
1140
1141  public void postCompletedSnapshotAction(SnapshotDescription snapshot,
1142    TableDescriptor hTableDescriptor) throws IOException {
1143    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1144      @Override
1145      public void call(MasterObserver observer) throws IOException {
1146        observer.postCompletedSnapshotAction(this, snapshot, hTableDescriptor);
1147      }
1148    });
1149  }
1150
1151  public void preListSnapshot(final SnapshotDescription snapshot) throws IOException {
1152    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1153      @Override
1154      public void call(MasterObserver observer) throws IOException {
1155        observer.preListSnapshot(this, snapshot);
1156      }
1157    });
1158  }
1159
1160  public void postListSnapshot(final SnapshotDescription snapshot) throws IOException {
1161    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1162      @Override
1163      public void call(MasterObserver observer) throws IOException {
1164        observer.postListSnapshot(this, snapshot);
1165      }
1166    });
1167  }
1168
1169  public void preCloneSnapshot(final SnapshotDescription snapshot,
1170    final TableDescriptor hTableDescriptor) throws IOException {
1171    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1172      @Override
1173      public void call(MasterObserver observer) throws IOException {
1174        observer.preCloneSnapshot(this, snapshot, hTableDescriptor);
1175      }
1176    });
1177  }
1178
1179  public void postCloneSnapshot(final SnapshotDescription snapshot,
1180    final TableDescriptor hTableDescriptor) throws IOException {
1181    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1182      @Override
1183      public void call(MasterObserver observer) throws IOException {
1184        observer.postCloneSnapshot(this, snapshot, hTableDescriptor);
1185      }
1186    });
1187  }
1188
1189  public void preRestoreSnapshot(final SnapshotDescription snapshot,
1190    final TableDescriptor hTableDescriptor) throws IOException {
1191    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1192      @Override
1193      public void call(MasterObserver observer) throws IOException {
1194        observer.preRestoreSnapshot(this, snapshot, hTableDescriptor);
1195      }
1196    });
1197  }
1198
1199  public void postRestoreSnapshot(final SnapshotDescription snapshot,
1200    final TableDescriptor hTableDescriptor) throws IOException {
1201    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1202      @Override
1203      public void call(MasterObserver observer) throws IOException {
1204        observer.postRestoreSnapshot(this, snapshot, hTableDescriptor);
1205      }
1206    });
1207  }
1208
1209  public void preDeleteSnapshot(final SnapshotDescription snapshot) throws IOException {
1210    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1211      @Override
1212      public void call(MasterObserver observer) throws IOException {
1213        observer.preDeleteSnapshot(this, snapshot);
1214      }
1215    });
1216  }
1217
1218  public void postDeleteSnapshot(final SnapshotDescription snapshot) throws IOException {
1219    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1220      @Override
1221      public void call(MasterObserver observer) throws IOException {
1222        observer.postDeleteSnapshot(this, snapshot);
1223      }
1224    });
1225  }
1226
1227  public void preGetTableDescriptors(final List<TableName> tableNamesList,
1228    final List<TableDescriptor> descriptors, final String regex) throws IOException {
1229    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1230      @Override
1231      public void call(MasterObserver observer) throws IOException {
1232        observer.preGetTableDescriptors(this, tableNamesList, descriptors, regex);
1233      }
1234    });
1235  }
1236
1237  public void postGetTableDescriptors(final List<TableName> tableNamesList,
1238    final List<TableDescriptor> descriptors, final String regex) throws IOException {
1239    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1240      @Override
1241      public void call(MasterObserver observer) throws IOException {
1242        observer.postGetTableDescriptors(this, tableNamesList, descriptors, regex);
1243      }
1244    });
1245  }
1246
1247  public void preGetTableNames(final List<TableDescriptor> descriptors, final String regex)
1248    throws IOException {
1249    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1250      @Override
1251      public void call(MasterObserver observer) throws IOException {
1252        observer.preGetTableNames(this, descriptors, regex);
1253      }
1254    });
1255  }
1256
1257  public void postGetTableNames(final List<TableDescriptor> descriptors, final String regex)
1258    throws IOException {
1259    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1260      @Override
1261      public void call(MasterObserver observer) throws IOException {
1262        observer.postGetTableNames(this, descriptors, regex);
1263      }
1264    });
1265  }
1266
1267  public void preTableFlush(final TableName tableName) throws IOException {
1268    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1269      @Override
1270      public void call(MasterObserver observer) throws IOException {
1271        observer.preTableFlush(this, tableName);
1272      }
1273    });
1274  }
1275
1276  public void postTableFlush(final TableName tableName) throws IOException {
1277    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1278      @Override
1279      public void call(MasterObserver observer) throws IOException {
1280        observer.postTableFlush(this, tableName);
1281      }
1282    });
1283  }
1284
1285  public void preMasterStoreFlush() throws IOException {
1286    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1287      @Override
1288      public void call(MasterObserver observer) throws IOException {
1289        observer.preMasterStoreFlush(this);
1290      }
1291    });
1292  }
1293
1294  public void postMasterStoreFlush() throws IOException {
1295    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1296      @Override
1297      public void call(MasterObserver observer) throws IOException {
1298        observer.postMasterStoreFlush(this);
1299      }
1300    });
1301  }
1302
1303  public void preSetUserQuota(final String user, final GlobalQuotaSettings quotas)
1304    throws IOException {
1305    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1306      @Override
1307      public void call(MasterObserver observer) throws IOException {
1308        observer.preSetUserQuota(this, user, quotas);
1309      }
1310    });
1311  }
1312
1313  public void postSetUserQuota(final String user, final GlobalQuotaSettings quotas)
1314    throws IOException {
1315    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1316      @Override
1317      public void call(MasterObserver observer) throws IOException {
1318        observer.postSetUserQuota(this, user, quotas);
1319      }
1320    });
1321  }
1322
1323  public void preSetUserQuota(final String user, final TableName table,
1324    final GlobalQuotaSettings quotas) throws IOException {
1325    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1326      @Override
1327      public void call(MasterObserver observer) throws IOException {
1328        observer.preSetUserQuota(this, user, table, quotas);
1329      }
1330    });
1331  }
1332
1333  public void postSetUserQuota(final String user, final TableName table,
1334    final GlobalQuotaSettings quotas) throws IOException {
1335    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1336      @Override
1337      public void call(MasterObserver observer) throws IOException {
1338        observer.postSetUserQuota(this, user, table, quotas);
1339      }
1340    });
1341  }
1342
1343  public void preSetUserQuota(final String user, final String namespace,
1344    final GlobalQuotaSettings quotas) throws IOException {
1345    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1346      @Override
1347      public void call(MasterObserver observer) throws IOException {
1348        observer.preSetUserQuota(this, user, namespace, quotas);
1349      }
1350    });
1351  }
1352
1353  public void postSetUserQuota(final String user, final String namespace,
1354    final GlobalQuotaSettings quotas) throws IOException {
1355    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1356      @Override
1357      public void call(MasterObserver observer) throws IOException {
1358        observer.postSetUserQuota(this, user, namespace, quotas);
1359      }
1360    });
1361  }
1362
1363  public void preSetTableQuota(final TableName table, final GlobalQuotaSettings quotas)
1364    throws IOException {
1365    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1366      @Override
1367      public void call(MasterObserver observer) throws IOException {
1368        observer.preSetTableQuota(this, table, quotas);
1369      }
1370    });
1371  }
1372
1373  public void postSetTableQuota(final TableName table, final GlobalQuotaSettings quotas)
1374    throws IOException {
1375    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1376      @Override
1377      public void call(MasterObserver observer) throws IOException {
1378        observer.postSetTableQuota(this, table, quotas);
1379      }
1380    });
1381  }
1382
1383  public void preSetNamespaceQuota(final String namespace, final GlobalQuotaSettings quotas)
1384    throws IOException {
1385    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1386      @Override
1387      public void call(MasterObserver observer) throws IOException {
1388        observer.preSetNamespaceQuota(this, namespace, quotas);
1389      }
1390    });
1391  }
1392
1393  public void postSetNamespaceQuota(final String namespace, final GlobalQuotaSettings quotas)
1394    throws IOException {
1395    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1396      @Override
1397      public void call(MasterObserver observer) throws IOException {
1398        observer.postSetNamespaceQuota(this, namespace, quotas);
1399      }
1400    });
1401  }
1402
1403  public void preSetRegionServerQuota(final String regionServer, final GlobalQuotaSettings quotas)
1404    throws IOException {
1405    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1406      @Override
1407      public void call(MasterObserver observer) throws IOException {
1408        observer.preSetRegionServerQuota(this, regionServer, quotas);
1409      }
1410    });
1411  }
1412
1413  public void postSetRegionServerQuota(final String regionServer, final GlobalQuotaSettings quotas)
1414    throws IOException {
1415    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1416      @Override
1417      public void call(MasterObserver observer) throws IOException {
1418        observer.postSetRegionServerQuota(this, regionServer, quotas);
1419      }
1420    });
1421  }
1422
1423  public void preMoveServersAndTables(final Set<Address> servers, final Set<TableName> tables,
1424    final String targetGroup) throws IOException {
1425    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1426      @Override
1427      public void call(MasterObserver observer) throws IOException {
1428        observer.preMoveServersAndTables(this, servers, tables, targetGroup);
1429      }
1430    });
1431  }
1432
1433  public void postMoveServersAndTables(final Set<Address> servers, final Set<TableName> tables,
1434    final String targetGroup) throws IOException {
1435    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1436      @Override
1437      public void call(MasterObserver observer) throws IOException {
1438        observer.postMoveServersAndTables(this, servers, tables, targetGroup);
1439      }
1440    });
1441  }
1442
1443  public void preMoveServers(final Set<Address> servers, final String targetGroup)
1444    throws IOException {
1445    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1446      @Override
1447      public void call(MasterObserver observer) throws IOException {
1448        observer.preMoveServers(this, servers, targetGroup);
1449      }
1450    });
1451  }
1452
1453  public void postMoveServers(final Set<Address> servers, final String targetGroup)
1454    throws IOException {
1455    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1456      @Override
1457      public void call(MasterObserver observer) throws IOException {
1458        observer.postMoveServers(this, servers, targetGroup);
1459      }
1460    });
1461  }
1462
1463  public void preMoveTables(final Set<TableName> tables, final String targetGroup)
1464    throws IOException {
1465    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1466      @Override
1467      public void call(MasterObserver observer) throws IOException {
1468        observer.preMoveTables(this, tables, targetGroup);
1469      }
1470    });
1471  }
1472
1473  public void postMoveTables(final Set<TableName> tables, final String targetGroup)
1474    throws IOException {
1475    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1476      @Override
1477      public void call(MasterObserver observer) throws IOException {
1478        observer.postMoveTables(this, tables, targetGroup);
1479      }
1480    });
1481  }
1482
1483  public void preAddRSGroup(final String name) throws IOException {
1484    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1485      @Override
1486      public void call(MasterObserver observer) throws IOException {
1487        observer.preAddRSGroup(this, name);
1488      }
1489    });
1490  }
1491
1492  public void postAddRSGroup(final String name) throws IOException {
1493    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1494      @Override
1495      public void call(MasterObserver observer) throws IOException {
1496        observer.postAddRSGroup(this, name);
1497      }
1498    });
1499  }
1500
1501  public void preRemoveRSGroup(final String name) throws IOException {
1502    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1503      @Override
1504      public void call(MasterObserver observer) throws IOException {
1505        observer.preRemoveRSGroup(this, name);
1506      }
1507    });
1508  }
1509
1510  public void postRemoveRSGroup(final String name) throws IOException {
1511    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1512      @Override
1513      public void call(MasterObserver observer) throws IOException {
1514        observer.postRemoveRSGroup(this, name);
1515      }
1516    });
1517  }
1518
1519  public void preBalanceRSGroup(final String name, final BalanceRequest request)
1520    throws IOException {
1521    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1522      @Override
1523      public void call(MasterObserver observer) throws IOException {
1524        observer.preBalanceRSGroup(this, name, request);
1525      }
1526    });
1527  }
1528
1529  public void postBalanceRSGroup(final String name, final BalanceRequest request,
1530    final BalanceResponse response) throws IOException {
1531    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1532      @Override
1533      public void call(MasterObserver observer) throws IOException {
1534        observer.postBalanceRSGroup(this, name, request, response);
1535      }
1536    });
1537  }
1538
1539  public void preRemoveServers(final Set<Address> servers) throws IOException {
1540    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1541      @Override
1542      public void call(MasterObserver observer) throws IOException {
1543        observer.preRemoveServers(this, servers);
1544      }
1545    });
1546  }
1547
1548  public void postRemoveServers(final Set<Address> servers) throws IOException {
1549    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1550      @Override
1551      public void call(MasterObserver observer) throws IOException {
1552        observer.postRemoveServers(this, servers);
1553      }
1554    });
1555  }
1556
1557  public void preGetRSGroupInfo(final String groupName) throws IOException {
1558    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1559      @Override
1560      public void call(MasterObserver observer) throws IOException {
1561        observer.preGetRSGroupInfo(this, groupName);
1562      }
1563    });
1564  }
1565
1566  public void postGetRSGroupInfo(final String groupName) throws IOException {
1567    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1568      @Override
1569      public void call(MasterObserver observer) throws IOException {
1570        observer.postGetRSGroupInfo(this, groupName);
1571      }
1572    });
1573  }
1574
1575  public void preGetRSGroupInfoOfTable(final TableName tableName) throws IOException {
1576    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1577      @Override
1578      public void call(MasterObserver observer) throws IOException {
1579        observer.preGetRSGroupInfoOfTable(this, tableName);
1580      }
1581    });
1582  }
1583
1584  public void postGetRSGroupInfoOfTable(final TableName tableName) throws IOException {
1585    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1586      @Override
1587      public void call(MasterObserver observer) throws IOException {
1588        observer.postGetRSGroupInfoOfTable(this, tableName);
1589      }
1590    });
1591  }
1592
1593  public void preListRSGroups() throws IOException {
1594    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1595      @Override
1596      public void call(MasterObserver observer) throws IOException {
1597        observer.preListRSGroups(this);
1598      }
1599    });
1600  }
1601
1602  public void postListRSGroups() throws IOException {
1603    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1604      @Override
1605      public void call(MasterObserver observer) throws IOException {
1606        observer.postListRSGroups(this);
1607      }
1608    });
1609  }
1610
1611  public void preListTablesInRSGroup(final String groupName) throws IOException {
1612    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1613
1614      @Override
1615      protected void call(MasterObserver observer) throws IOException {
1616        observer.preListTablesInRSGroup(this, groupName);
1617      }
1618    });
1619  }
1620
1621  public void postListTablesInRSGroup(final String groupName) throws IOException {
1622    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1623
1624      @Override
1625      protected void call(MasterObserver observer) throws IOException {
1626        observer.postListTablesInRSGroup(this, groupName);
1627      }
1628    });
1629  }
1630
1631  public void preRenameRSGroup(final String oldName, final String newName) throws IOException {
1632    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1633
1634      @Override
1635      protected void call(MasterObserver observer) throws IOException {
1636        observer.preRenameRSGroup(this, oldName, newName);
1637      }
1638    });
1639  }
1640
1641  public void postRenameRSGroup(final String oldName, final String newName) throws IOException {
1642    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1643
1644      @Override
1645      protected void call(MasterObserver observer) throws IOException {
1646        observer.postRenameRSGroup(this, oldName, newName);
1647      }
1648    });
1649  }
1650
1651  public void preUpdateRSGroupConfig(final String groupName,
1652    final Map<String, String> configuration) throws IOException {
1653    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1654      @Override
1655      protected void call(MasterObserver observer) throws IOException {
1656        observer.preUpdateRSGroupConfig(this, groupName, configuration);
1657      }
1658    });
1659  }
1660
1661  public void postUpdateRSGroupConfig(final String groupName,
1662    final Map<String, String> configuration) throws IOException {
1663    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1664      @Override
1665      protected void call(MasterObserver observer) throws IOException {
1666        observer.postUpdateRSGroupConfig(this, groupName, configuration);
1667      }
1668    });
1669  }
1670
1671  public void preGetConfiguredNamespacesAndTablesInRSGroup(final String groupName)
1672    throws IOException {
1673    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1674
1675      @Override
1676      protected void call(MasterObserver observer) throws IOException {
1677        observer.preGetConfiguredNamespacesAndTablesInRSGroup(this, groupName);
1678      }
1679    });
1680  }
1681
1682  public void postGetConfiguredNamespacesAndTablesInRSGroup(final String groupName)
1683    throws IOException {
1684    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1685
1686      @Override
1687      protected void call(MasterObserver observer) throws IOException {
1688        observer.postGetConfiguredNamespacesAndTablesInRSGroup(this, groupName);
1689      }
1690    });
1691  }
1692
1693  public void preGetRSGroupInfoOfServer(final Address server) throws IOException {
1694    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1695      @Override
1696      public void call(MasterObserver observer) throws IOException {
1697        observer.preGetRSGroupInfoOfServer(this, server);
1698      }
1699    });
1700  }
1701
1702  public void postGetRSGroupInfoOfServer(final Address server) throws IOException {
1703    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1704      @Override
1705      public void call(MasterObserver observer) throws IOException {
1706        observer.postGetRSGroupInfoOfServer(this, server);
1707      }
1708    });
1709  }
1710
1711  public void preAddReplicationPeer(final String peerId, final ReplicationPeerConfig peerConfig)
1712    throws IOException {
1713    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1714      @Override
1715      public void call(MasterObserver observer) throws IOException {
1716        observer.preAddReplicationPeer(this, peerId, peerConfig);
1717      }
1718    });
1719  }
1720
1721  public void postAddReplicationPeer(final String peerId, final ReplicationPeerConfig peerConfig)
1722    throws IOException {
1723    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1724      @Override
1725      public void call(MasterObserver observer) throws IOException {
1726        observer.postAddReplicationPeer(this, peerId, peerConfig);
1727      }
1728    });
1729  }
1730
1731  public void preRemoveReplicationPeer(final String peerId) throws IOException {
1732    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1733      @Override
1734      public void call(MasterObserver observer) throws IOException {
1735        observer.preRemoveReplicationPeer(this, peerId);
1736      }
1737    });
1738  }
1739
1740  public void postRemoveReplicationPeer(final String peerId) throws IOException {
1741    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1742      @Override
1743      public void call(MasterObserver observer) throws IOException {
1744        observer.postRemoveReplicationPeer(this, peerId);
1745      }
1746    });
1747  }
1748
1749  public void preEnableReplicationPeer(final String peerId) throws IOException {
1750    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1751      @Override
1752      public void call(MasterObserver observer) throws IOException {
1753        observer.preEnableReplicationPeer(this, peerId);
1754      }
1755    });
1756  }
1757
1758  public void postEnableReplicationPeer(final String peerId) throws IOException {
1759    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1760      @Override
1761      public void call(MasterObserver observer) throws IOException {
1762        observer.postEnableReplicationPeer(this, peerId);
1763      }
1764    });
1765  }
1766
1767  public void preDisableReplicationPeer(final String peerId) throws IOException {
1768    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1769      @Override
1770      public void call(MasterObserver observer) throws IOException {
1771        observer.preDisableReplicationPeer(this, peerId);
1772      }
1773    });
1774  }
1775
1776  public void postDisableReplicationPeer(final String peerId) throws IOException {
1777    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1778      @Override
1779      public void call(MasterObserver observer) throws IOException {
1780        observer.postDisableReplicationPeer(this, peerId);
1781      }
1782    });
1783  }
1784
1785  public void preGetReplicationPeerConfig(final String peerId) throws IOException {
1786    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1787      @Override
1788      public void call(MasterObserver observer) throws IOException {
1789        observer.preGetReplicationPeerConfig(this, peerId);
1790      }
1791    });
1792  }
1793
1794  public void postGetReplicationPeerConfig(final String peerId) throws IOException {
1795    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1796      @Override
1797      public void call(MasterObserver observer) throws IOException {
1798        observer.postGetReplicationPeerConfig(this, peerId);
1799      }
1800    });
1801  }
1802
1803  public void preUpdateReplicationPeerConfig(final String peerId,
1804    final ReplicationPeerConfig peerConfig) throws IOException {
1805    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1806      @Override
1807      public void call(MasterObserver observer) throws IOException {
1808        observer.preUpdateReplicationPeerConfig(this, peerId, peerConfig);
1809      }
1810    });
1811  }
1812
1813  public void postUpdateReplicationPeerConfig(final String peerId,
1814    final ReplicationPeerConfig peerConfig) throws IOException {
1815    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1816      @Override
1817      public void call(MasterObserver observer) throws IOException {
1818        observer.postUpdateReplicationPeerConfig(this, peerId, peerConfig);
1819      }
1820    });
1821  }
1822
1823  public void preListReplicationPeers(final String regex) throws IOException {
1824    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1825      @Override
1826      public void call(MasterObserver observer) throws IOException {
1827        observer.preListReplicationPeers(this, regex);
1828      }
1829    });
1830  }
1831
1832  public void postListReplicationPeers(final String regex) throws IOException {
1833    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1834      @Override
1835      public void call(MasterObserver observer) throws IOException {
1836        observer.postListReplicationPeers(this, regex);
1837      }
1838    });
1839  }
1840
1841  public void preTransitReplicationPeerSyncReplicationState(String peerId,
1842    SyncReplicationState state) throws IOException {
1843    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1844      @Override
1845      public void call(MasterObserver observer) throws IOException {
1846        observer.preTransitReplicationPeerSyncReplicationState(this, peerId, state);
1847      }
1848    });
1849  }
1850
1851  public void postTransitReplicationPeerSyncReplicationState(String peerId,
1852    SyncReplicationState from, SyncReplicationState to) throws IOException {
1853    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1854      @Override
1855      public void call(MasterObserver observer) throws IOException {
1856        observer.postTransitReplicationPeerSyncReplicationState(this, peerId, from, to);
1857      }
1858    });
1859  }
1860
1861  public void preRequestLock(String namespace, TableName tableName, RegionInfo[] regionInfos,
1862    LockType type, String description) throws IOException {
1863    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1864      @Override
1865      public void call(MasterObserver observer) throws IOException {
1866        observer.preRequestLock(this, namespace, tableName, regionInfos, description);
1867      }
1868    });
1869  }
1870
1871  public void postRequestLock(String namespace, TableName tableName, RegionInfo[] regionInfos,
1872    LockType type, String description) throws IOException {
1873    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1874      @Override
1875      public void call(MasterObserver observer) throws IOException {
1876        observer.postRequestLock(this, namespace, tableName, regionInfos, description);
1877      }
1878    });
1879  }
1880
1881  public void preLockHeartbeat(LockProcedure proc, boolean keepAlive) throws IOException {
1882    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1883      @Override
1884      public void call(MasterObserver observer) throws IOException {
1885        observer.preLockHeartbeat(this, proc.getTableName(), proc.getDescription());
1886      }
1887    });
1888  }
1889
1890  public void postLockHeartbeat(LockProcedure proc, boolean keepAlive) throws IOException {
1891    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1892      @Override
1893      public void call(MasterObserver observer) throws IOException {
1894        observer.postLockHeartbeat(this);
1895      }
1896    });
1897  }
1898
1899  public void preGetClusterMetrics() throws IOException {
1900    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1901      @Override
1902      public void call(MasterObserver observer) throws IOException {
1903        observer.preGetClusterMetrics(this);
1904      }
1905    });
1906  }
1907
1908  public void postGetClusterMetrics(ClusterMetrics status) throws IOException {
1909    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1910      @Override
1911      public void call(MasterObserver observer) throws IOException {
1912        observer.postGetClusterMetrics(this, status);
1913      }
1914    });
1915  }
1916
1917  public void preClearDeadServers() throws IOException {
1918    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1919      @Override
1920      public void call(MasterObserver observer) throws IOException {
1921        observer.preClearDeadServers(this);
1922      }
1923    });
1924  }
1925
1926  public void postClearDeadServers(List<ServerName> servers, List<ServerName> notClearedServers)
1927    throws IOException {
1928    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1929      @Override
1930      public void call(MasterObserver observer) throws IOException {
1931        observer.postClearDeadServers(this, servers, notClearedServers);
1932      }
1933    });
1934  }
1935
1936  public void preDecommissionRegionServers(List<ServerName> servers, boolean offload)
1937    throws IOException {
1938    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1939      @Override
1940      public void call(MasterObserver observer) throws IOException {
1941        observer.preDecommissionRegionServers(this, servers, offload);
1942      }
1943    });
1944  }
1945
1946  public void postDecommissionRegionServers(List<ServerName> servers, boolean offload)
1947    throws IOException {
1948    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1949      @Override
1950      public void call(MasterObserver observer) throws IOException {
1951        observer.postDecommissionRegionServers(this, servers, offload);
1952      }
1953    });
1954  }
1955
1956  public void preListDecommissionedRegionServers() throws IOException {
1957    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1958      @Override
1959      public void call(MasterObserver observer) throws IOException {
1960        observer.preListDecommissionedRegionServers(this);
1961      }
1962    });
1963  }
1964
1965  public void postListDecommissionedRegionServers() throws IOException {
1966    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1967      @Override
1968      public void call(MasterObserver observer) throws IOException {
1969        observer.postListDecommissionedRegionServers(this);
1970      }
1971    });
1972  }
1973
1974  public void preRecommissionRegionServer(ServerName server, List<byte[]> encodedRegionNames)
1975    throws IOException {
1976    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1977      @Override
1978      public void call(MasterObserver observer) throws IOException {
1979        observer.preRecommissionRegionServer(this, server, encodedRegionNames);
1980      }
1981    });
1982  }
1983
1984  public void postRecommissionRegionServer(ServerName server, List<byte[]> encodedRegionNames)
1985    throws IOException {
1986    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1987      @Override
1988      public void call(MasterObserver observer) throws IOException {
1989        observer.postRecommissionRegionServer(this, server, encodedRegionNames);
1990      }
1991    });
1992  }
1993
1994  public void preSwitchRpcThrottle(boolean enable) throws IOException {
1995    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
1996      @Override
1997      public void call(MasterObserver observer) throws IOException {
1998        observer.preSwitchRpcThrottle(this, enable);
1999      }
2000    });
2001  }
2002
2003  public void postSwitchRpcThrottle(final boolean oldValue, final boolean newValue)
2004    throws IOException {
2005    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2006      @Override
2007      public void call(MasterObserver observer) throws IOException {
2008        observer.postSwitchRpcThrottle(this, oldValue, newValue);
2009      }
2010    });
2011  }
2012
2013  public void preIsRpcThrottleEnabled() throws IOException {
2014    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2015      @Override
2016      public void call(MasterObserver observer) throws IOException {
2017        observer.preIsRpcThrottleEnabled(this);
2018      }
2019    });
2020  }
2021
2022  public void postIsRpcThrottleEnabled(boolean enabled) throws IOException {
2023    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2024      @Override
2025      public void call(MasterObserver observer) throws IOException {
2026        observer.postIsRpcThrottleEnabled(this, enabled);
2027      }
2028    });
2029  }
2030
2031  public void preSwitchExceedThrottleQuota(boolean enable) throws IOException {
2032    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2033      @Override
2034      public void call(MasterObserver observer) throws IOException {
2035        observer.preSwitchExceedThrottleQuota(this, enable);
2036      }
2037    });
2038  }
2039
2040  public void postSwitchExceedThrottleQuota(final boolean oldValue, final boolean newValue)
2041    throws IOException {
2042    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2043      @Override
2044      public void call(MasterObserver observer) throws IOException {
2045        observer.postSwitchExceedThrottleQuota(this, oldValue, newValue);
2046      }
2047    });
2048  }
2049
2050  public void preGrant(UserPermission userPermission, boolean mergeExistingPermissions)
2051    throws IOException {
2052    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2053      @Override
2054      public void call(MasterObserver observer) throws IOException {
2055        observer.preGrant(this, userPermission, mergeExistingPermissions);
2056      }
2057    });
2058  }
2059
2060  public void postGrant(UserPermission userPermission, boolean mergeExistingPermissions)
2061    throws IOException {
2062    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2063      @Override
2064      public void call(MasterObserver observer) throws IOException {
2065        observer.postGrant(this, userPermission, mergeExistingPermissions);
2066      }
2067    });
2068  }
2069
2070  public void preRevoke(UserPermission userPermission) throws IOException {
2071    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2072      @Override
2073      public void call(MasterObserver observer) throws IOException {
2074        observer.preRevoke(this, userPermission);
2075      }
2076    });
2077  }
2078
2079  public void postRevoke(UserPermission userPermission) throws IOException {
2080    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2081      @Override
2082      public void call(MasterObserver observer) throws IOException {
2083        observer.postRevoke(this, userPermission);
2084      }
2085    });
2086  }
2087
2088  public void preGetUserPermissions(String userName, String namespace, TableName tableName,
2089    byte[] family, byte[] qualifier) throws IOException {
2090    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2091      @Override
2092      public void call(MasterObserver observer) throws IOException {
2093        observer.preGetUserPermissions(this, userName, namespace, tableName, family, qualifier);
2094      }
2095    });
2096  }
2097
2098  public void postGetUserPermissions(String userName, String namespace, TableName tableName,
2099    byte[] family, byte[] qualifier) throws IOException {
2100    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2101      @Override
2102      public void call(MasterObserver observer) throws IOException {
2103        observer.postGetUserPermissions(this, userName, namespace, tableName, family, qualifier);
2104      }
2105    });
2106  }
2107
2108  public void preHasUserPermissions(String userName, List<Permission> permissions)
2109    throws IOException {
2110    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2111      @Override
2112      public void call(MasterObserver observer) throws IOException {
2113        observer.preHasUserPermissions(this, userName, permissions);
2114      }
2115    });
2116  }
2117
2118  public void postHasUserPermissions(String userName, List<Permission> permissions)
2119    throws IOException {
2120    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2121      @Override
2122      public void call(MasterObserver observer) throws IOException {
2123        observer.postHasUserPermissions(this, userName, permissions);
2124      }
2125    });
2126  }
2127
2128  public void preUpdateConfiguration(Configuration preReloadConf) throws IOException {
2129    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2130      @Override
2131      public void call(MasterObserver observer) throws IOException {
2132        observer.preUpdateMasterConfiguration(this, preReloadConf);
2133      }
2134    });
2135  }
2136
2137  public void postUpdateConfiguration(Configuration postReloadConf) throws IOException {
2138    execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
2139      @Override
2140      public void call(MasterObserver observer) throws IOException {
2141        observer.postUpdateMasterConfiguration(this, postReloadConf);
2142      }
2143    });
2144  }
2145}