View Javadoc

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.commons.logging.Log;
23  import org.apache.commons.logging.LogFactory;
24  import org.apache.hadoop.conf.Configuration;
25  import org.apache.hadoop.hbase.procedure.flush.RegionServerFlushTableProcedureManager;
26  import org.apache.hadoop.hbase.regionserver.RegionServerServices;
27  import org.apache.hadoop.hbase.regionserver.snapshot.RegionServerSnapshotManager;
28  
29  /**
30   * Provides the globally barriered procedure framework and environment
31   * for region server oriented operations. 
32   * {@link org.apache.hadoop.hbase.regionserver.HRegionServer} interacts
33   * with the loaded procedure manager through this class.
34   */
35  public class RegionServerProcedureManagerHost extends
36      ProcedureManagerHost<RegionServerProcedureManager> {
37  
38    private static final Log LOG = LogFactory
39        .getLog(RegionServerProcedureManagerHost.class);
40  
41    public void initialize(RegionServerServices rss) throws IOException {
42      for (RegionServerProcedureManager proc : procedures) {
43        LOG.debug("Procedure " + proc.getProcedureSignature() + " is initializing");
44        proc.initialize(rss);
45        LOG.debug("Procedure " + proc.getProcedureSignature() + " is initialized");
46      }
47    }
48  
49    public void start() {
50      for (RegionServerProcedureManager proc : procedures) {
51        LOG.debug("Procedure " + proc.getProcedureSignature() + " is starting");
52        proc.start();
53        LOG.debug("Procedure " + proc.getProcedureSignature() + " is started");
54      }
55    }
56  
57    public void stop(boolean force) {
58      for (RegionServerProcedureManager proc : procedures) {
59        try {
60          proc.stop(force);
61        } catch (IOException e) {
62          LOG.warn("Failed to close procedure " + proc.getProcedureSignature()
63              + " cleanly", e);
64        }
65      }
66    }
67  
68    @Override
69    public void loadProcedures(Configuration conf) {
70      loadUserProcedures(conf, REGIONSERVER_PROCEDURE_CONF_KEY);
71      // load the default snapshot manager
72      procedures.add(new RegionServerSnapshotManager());
73      // load the default flush region procedure manager
74      procedures.add(new RegionServerFlushTableProcedureManager());
75    }
76  
77  }