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
24 import org.apache.hadoop.classification.InterfaceAudience;
25 import org.apache.hadoop.hbase.Server;
26 import org.apache.hadoop.hbase.ServerName;
27
28 /**
29 * Interface to Map of online regions. In the Map, the key is the region's
30 * encoded name and the value is an {@link HRegion} instance.
31 */
32 @InterfaceAudience.Private
33 interface OnlineRegions extends Server {
34 /**
35 * Add to online regions.
36 * @param r
37 */
38 public void addToOnlineRegions(final HRegion r);
39
40 /**
41 * This method removes HRegion corresponding to hri from the Map of onlineRegions.
42 *
43 * @param r Region to remove.
44 * @param destination Destination, if any, null otherwise.
45 * @return True if we removed a region from online list.
46 */
47 public boolean removeFromOnlineRegions(final HRegion r, ServerName destination);
48
49 /**
50 * Return {@link HRegion} instance.
51 * Only works if caller is in same context, in same JVM. HRegion is not
52 * serializable.
53 * @param encodedRegionName
54 * @return HRegion for the passed encoded <code>encodedRegionName</code> or
55 * null if named region is not member of the online regions.
56 */
57 public HRegion getFromOnlineRegions(String encodedRegionName);
58
59 /**
60 * Get all online regions of a table in this RS.
61 * @param tableName
62 * @return List of HRegion
63 * @throws java.io.IOException
64 */
65 public List<HRegion> getOnlineRegions(byte[] tableName) throws IOException;
66 }