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
19 package org.apache.hadoop.hbase.rsgroup;
20
21
22 import java.io.IOException;
23 import java.util.List;
24 import java.util.Set;
25
26 import org.apache.hadoop.hbase.NamespaceDescriptor;
27 import org.apache.hadoop.hbase.TableName;
28 import org.apache.hadoop.hbase.classification.InterfaceAudience;
29 import org.apache.hadoop.hbase.util.Bytes;
30 import org.apache.hadoop.hbase.net.Address;
31
32 /**
33 * Interface used to manage RSGroupInfo storage. An implementation
34 * has the option to support offline mode.
35 * See {@link RSGroupBasedLoadBalancer}
36 */
37 @InterfaceAudience.Private
38 public interface RSGroupInfoManager {
39
40 String REASSIGN_WAIT_INTERVAL_KEY = "hbase.rsgroup.reassign.wait";
41 long DEFAULT_REASSIGN_WAIT_INTERVAL = 30 * 1000L;
42
43 //Assigned before user tables
44 TableName RSGROUP_TABLE_NAME =
45 TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "rsgroup");
46 String rsGroupZNode = "rsgroup";
47 byte[] META_FAMILY_BYTES = Bytes.toBytes("m");
48 byte[] META_QUALIFIER_BYTES = Bytes.toBytes("i");
49 byte[] ROW_KEY = {0};
50
51 void start();
52
53 /**
54 * Add given RSGroupInfo to existing list of group infos.
55 */
56 void addRSGroup(RSGroupInfo rsGroupInfo) throws IOException;
57
58 /**
59 * Remove a region server group.
60 */
61 void removeRSGroup(String groupName) throws IOException;
62
63 /**
64 * Move servers to a new group.
65 * @param servers list of servers, must be part of the same group
66 * @param srcGroup groupName being moved from
67 * @param dstGroup groupName being moved to
68 * @return Set of servers moved (May be a subset of {@code servers}).
69 */
70 Set<Address> moveServers(Set<Address> servers, String srcGroup, String dstGroup)
71 throws IOException;
72
73 /**
74 * Gets the group info of server.
75 */
76 RSGroupInfo getRSGroupOfServer(Address serverHostPort) throws IOException;
77
78 /**
79 * Gets {@code RSGroupInfo} for the given group name.
80 */
81 RSGroupInfo getRSGroup(String groupName) throws IOException;
82
83 /**
84 * Get the group membership of a table
85 */
86 String getRSGroupOfTable(TableName tableName) throws IOException;
87
88 /**
89 * Set the group membership of a set of tables
90 *
91 * @param tableNames set of tables to move
92 * @param groupName name of group of tables to move to
93 */
94 void moveTables(Set<TableName> tableNames, String groupName) throws IOException;
95
96 /**
97 * List the existing {@code RSGroupInfo}s.
98 */
99 List<RSGroupInfo> listRSGroups() throws IOException;
100
101 /**
102 * Refresh/reload the group information from the persistent store
103 */
104 void refresh() throws IOException;
105
106 /**
107 * Whether the manager is able to fully return group metadata
108 *
109 * @return whether the manager is in online mode
110 */
111 boolean isOnline();
112
113 /**
114 * Move servers and tables to a new group.
115 * @param servers list of servers, must be part of the same group
116 * @param tables set of tables to move
117 * @param srcGroup groupName being moved from
118 * @param dstGroup groupName being moved to
119 */
120 void moveServersAndTables(Set<Address> servers, Set<TableName> tables,
121 String srcGroup, String dstGroup) throws IOException;
122
123 /**
124 * Remove decommissioned servers from rsgroup
125 * @param servers set of servers to remove
126 */
127 void removeServers(Set<Address> servers) throws IOException;
128
129 /**
130 * Rename RSGroup
131 * @param oldName old rsgroup name
132 * @param newName new rsgroup name
133 */
134 void renameRSGroup(String oldName, String newName) throws IOException;
135 }