View Javadoc

1   /**
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  package org.apache.hadoop.hbase.regionserver;
20  
21  import org.apache.hadoop.hbase.classification.InterfaceAudience;
22  import org.apache.hadoop.fs.FileSystem;
23  import org.apache.hadoop.hbase.HRegionInfo;
24  import org.apache.hadoop.hbase.catalog.CatalogTracker;
25  import org.apache.hadoop.hbase.executor.ExecutorService;
26  import org.apache.hadoop.hbase.ipc.PriorityFunction;
27  import org.apache.hadoop.hbase.ipc.RpcServerInterface;
28  import org.apache.hadoop.hbase.master.TableLockManager;
29  import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode;
30  import org.apache.hadoop.hbase.regionserver.wal.HLog;
31  import org.apache.zookeeper.KeeperException;
32  
33  import com.google.protobuf.Service;
34  
35  import java.io.IOException;
36  import java.util.Map;
37  import java.util.concurrent.ConcurrentMap;
38  
39  /**
40   * Services provided by {@link HRegionServer}
41   */
42  @InterfaceAudience.Private
43  public interface RegionServerServices
44      extends OnlineRegions, FavoredNodesForRegion, PriorityFunction {
45    /**
46     * @return True if this regionserver is stopping.
47     */
48    boolean isStopping();
49  
50    /** @return the HLog for a particular region. Pass null for getting the
51     * default (common) WAL */
52    HLog getWAL(HRegionInfo regionInfo) throws IOException;
53  
54    /**
55     * @return Implementation of {@link CompactionRequestor} or null.
56     */
57    CompactionRequestor getCompactionRequester();
58  
59    /**
60     * @return Implementation of {@link FlushRequester} or null.
61     */
62    FlushRequester getFlushRequester();
63  
64    /**
65     * @return the RegionServerAccounting for this Region Server
66     */
67    RegionServerAccounting getRegionServerAccounting();
68  
69    /**
70     * @return RegionServer's instance of {@link TableLockManager}
71     */
72    TableLockManager getTableLockManager();
73  
74    /**
75     * Tasks to perform after region open to complete deploy of region on
76     * regionserver
77     *
78     * @param r Region to open.
79     * @param ct Instance of {@link CatalogTracker}
80     * @throws KeeperException
81     * @throws IOException
82     */
83    void postOpenDeployTasks(final HRegion r, final CatalogTracker ct)
84    throws KeeperException, IOException;
85  
86    /**
87     * Notify master that a handler requests to change a region state
88     */
89    boolean reportRegionStateTransition(TransitionCode code, long openSeqNum, HRegionInfo... hris);
90  
91    /**
92     * Notify master that a handler requests to change a region state
93     */
94    boolean reportRegionStateTransition(TransitionCode code, HRegionInfo... hris);
95  
96    /**
97     * Returns a reference to the region server's RPC server
98     */
99    RpcServerInterface getRpcServer();
100 
101   /**
102    * Get the regions that are currently being opened or closed in the RS
103    * @return map of regions in transition in this RS
104    */
105   ConcurrentMap<byte[], Boolean> getRegionsInTransitionInRS();
106 
107   /**
108    * @return Return the FileSystem object used by the regionserver
109    */
110   FileSystem getFileSystem();
111 
112   /**
113    * @return The RegionServer's "Leases" service
114    */
115   Leases getLeases();
116 
117   /**
118    * @return hbase executor service
119    */
120   ExecutorService getExecutorService();
121 
122   /**
123    * @return The RegionServer's CatalogTracker
124    */
125   CatalogTracker getCatalogTracker();
126 
127   /**
128    * @return set of recovering regions on the hosting region server
129    */
130   Map<String, HRegion> getRecoveringRegions();
131 
132   /**
133    * Only required for "old" log replay; if it's removed, remove this.
134    * @return The RegionServer's NonceManager
135    */
136   public ServerNonceManager getNonceManager();
137   
138   /**
139    * Registers a new protocol buffer {@link Service} subclass as a coprocessor endpoint to
140    * be available for handling
141    * @param instance the {@code Service} subclass instance to expose as a coprocessor endpoint
142    * @return {@code true} if the registration was successful, {@code false}
143    */
144   boolean registerService(Service service);
145 
146   /**
147    * @return heap memory manager instance
148    */
149   HeapMemoryManager getHeapMemoryManager();
150 
151   /**
152    * @return the max compaction pressure of all stores on this regionserver. The value should be
153    *         greater than or equal to 0.0, and any value greater than 1.0 means we enter the
154    *         emergency state that some stores have too many store files.
155    * @see org.apache.hadoop.hbase.regionserver.Store#getCompactionPressure()
156    */
157   double getCompactionPressure();
158 }