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 java.io.IOException;
22  import java.util.List;
23  import java.util.Map;
24  import java.util.Set;
25  import java.util.concurrent.ConcurrentMap;
26
27  import org.apache.hadoop.fs.FileSystem;
28  import org.apache.hadoop.hbase.HBaseInterfaceAudience;
29  import org.apache.hadoop.hbase.HRegionInfo;
30  import org.apache.hadoop.hbase.TableName;
31  import org.apache.hadoop.hbase.classification.InterfaceAudience;
32  import org.apache.hadoop.hbase.classification.InterfaceStability;
33  import org.apache.hadoop.hbase.executor.ExecutorService;
34  import org.apache.hadoop.hbase.ipc.RpcServerInterface;
35  import org.apache.hadoop.hbase.master.TableLockManager;
36  import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode;
37  import org.apache.hadoop.hbase.quotas.RegionServerQuotaManager;
38  import org.apache.hadoop.hbase.regionserver.throttle.ThroughputController;
39  import org.apache.hadoop.hbase.wal.WAL;
40  import org.apache.zookeeper.KeeperException;
41
42  import com.google.protobuf.Service;
43
44  /**
45   * Services provided by {@link HRegionServer}
46   */
47  @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
48  @InterfaceStability.Evolving
49  public interface RegionServerServices extends OnlineRegions, FavoredNodesForRegion {
50    /**
51     * @return True if this regionserver is stopping.
52     */
53    boolean isStopping();
54
55    /** @return the WAL for a particular region. Pass null for getting the
56     * default (common) WAL */
57    WAL getWAL(HRegionInfo regionInfo) throws IOException;
58
59    /** @return the List of WALs that are used by this server
60     *  Doesn't include the meta WAL
61     */
62    List<WAL> getWALs() throws IOException;
63
64    /**
65     * @return Implementation of {@link CompactionRequestor} or null.
66     */
67    CompactionRequestor getCompactionRequester();
68
69    /**
70     * @return Implementation of {@link FlushRequester} or null.
71     */
72    FlushRequester getFlushRequester();
73
74    /**
75     * @return the RegionServerAccounting for this Region Server
76     */
77    RegionServerAccounting getRegionServerAccounting();
78
79    /**
80     * @return RegionServer's instance of {@link TableLockManager}
81     */
82    TableLockManager getTableLockManager();
83
84    /**
85     * @return RegionServer's instance of {@link RegionServerQuotaManager}
86     */
87    RegionServerQuotaManager getRegionServerQuotaManager();
88
89    /**
90     * @return RegionServer's instance of {@link SecureBulkLoadManager}
91     */
92    SecureBulkLoadManager getSecureBulkLoadManager();
93
94    /**
95     * Context for postOpenDeployTasks().
96     */
97    class PostOpenDeployContext {
98      private final Region region;
99      private final long masterSystemTime;
100
101     @InterfaceAudience.Private
102     public PostOpenDeployContext(Region region, long masterSystemTime) {
103       this.region = region;
104       this.masterSystemTime = masterSystemTime;
105     }
106     public Region getRegion() {
107       return region;
108     }
109     public long getMasterSystemTime() {
110       return masterSystemTime;
111     }
112   }
113
114   /**
115    * Tasks to perform after region open to complete deploy of region on
116    * regionserver
117    *
118    * @param context the context
119    * @throws KeeperException
120    * @throws IOException
121    */
122   void postOpenDeployTasks(final PostOpenDeployContext context) throws KeeperException, IOException;
123
124   /**
125    * Tasks to perform after region open to complete deploy of region on
126    * regionserver
127    *
128    * @param r Region to open.
129    * @throws KeeperException
130    * @throws IOException
131    * @deprecated use {@link #postOpenDeployTasks(PostOpenDeployContext)}
132    */
133   @Deprecated
134   void postOpenDeployTasks(final Region r) throws KeeperException, IOException;
135
136   class RegionStateTransitionContext {
137     private final TransitionCode code;
138     private final long openSeqNum;
139     private final long masterSystemTime;
140     private final HRegionInfo[] hris;
141
142     @InterfaceAudience.Private
143     public RegionStateTransitionContext(TransitionCode code, long openSeqNum, long masterSystemTime,
144         HRegionInfo... hris) {
145       this.code = code;
146       this.openSeqNum = openSeqNum;
147       this.masterSystemTime = masterSystemTime;
148       this.hris = hris;
149     }
150     public TransitionCode getCode() {
151       return code;
152     }
153     public long getOpenSeqNum() {
154       return openSeqNum;
155     }
156     public long getMasterSystemTime() {
157       return masterSystemTime;
158     }
159     public HRegionInfo[] getHris() {
160       return hris;
161     }
162   }
163
164   /**
165    * Notify master that a handler requests to change a region state
166    */
167   boolean reportRegionStateTransition(final RegionStateTransitionContext context);
168
169   /**
170    * Notify master that a handler requests to change a region state
171    * @deprecated use {@link #reportRegionStateTransition(RegionStateTransitionContext)}
172    */
173   @Deprecated
174   boolean reportRegionStateTransition(TransitionCode code, long openSeqNum, HRegionInfo... hris);
175
176   /**
177    * Notify master that a handler requests to change a region state
178    * @deprecated use {@link #reportRegionStateTransition(RegionStateTransitionContext)}
179    */
180   @Deprecated
181   boolean reportRegionStateTransition(TransitionCode code, HRegionInfo... hris);
182
183   /**
184    * Returns a reference to the region server's RPC server
185    */
186   RpcServerInterface getRpcServer();
187 
188   /**
189    * Get the regions that are currently being opened or closed in the RS
190    * @return map of regions in transition in this RS
191    */
192   ConcurrentMap<byte[], Boolean> getRegionsInTransitionInRS();
193
194   /**
195    * @return Return the FileSystem object used by the regionserver
196    */
197   FileSystem getFileSystem();
198
199   /**
200    * @return The RegionServer's "Leases" service
201    */
202   Leases getLeases();
203
204   /**
205    * @return hbase executor service
206    */
207   ExecutorService getExecutorService();
208
209   /**
210    * @return set of recovering regions on the hosting region server
211    */
212   Map<String, Region> getRecoveringRegions();
213 
214   /**
215    * Only required for "old" log replay; if it's removed, remove this.
216    * @return The RegionServer's NonceManager
217    */
218   public ServerNonceManager getNonceManager();
219
220   /**
221    * @return all the online tables in this RS
222    */
223   Set<TableName> getOnlineTables();
224
225
226   /**
227    * Registers a new protocol buffer {@link Service} subclass as a coprocessor endpoint to be
228    * available for handling
229    * @param service the {@code Service} subclass instance to expose as a coprocessor endpoint
230    * @return {@code true} if the registration was successful, {@code false}
231    */
232   boolean registerService(Service service);
233
234   /**
235    * @return heap memory manager instance
236    */
237   HeapMemoryManager getHeapMemoryManager();
238
239   /**
240    * @return the max compaction pressure of all stores on this regionserver. The value should be
241    *         greater than or equal to 0.0, and any value greater than 1.0 means we enter the
242    *         emergency state that some stores have too many store files.
243    * @see org.apache.hadoop.hbase.regionserver.Store#getCompactionPressure()
244    */
245   double getCompactionPressure();
246
247   /**
248    * @return the controller to avoid flush too fast
249    */
250   ThroughputController getFlushThroughputController();
251
252   /**
253    * @return the flush pressure of all stores on this regionserver. The value should be greater than
254    *         or equal to 0.0, and any value greater than 1.0 means we enter the emergency state that
255    *         global memstore size already exceeds lower limit.
256    */
257   double getFlushPressure();
258
259   /**
260    * @return the metrics tracker for the region server
261    */
262   MetricsRegionServer getMetrics();
263 }