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