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.Map;
23 import java.util.Set;
24 import java.util.concurrent.ConcurrentMap;
25
26 import org.apache.hadoop.fs.FileSystem;
27 import org.apache.hadoop.hbase.HBaseInterfaceAudience;
28 import org.apache.hadoop.hbase.HRegionInfo;
29 import org.apache.hadoop.hbase.TableName;
30 import org.apache.hadoop.hbase.classification.InterfaceAudience;
31 import org.apache.hadoop.hbase.classification.InterfaceStability;
32 import org.apache.hadoop.hbase.executor.ExecutorService;
33 import org.apache.hadoop.hbase.ipc.RpcServerInterface;
34 import org.apache.hadoop.hbase.master.TableLockManager;
35 import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode;
36 import org.apache.hadoop.hbase.wal.WAL;
37 import org.apache.hadoop.hbase.quotas.RegionServerQuotaManager;
38 import org.apache.zookeeper.KeeperException;
39
40 import com.google.protobuf.Service;
41
42 /**
43 * Services provided by {@link HRegionServer}
44 */
45 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
46 @InterfaceStability.Evolving
47 public interface RegionServerServices extends OnlineRegions, FavoredNodesForRegion {
48 /**
49 * @return True if this regionserver is stopping.
50 */
51 boolean isStopping();
52
53 /** @return the WAL for a particular region. Pass null for getting the
54 * default (common) WAL */
55 WAL getWAL(HRegionInfo regionInfo) throws IOException;
56
57 /**
58 * @return Implementation of {@link CompactionRequestor} or null.
59 */
60 CompactionRequestor getCompactionRequester();
61
62 /**
63 * @return Implementation of {@link FlushRequester} or null.
64 */
65 FlushRequester getFlushRequester();
66
67 /**
68 * @return the RegionServerAccounting for this Region Server
69 */
70 RegionServerAccounting getRegionServerAccounting();
71
72 /**
73 * @return RegionServer's instance of {@link TableLockManager}
74 */
75 TableLockManager getTableLockManager();
76
77 /**
78 * @return RegionServer's instance of {@link RegionServerQuotaManager}
79 */
80 RegionServerQuotaManager getRegionServerQuotaManager();
81
82 /**
83 * Tasks to perform after region open to complete deploy of region on
84 * regionserver
85 *
86 * @param r Region to open.
87 * @throws KeeperException
88 * @throws IOException
89 */
90 void postOpenDeployTasks(final Region r) throws KeeperException, IOException;
91
92 /**
93 * Notify master that a handler requests to change a region state
94 */
95 boolean reportRegionStateTransition(TransitionCode code, long openSeqNum, HRegionInfo... hris);
96
97 /**
98 * Notify master that a handler requests to change a region state
99 */
100 boolean reportRegionStateTransition(TransitionCode code, HRegionInfo... hris);
101
102 /**
103 * Returns a reference to the region server's RPC server
104 */
105 RpcServerInterface getRpcServer();
106
107 /**
108 * Get the regions that are currently being opened or closed in the RS
109 * @return map of regions in transition in this RS
110 */
111 ConcurrentMap<byte[], Boolean> getRegionsInTransitionInRS();
112
113 /**
114 * @return Return the FileSystem object used by the regionserver
115 */
116 FileSystem getFileSystem();
117
118 /**
119 * @return The RegionServer's "Leases" service
120 */
121 Leases getLeases();
122
123 /**
124 * @return hbase executor service
125 */
126 ExecutorService getExecutorService();
127
128 /**
129 * @return set of recovering regions on the hosting region server
130 */
131 Map<String, Region> getRecoveringRegions();
132
133 /**
134 * Only required for "old" log replay; if it's removed, remove this.
135 * @return The RegionServer's NonceManager
136 */
137 public ServerNonceManager getNonceManager();
138
139 /**
140 * Registers a new protocol buffer {@link Service} subclass as a coprocessor endpoint to be
141 * available for handling
142 * @param service the {@code Service} subclass instance to expose as a coprocessor endpoint
143 * @return {@code true} if the registration was successful, {@code false}
144 */
145 boolean registerService(Service service);
146
147 /**
148 * @return heap memory manager instance
149 */
150 HeapMemoryManager getHeapMemoryManager();
151
152 /**
153 * @return the max compaction pressure of all stores on this regionserver. The value should be
154 * greater than or equal to 0.0, and any value greater than 1.0 means we enter the
155 * emergency state that some stores have too many store files.
156 * @see org.apache.hadoop.hbase.regionserver.Store#getCompactionPressure()
157 */
158 double getCompactionPressure();
159
160 /**
161 * @return all the online tables in this RS
162 */
163 Set<TableName> getOnlineTables();
164 }