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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 package org
.apache
.hadoop
.hbase
.regionserver
;
21 import java
.io
.IOException
;
22 import java
.util
.Collection
;
23 import java
.util
.List
;
24 import java
.util
.Map
.Entry
;
25 import java
.util
.Optional
;
26 import java
.util
.concurrent
.ConcurrentMap
;
27 import org
.apache
.hadoop
.hbase
.Abortable
;
28 import org
.apache
.hadoop
.hbase
.Server
;
29 import org
.apache
.hadoop
.hbase
.TableDescriptors
;
30 import org
.apache
.hadoop
.hbase
.TableName
;
31 import org
.apache
.hadoop
.hbase
.client
.RegionInfo
;
32 import org
.apache
.hadoop
.hbase
.client
.locking
.EntityLock
;
33 import org
.apache
.hadoop
.hbase
.executor
.ExecutorService
;
34 import org
.apache
.hadoop
.hbase
.io
.hfile
.BlockCache
;
35 import org
.apache
.hadoop
.hbase
.ipc
.RpcServerInterface
;
36 import org
.apache
.hadoop
.hbase
.mob
.MobFileCache
;
37 import org
.apache
.hadoop
.hbase
.quotas
.RegionServerRpcQuotaManager
;
38 import org
.apache
.hadoop
.hbase
.quotas
.RegionServerSpaceQuotaManager
;
39 import org
.apache
.hadoop
.hbase
.quotas
.RegionSizeStore
;
40 import org
.apache
.hadoop
.hbase
.regionserver
.compactions
.CompactionRequester
;
41 import org
.apache
.hadoop
.hbase
.regionserver
.regionreplication
.RegionReplicationBufferManager
;
42 import org
.apache
.hadoop
.hbase
.regionserver
.throttle
.ThroughputController
;
43 import org
.apache
.hadoop
.hbase
.security
.access
.AccessChecker
;
44 import org
.apache
.hadoop
.hbase
.security
.access
.ZKPermissionWatcher
;
45 import org
.apache
.hadoop
.hbase
.wal
.WAL
;
46 import org
.apache
.yetus
.audience
.InterfaceAudience
;
48 import org
.apache
.hbase
.thirdparty
.com
.google
.protobuf
.Service
;
50 import org
.apache
.hadoop
.hbase
.shaded
.protobuf
.generated
.RegionServerStatusProtos
.RegionStateTransition
.TransitionCode
;
53 * A curated subset of services provided by {@link HRegionServer}.
54 * For use internally only. Passed to Managers, Services and Chores so can pass less-than-a
55 * full-on HRegionServer at test-time. Be judicious adding API. Changes cause ripples through
58 @InterfaceAudience.Private
59 public interface RegionServerServices
extends Server
, MutableOnlineRegions
, FavoredNodesForRegion
{
61 /** @return the WAL for a particular region. Pass null for getting the
62 * default (common) WAL */
63 WAL
getWAL(RegionInfo regionInfo
) throws IOException
;
65 /** @return the List of WALs that are used by this server
66 * Doesn't include the meta WAL
68 List
<WAL
> getWALs() throws IOException
;
71 * @return Implementation of {@link FlushRequester} or null. Usually it will not be null unless
72 * during intialization.
74 FlushRequester
getFlushRequester();
77 * @return Implementation of {@link CompactionRequester} or null. Usually it will not be null
78 * unless during intialization.
80 CompactionRequester
getCompactionRequestor();
83 * @return the RegionServerAccounting for this Region Server
85 RegionServerAccounting
getRegionServerAccounting();
88 * @return RegionServer's instance of {@link RegionServerRpcQuotaManager}
90 RegionServerRpcQuotaManager
getRegionServerRpcQuotaManager();
93 * @return RegionServer's instance of {@link SecureBulkLoadManager}
95 SecureBulkLoadManager
getSecureBulkLoadManager();
98 * @return RegionServer's instance of {@link RegionServerSpaceQuotaManager}
100 RegionServerSpaceQuotaManager
getRegionServerSpaceQuotaManager();
103 * Context for postOpenDeployTasks().
105 class PostOpenDeployContext
{
106 private final HRegion region
;
107 private final long openProcId
;
108 private final long masterSystemTime
;
110 public PostOpenDeployContext(HRegion region
, long openProcId
, long masterSystemTime
) {
111 this.region
= region
;
112 this.openProcId
= openProcId
;
113 this.masterSystemTime
= masterSystemTime
;
116 public HRegion
getRegion() {
120 public long getOpenProcId() {
124 public long getMasterSystemTime() {
125 return masterSystemTime
;
130 * Tasks to perform after region open to complete deploy of region on regionserver
131 * @param context the context
133 void postOpenDeployTasks(final PostOpenDeployContext context
) throws IOException
;
135 class RegionStateTransitionContext
{
136 private final TransitionCode code
;
137 private final long openSeqNum
;
138 private final long masterSystemTime
;
139 private final long[] procIds
;
140 private final RegionInfo
[] hris
;
142 public RegionStateTransitionContext(TransitionCode code
, long openSeqNum
, long masterSystemTime
,
143 RegionInfo
... hris
) {
145 this.openSeqNum
= openSeqNum
;
146 this.masterSystemTime
= masterSystemTime
;
148 this.procIds
= new long[hris
.length
];
151 public RegionStateTransitionContext(TransitionCode code
, long openSeqNum
, long procId
,
152 long masterSystemTime
, RegionInfo hri
) {
154 this.openSeqNum
= openSeqNum
;
155 this.masterSystemTime
= masterSystemTime
;
156 this.hris
= new RegionInfo
[] { hri
};
157 this.procIds
= new long[] { procId
};
160 public TransitionCode
getCode() {
164 public long getOpenSeqNum() {
168 public long getMasterSystemTime() {
169 return masterSystemTime
;
172 public RegionInfo
[] getHris() {
176 public long[] getProcIds() {
182 * Notify master that a handler requests to change a region state
184 boolean reportRegionStateTransition(final RegionStateTransitionContext context
);
187 * Returns a reference to the region server's RPC server
189 RpcServerInterface
getRpcServer();
192 * Get the regions that are currently being opened or closed in the RS
193 * @return map of regions in transition in this RS
195 ConcurrentMap
<byte[], Boolean
> getRegionsInTransitionInRS();
198 * @return The RegionServer's "Leases" service
200 LeaseManager
getLeaseManager();
203 * @return hbase executor service
205 ExecutorService
getExecutorService();
208 * Only required for "old" log replay; if it's removed, remove this.
209 * @return The RegionServer's NonceManager
211 ServerNonceManager
getNonceManager();
214 * Registers a new protocol buffer {@link Service} subclass as a coprocessor endpoint to be
215 * available for handling
216 * @param service the {@code Service} subclass instance to expose as a coprocessor endpoint
217 * @return {@code true} if the registration was successful, {@code false}
219 boolean registerService(Service service
);
222 * @return heap memory manager instance
224 HeapMemoryManager
getHeapMemoryManager();
227 * @return the max compaction pressure of all stores on this regionserver. The value should be
228 * greater than or equal to 0.0, and any value greater than 1.0 means we enter the
229 * emergency state that some stores have too many store files.
230 * @see org.apache.hadoop.hbase.regionserver.Store#getCompactionPressure()
232 double getCompactionPressure();
235 * @return the controller to avoid flush too fast
237 ThroughputController
getFlushThroughputController();
240 * @return the flush pressure of all stores on this regionserver. The value should be greater than
241 * or equal to 0.0, and any value greater than 1.0 means we enter the emergency state that
242 * global memstore size already exceeds lower limit.
245 double getFlushPressure();
248 * @return the metrics tracker for the region server
250 MetricsRegionServer
getMetrics();
253 * Master based locks on namespaces/tables/regions.
255 EntityLock
regionLock(List
<RegionInfo
> regionInfos
, String description
,
256 Abortable abort
) throws IOException
;
259 * Unassign the given region from the current regionserver and assign it randomly. Could still be
260 * assigned to us. This is used to solve some tough problems for which you need to reset the state
261 * of a region. For example, if you hit FileNotFound exception and want to refresh the store file
264 * See HBASE-17712 for more details.
266 void unassign(byte[] regionName
) throws IOException
;
269 * Reports the provided Region sizes hosted by this RegionServer to the active Master.
271 * @param sizeStore The sizes for Regions locally hosted.
272 * @return {@code false} if reporting should be temporarily paused, {@code true} otherwise.
274 boolean reportRegionSizesForQuotas(RegionSizeStore sizeStore
);
277 * Reports a collection of files, and their sizes, that belonged to the given {@code table} were
278 * just moved to the archive directory.
280 * @param tableName The name of the table that files previously belonged to
281 * @param archivedFiles Files and their sizes that were moved to archive
282 * @return {@code true} if the files were successfully reported, {@code false} otherwise.
284 boolean reportFileArchivalForQuotas(
285 TableName tableName
, Collection
<Entry
<String
,Long
>> archivedFiles
);
288 * @return True if cluster is up; false if cluster is not up (we are shutting down).
290 boolean isClusterUp();
293 * @return Return the object that implements the replication source executorService.
295 ReplicationSourceService
getReplicationSourceService();
298 * @return Return table descriptors implementation.
300 TableDescriptors
getTableDescriptors();
303 * @return The block cache instance.
305 Optional
<BlockCache
> getBlockCache();
308 * @return The cache for mob files.
310 Optional
<MobFileCache
> getMobFileCache();
313 * @return the {@link AccessChecker}
315 AccessChecker
getAccessChecker();
318 * @return {@link ZKPermissionWatcher}
320 ZKPermissionWatcher
getZKPermissionWatcher();
322 RegionReplicationBufferManager
getRegionReplicationBufferManager();
325 HRegion
getRegion(String encodedRegionName
);
328 List
<HRegion
> getRegions(TableName tableName
) throws IOException
;
331 List
<HRegion
> getRegions();