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 21 package org.apache.hadoop.hbase.rsgroup; 22 23 import com.google.common.net.HostAndPort; 24 25 import java.io.IOException; 26 import java.util.List; 27 import java.util.Set; 28 29 import org.apache.hadoop.hbase.NamespaceDescriptor; 30 import org.apache.hadoop.hbase.TableName; 31 import org.apache.hadoop.hbase.util.Bytes; 32 33 /** 34 * Interface used to manage RSGroupInfo storage. An implementation 35 * has the option to support offline mode. 36 * See {@link RSGroupBasedLoadBalancer} 37 */ 38 public interface RSGroupInfoManager { 39 //Assigned before user tables 40 public static final TableName RSGROUP_TABLE_NAME = 41 TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "rsgroup"); 42 public static final byte[] RSGROUP_TABLE_NAME_BYTES = RSGROUP_TABLE_NAME.toBytes(); 43 public static final String rsGroupZNode = "rsgroup"; 44 public static final byte[] META_FAMILY_BYTES = Bytes.toBytes("m"); 45 public static final byte[] META_QUALIFIER_BYTES = Bytes.toBytes("i"); 46 public static final byte[] ROW_KEY = {0}; 47 48 49 /** 50 * Adds the group. 51 * 52 * @param rsGroupInfo the group name 53 * @throws java.io.IOException Signals that an I/O exception has occurred. 54 */ 55 void addRSGroup(RSGroupInfo rsGroupInfo) throws IOException; 56 57 /** 58 * Remove a region server group. 59 * 60 * @param groupName the group name 61 * @throws java.io.IOException Signals that an I/O exception has occurred. 62 */ 63 void removeRSGroup(String groupName) throws IOException; 64 65 /** 66 * move servers to a new group. 67 * @param hostPorts list of servers, must be part of the same group 68 * @param srcGroup groupName being moved from 69 * @param dstGroup groupName being moved to 70 * @return true if move was successful 71 * @throws java.io.IOException on move failure 72 */ 73 boolean moveServers(Set<HostAndPort> hostPorts, 74 String srcGroup, String dstGroup) throws IOException; 75 76 /** 77 * Gets the group info of server. 78 * 79 * @param hostPort the server 80 * @return An instance of RSGroupInfo 81 */ 82 RSGroupInfo getRSGroupOfServer(HostAndPort hostPort) throws IOException; 83 84 /** 85 * Gets the group information. 86 * 87 * @param groupName the group name 88 * @return An instance of RSGroupInfo 89 */ 90 RSGroupInfo getRSGroup(String groupName) throws IOException; 91 92 /** 93 * Get the group membership of a table 94 * @param tableName name of table to get group membership 95 * @return Group name of table 96 * @throws java.io.IOException on failure to retrive information 97 */ 98 String getRSGroupOfTable(TableName tableName) throws IOException; 99 100 /** 101 * Set the group membership of a set of tables 102 * 103 * @param tableNames set of tables to move 104 * @param groupName name of group of tables to move to 105 * @throws java.io.IOException on failure to move 106 */ 107 void moveTables(Set<TableName> tableNames, String groupName) throws IOException; 108 109 /** 110 * List the groups 111 * 112 * @return list of RSGroupInfo 113 * @throws java.io.IOException on failure 114 */ 115 List<RSGroupInfo> listRSGroups() throws IOException; 116 117 /** 118 * Refresh/reload the group information from 119 * the persistent store 120 * 121 * @throws java.io.IOException on failure to refresh 122 */ 123 void refresh() throws IOException; 124 125 /** 126 * Whether the manager is able to fully 127 * return group metadata 128 * 129 * @return whether the manager is in online mode 130 */ 131 boolean isOnline(); 132 }