001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019package org.apache.hadoop.hbase.rsgroup; 020 021 022import java.io.IOException; 023import java.util.List; 024import java.util.Map; 025import java.util.Set; 026 027import org.apache.hadoop.hbase.NamespaceDescriptor; 028import org.apache.hadoop.hbase.TableName; 029import org.apache.hadoop.hbase.net.Address; 030import org.apache.hadoop.hbase.util.Bytes; 031import org.apache.yetus.audience.InterfaceAudience; 032 033/** 034 * Interface used to manage RSGroupInfo storage. An implementation 035 * has the option to support offline mode. 036 * See {@link RSGroupBasedLoadBalancer} 037 */ 038@InterfaceAudience.Private 039public interface RSGroupInfoManager { 040 041 String REASSIGN_WAIT_INTERVAL_KEY = "hbase.rsgroup.reassign.wait"; 042 long DEFAULT_REASSIGN_WAIT_INTERVAL = 30 * 1000L; 043 044 //Assigned before user tables 045 TableName RSGROUP_TABLE_NAME = 046 TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "rsgroup"); 047 String rsGroupZNode = "rsgroup"; 048 byte[] META_FAMILY_BYTES = Bytes.toBytes("m"); 049 byte[] META_QUALIFIER_BYTES = Bytes.toBytes("i"); 050 byte[] ROW_KEY = {0}; 051 052 void start(); 053 054 /** 055 * Add given RSGroupInfo to existing list of group infos. 056 */ 057 void addRSGroup(RSGroupInfo rsGroupInfo) throws IOException; 058 059 /** 060 * Remove a region server group. 061 */ 062 void removeRSGroup(String groupName) throws IOException; 063 064 /** 065 * Move servers to a new group. 066 * @param servers list of servers, must be part of the same group 067 * @param srcGroup groupName being moved from 068 * @param dstGroup groupName being moved to 069 * @return Set of servers moved (May be a subset of {@code servers}). 070 */ 071 Set<Address> moveServers(Set<Address> servers, String srcGroup, String dstGroup) 072 throws IOException; 073 074 /** 075 * Gets the group info of server. 076 */ 077 RSGroupInfo getRSGroupOfServer(Address serverHostPort) throws IOException; 078 079 /** 080 * Gets {@code RSGroupInfo} for the given group name. 081 */ 082 RSGroupInfo getRSGroup(String groupName) throws IOException; 083 084 /** 085 * Get the group membership of a table 086 */ 087 String getRSGroupOfTable(TableName tableName) throws IOException; 088 089 /** 090 * Set the group membership of a set of tables 091 * 092 * @param tableNames set of tables to move 093 * @param groupName name of group of tables to move to 094 */ 095 void moveTables(Set<TableName> tableNames, String groupName) throws IOException; 096 097 /** 098 * List the existing {@code RSGroupInfo}s. 099 */ 100 List<RSGroupInfo> listRSGroups() throws IOException; 101 102 /** 103 * Refresh/reload the group information from the persistent store 104 */ 105 void refresh() throws IOException; 106 107 /** 108 * Whether the manager is able to fully return group metadata 109 * 110 * @return whether the manager is in online mode 111 */ 112 boolean isOnline(); 113 114 /** 115 * Move servers and tables to a new group. 116 * @param servers list of servers, must be part of the same group 117 * @param tables set of tables to move 118 * @param srcGroup groupName being moved from 119 * @param dstGroup groupName being moved to 120 */ 121 void moveServersAndTables(Set<Address> servers, Set<TableName> tables, 122 String srcGroup, String dstGroup) throws IOException; 123 124 /** 125 * Remove decommissioned servers from rsgroup 126 * @param servers set of servers to remove 127 */ 128 void removeServers(Set<Address> servers) throws IOException; 129 130 /** 131 * Rename RSGroup 132 * @param oldName old rsgroup name 133 * @param newName new rsgroup name 134 */ 135 void renameRSGroup(String oldName, String newName) throws IOException; 136 137 /** 138 * Determine {@code RSGroupInfo} for the given table. 139 * @param tableName table name 140 * @return {@link RSGroupInfo} which table should belong to 141 */ 142 RSGroupInfo determineRSGroupInfoForTable(TableName tableName) throws IOException; 143 144 /** 145 * Update RSGroup configuration 146 * @param groupName the group name 147 * @param configuration new configuration of the group name to be set 148 * @throws IOException if a remote or network exception occurs 149 */ 150 void updateRSGroupConfig(String groupName, Map<String, String> configuration) throws IOException; 151}