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