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
.throttle
.ThroughputController
;
42 import org
.apache
.hadoop
.hbase
.security
.access
.AccessChecker
;
43 import org
.apache
.hadoop
.hbase
.security
.access
.ZKPermissionWatcher
;
44 import org
.apache
.hadoop
.hbase
.wal
.WAL
;
45 import org
.apache
.yetus
.audience
.InterfaceAudience
;
47 import org
.apache
.hbase
.thirdparty
.com
.google
.protobuf
.Service
;
49 import org
.apache
.hadoop
.hbase
.shaded
.protobuf
.generated
.RegionServerStatusProtos
.RegionStateTransition
.TransitionCode
;
52 * A curated subset of services provided by {@link HRegionServer}.
53 * For use internally only. Passed to Managers, Services and Chores so can pass less-than-a
54 * full-on HRegionServer at test-time. Be judicious adding API. Changes cause ripples through
57 @InterfaceAudience.Private
58 public interface RegionServerServices
extends Server
, MutableOnlineRegions
, FavoredNodesForRegion
{
60 /** @return the WAL for a particular region. Pass null for getting the
61 * default (common) WAL */
62 WAL
getWAL(RegionInfo regionInfo
) throws IOException
;
64 /** @return the List of WALs that are used by this server
65 * Doesn't include the meta WAL
67 List
<WAL
> getWALs() throws IOException
;
70 * @return Implementation of {@link FlushRequester} or null. Usually it will not be null unless
71 * during intialization.
73 FlushRequester
getFlushRequester();
76 * @return Implementation of {@link CompactionRequester} or null. Usually it will not be null
77 * unless during intialization.
79 CompactionRequester
getCompactionRequestor();
82 * @return the RegionServerAccounting for this Region Server
84 RegionServerAccounting
getRegionServerAccounting();
87 * @return RegionServer's instance of {@link RegionServerRpcQuotaManager}
89 RegionServerRpcQuotaManager
getRegionServerRpcQuotaManager();
92 * @return RegionServer's instance of {@link SecureBulkLoadManager}
94 SecureBulkLoadManager
getSecureBulkLoadManager();
97 * @return RegionServer's instance of {@link RegionServerSpaceQuotaManager}
99 RegionServerSpaceQuotaManager
getRegionServerSpaceQuotaManager();
102 * Context for postOpenDeployTasks().
104 class PostOpenDeployContext
{
105 private final HRegion region
;
106 private final long openProcId
;
107 private final long masterSystemTime
;
109 public PostOpenDeployContext(HRegion region
, long openProcId
, long masterSystemTime
) {
110 this.region
= region
;
111 this.openProcId
= openProcId
;
112 this.masterSystemTime
= masterSystemTime
;
115 public HRegion
getRegion() {
119 public long getOpenProcId() {
123 public long getMasterSystemTime() {
124 return masterSystemTime
;
129 * Tasks to perform after region open to complete deploy of region on regionserver
130 * @param context the context
132 void postOpenDeployTasks(final PostOpenDeployContext context
) throws IOException
;
134 class RegionStateTransitionContext
{
135 private final TransitionCode code
;
136 private final long openSeqNum
;
137 private final long masterSystemTime
;
138 private final long[] procIds
;
139 private final RegionInfo
[] hris
;
141 public RegionStateTransitionContext(TransitionCode code
, long openSeqNum
, long masterSystemTime
,
142 RegionInfo
... hris
) {
144 this.openSeqNum
= openSeqNum
;
145 this.masterSystemTime
= masterSystemTime
;
147 this.procIds
= new long[hris
.length
];
150 public RegionStateTransitionContext(TransitionCode code
, long openSeqNum
, long procId
,
151 long masterSystemTime
, RegionInfo hri
) {
153 this.openSeqNum
= openSeqNum
;
154 this.masterSystemTime
= masterSystemTime
;
155 this.hris
= new RegionInfo
[] { hri
};
156 this.procIds
= new long[] { procId
};
159 public TransitionCode
getCode() {
163 public long getOpenSeqNum() {
167 public long getMasterSystemTime() {
168 return masterSystemTime
;
171 public RegionInfo
[] getHris() {
175 public long[] getProcIds() {
181 * Notify master that a handler requests to change a region state
183 boolean reportRegionStateTransition(final RegionStateTransitionContext context
);
186 * Returns a reference to the region server's RPC server
188 RpcServerInterface
getRpcServer();
191 * Get the regions that are currently being opened or closed in the RS
192 * @return map of regions in transition in this RS
194 ConcurrentMap
<byte[], Boolean
> getRegionsInTransitionInRS();
197 * @return The RegionServer's "Leases" service
199 LeaseManager
getLeaseManager();
202 * @return hbase executor service
204 ExecutorService
getExecutorService();
207 * Only required for "old" log replay; if it's removed, remove this.
208 * @return The RegionServer's NonceManager
210 ServerNonceManager
getNonceManager();
213 * Registers a new protocol buffer {@link Service} subclass as a coprocessor endpoint to be
214 * available for handling
215 * @param service the {@code Service} subclass instance to expose as a coprocessor endpoint
216 * @return {@code true} if the registration was successful, {@code false}
218 boolean registerService(Service service
);
221 * @return heap memory manager instance
223 HeapMemoryManager
getHeapMemoryManager();
226 * @return the max compaction pressure of all stores on this regionserver. The value should be
227 * greater than or equal to 0.0, and any value greater than 1.0 means we enter the
228 * emergency state that some stores have too many store files.
229 * @see org.apache.hadoop.hbase.regionserver.Store#getCompactionPressure()
231 double getCompactionPressure();
234 * @return the controller to avoid flush too fast
236 ThroughputController
getFlushThroughputController();
239 * @return the flush pressure of all stores on this regionserver. The value should be greater than
240 * or equal to 0.0, and any value greater than 1.0 means we enter the emergency state that
241 * global memstore size already exceeds lower limit.
244 double getFlushPressure();
247 * @return the metrics tracker for the region server
249 MetricsRegionServer
getMetrics();
252 * Master based locks on namespaces/tables/regions.
254 EntityLock
regionLock(List
<RegionInfo
> regionInfos
, String description
,
255 Abortable abort
) throws IOException
;
258 * Unassign the given region from the current regionserver and assign it randomly. Could still be
259 * assigned to us. This is used to solve some tough problems for which you need to reset the state
260 * of a region. For example, if you hit FileNotFound exception and want to refresh the store file
263 * See HBASE-17712 for more details.
265 void unassign(byte[] regionName
) throws IOException
;
268 * Reports the provided Region sizes hosted by this RegionServer to the active Master.
270 * @param sizeStore The sizes for Regions locally hosted.
271 * @return {@code false} if reporting should be temporarily paused, {@code true} otherwise.
273 boolean reportRegionSizesForQuotas(RegionSizeStore sizeStore
);
276 * Reports a collection of files, and their sizes, that belonged to the given {@code table} were
277 * just moved to the archive directory.
279 * @param tableName The name of the table that files previously belonged to
280 * @param archivedFiles Files and their sizes that were moved to archive
281 * @return {@code true} if the files were successfully reported, {@code false} otherwise.
283 boolean reportFileArchivalForQuotas(
284 TableName tableName
, Collection
<Entry
<String
,Long
>> archivedFiles
);
287 * @return True if cluster is up; false if cluster is not up (we are shutting down).
289 boolean isClusterUp();
292 * @return Return the object that implements the replication source executorService.
294 ReplicationSourceService
getReplicationSourceService();
297 * @return Return table descriptors implementation.
299 TableDescriptors
getTableDescriptors();
302 * @return The block cache instance.
304 Optional
<BlockCache
> getBlockCache();
307 * @return The cache for mob files.
309 Optional
<MobFileCache
> getMobFileCache();
312 * @return the {@link AccessChecker}
314 AccessChecker
getAccessChecker();
317 * @return {@link ZKPermissionWatcher}
319 ZKPermissionWatcher
getZKPermissionWatcher();