1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 package org.apache.hadoop.hbase.procedure; 19 20 import java.io.IOException; 21 22 import org.apache.hadoop.hbase.classification.InterfaceAudience; 23 import org.apache.hadoop.hbase.classification.InterfaceStability; 24 import org.apache.hadoop.hbase.Stoppable; 25 import org.apache.hadoop.hbase.master.MasterServices; 26 import org.apache.hadoop.hbase.master.MetricsMaster; 27 import org.apache.hadoop.hbase.master.HMaster; 28 import org.apache.hadoop.hbase.master.snapshot.SnapshotManager; 29 import org.apache.hadoop.hbase.regionserver.HRegionServer; 30 import org.apache.hadoop.hbase.regionserver.snapshot.RegionServerSnapshotManager; 31 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ProcedureDescription; 32 import org.apache.zookeeper.KeeperException; 33 34 /** 35 * A life-cycle management interface for globally barriered procedures on master. 36 * See the following doc on details of globally barriered procedure: 37 * https://issues.apache.org/jira/secure/attachment/12555103/121127-global-barrier-proc.pdf 38 * 39 * To implement a custom globally barriered procedure, user needs to extend two classes: 40 * {@link MasterProcedureManager} and {@link RegionServerProcedureManager}. Implementation of 41 * {@link MasterProcedureManager} is loaded into {@link HMaster} process via configuration 42 * parameter 'hbase.procedure.master.classes', while implementation of 43 * {@link RegionServerProcedureManager} is loaded into {@link HRegionServer} process via 44 * configuration parameter 'hbase.procedure.regionserver.classes'. 45 * 46 * An example of globally barriered procedure implementation is {@link SnapshotManager} and 47 * {@link RegionServerSnapshotManager}. 48 * 49 * A globally barriered procedure is identified by its signature (usually it is the name of the 50 * procedure znode). During the initialization phase, the initialize methods are called by both 51 * {@link HMaster} and {@link HRegionServer} witch create the procedure znode and register the 52 * listeners. A procedure can be triggered by its signature and an instant name (encapsulated in 53 * a {@link ProcedureDescription} object). When the servers are shutdown, the stop methods on both 54 * classes are called to clean up the data associated with the procedure. 55 */ 56 @InterfaceAudience.Private 57 @InterfaceStability.Evolving 58 public abstract class MasterProcedureManager extends ProcedureManager implements 59 Stoppable { 60 /** 61 * Initialize a globally barriered procedure for master. 62 * 63 * @param master Master service interface 64 * @throws KeeperException 65 * @throws IOException 66 * @throws UnsupportedOperationException 67 */ 68 public abstract void initialize(MasterServices master, MetricsMaster metricsMaster) 69 throws KeeperException, IOException, UnsupportedOperationException; 70 71 /** 72 * Execute a distributed procedure on cluster 73 * 74 * @param desc Procedure description 75 * @throws IOException 76 */ 77 public abstract void execProcedure(ProcedureDescription desc) throws IOException; 78 79 /** 80 * Check if the procedure is finished successfully 81 * 82 * @param desc Procedure description 83 * @return true if the specified procedure is finished successfully 84 * @throws IOException 85 */ 86 public abstract boolean isProcedureDone(ProcedureDescription desc) throws IOException; 87 }