View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.rsgroup;
19  
20  import java.io.Closeable;
21  import java.io.IOException;
22  import java.util.List;
23  import java.util.Set;
24  
25  import org.apache.hadoop.hbase.TableName;
26  import org.apache.hadoop.hbase.classification.InterfaceAudience;
27  import org.apache.hadoop.hbase.net.Address;
28  
29  /**
30   * Group user API interface used between client and server.
31   */
32  @InterfaceAudience.Private
33  public interface RSGroupAdmin extends Closeable {
34    /**
35     * Gets {@code RSGroupInfo} for given group name.
36     */
37    RSGroupInfo getRSGroupInfo(String groupName) throws IOException;
38  
39    /**
40     * Gets {@code RSGroupInfo} for the given table's group.
41     */
42    RSGroupInfo getRSGroupInfoOfTable(TableName tableName) throws IOException;
43  
44    /**
45     * Move given set of servers to the specified target RegionServer group.
46     */
47    void moveServers(Set<Address> servers, String targetGroup) throws IOException;
48  
49    /**
50     * Move given set of tables to the specified target RegionServer group.
51     * This will unassign all of a table's region so it can be reassigned to the correct group.
52     */
53    void moveTables(Set<TableName> tables, String targetGroup) throws IOException;
54  
55    /**
56     * Creates a new RegionServer group with the given name.
57     */
58    void addRSGroup(String groupName) throws IOException;
59  
60    /**
61     * Removes RegionServer group associated with the given name.
62     */
63    void removeRSGroup(String groupName) throws IOException;
64  
65    /**
66     * Balance regions in the given RegionServer group.
67     *
68     * @return boolean Whether balance ran or not
69     */
70    boolean balanceRSGroup(String groupName) throws IOException;
71  
72    /**
73     * Lists current set of RegionServer groups.
74     */
75    List<RSGroupInfo> listRSGroups() throws IOException;
76  
77    /**
78     * Retrieve the RSGroupInfo a server is affiliated to
79     * @param hostPort HostPort to get RSGroupInfo for
80     */
81    RSGroupInfo getRSGroupOfServer(Address hostPort) throws IOException;
82  
83    /**
84     * Move given set of servers and tables to the specified target RegionServer group.
85     * @param servers set of servers to move
86     * @param tables set of tables to move
87     * @param targetGroup the target group name
88     * @throws IOException
89     */
90    void moveServersAndTables(Set<Address> servers, Set<TableName> tables,
91                              String targetGroup) throws IOException;
92  
93    /**
94     * Remove decommissioned servers from rsgroup.
95     * 1. Sometimes we may find the server aborted due to some hardware failure and we must offline
96     * the server for repairing. Or we need to move some servers to join other clusters.
97     * So we need to remove these servers from the rsgroup.
98     * 2. Dead/recovering/live servers will be disallowed.
99     * @param servers set of servers to remove
100    */
101   void removeServers(Set<Address> servers) throws IOException;
102 
103   /**
104    * Rename rsgroup.
105    * @param oldName old rsgroup name
106    * @param newName new rsgroup name
107    */
108   void renameRSGroup(String oldName, String newName) throws IOException;
109 }