1 /**
2 * Copyright The Apache Software Foundation
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 package org.apache.hadoop.hbase.rsgroup;
21
22 import com.google.common.net.HostAndPort;
23
24 import java.io.Closeable;
25 import java.io.IOException;
26 import java.util.List;
27 import java.util.Set;
28
29 import org.apache.hadoop.hbase.TableName;
30 import org.apache.hadoop.hbase.classification.InterfaceAudience;
31 import org.apache.hadoop.hbase.client.Connection;
32
33 /**
34 * Group user API interface used between client and server.
35 */
36 @InterfaceAudience.Private
37 public abstract class RSGroupAdmin implements Closeable {
38
39 /**
40 * Create a new RSGroupAdmin client
41 * @param conn connection RSGroupAdmin instance will use
42 * @return a new RSGroupAdmin client
43 * @throws IOException on failure to create new client
44 */
45 public static RSGroupAdmin newClient(Connection conn) throws IOException {
46 return new RSGroupAdminClient(conn);
47 }
48
49 /**
50 * Gets the regionserver group information.
51 *
52 * @param groupName the group name
53 * @return An instance of RSGroupInfo
54 */
55 public abstract RSGroupInfo getRSGroupInfo(String groupName) throws IOException;
56
57 /**
58 * Gets the regionserver group info of table.
59 *
60 * @param tableName the table name
61 * @return An instance of RSGroupInfo.
62 */
63 public abstract RSGroupInfo getRSGroupInfoOfTable(TableName tableName) throws IOException;
64
65 /**
66 * Move a set of serves to another group
67 *
68 *
69 * @param servers set of servers, must be in the form HOST:PORT
70 * @param targetGroup the target group
71 * @throws java.io.IOException Signals that an I/O exception has occurred.
72 */
73 public abstract void moveServers(Set<HostAndPort> servers, String targetGroup) throws IOException;
74
75 /**
76 * Move tables to a new group.
77 * This will unassign all of a table's region so it can be reassigned to the correct group.
78 * @param tables list of tables to move
79 * @param targetGroup target group
80 * @throws java.io.IOException on failure to move tables
81 */
82 public abstract void moveTables(Set<TableName> tables, String targetGroup) throws IOException;
83
84 /**
85 * Add a new group
86 * @param name name of the group
87 * @throws java.io.IOException on failure to add group
88 */
89 public abstract void addRSGroup(String name) throws IOException;
90
91 /**
92 * Remove a regionserver group
93 * @param name name of the group
94 * @throws java.io.IOException on failure to remove group
95 */
96 public abstract void removeRSGroup(String name) throws IOException;
97
98 /**
99 * Balance the regions in a group
100 *
101 * @param name the name of the group to balance
102 * @return boolean whether balance ran or not
103 * @throws java.io.IOException on unexpected failure to balance group
104 */
105 public abstract boolean balanceRSGroup(String name) throws IOException;
106
107 /**
108 * Lists the existing groups.
109 *
110 * @return Collection of RSGroupInfo.
111 */
112 public abstract List<RSGroupInfo> listRSGroups() throws IOException;
113
114 /**
115 * Retrieve the RSGroupInfo a server is affiliated to
116 * @param hostPort HostPort to get RSGroupInfo for
117 * @return RSGroupInfo associated with the server
118 * @throws java.io.IOException on unexpected failure to retrieve GroupInfo
119 */
120 public abstract RSGroupInfo getRSGroupOfServer(HostAndPort hostPort) throws IOException;
121 }