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 */ 018package org.apache.hadoop.hbase.rsgroup; 019 020import java.io.IOException; 021import java.util.List; 022import java.util.Map; 023import java.util.Set; 024 025import org.apache.hadoop.hbase.TableName; 026import org.apache.hadoop.hbase.net.Address; 027import org.apache.yetus.audience.InterfaceAudience; 028 029/** 030 * Group user API interface used between client and server. 031 */ 032@InterfaceAudience.Private 033public interface RSGroupAdmin { 034 /** 035 * Gets {@code RSGroupInfo} for given group name. 036 */ 037 RSGroupInfo getRSGroupInfo(String groupName) throws IOException; 038 039 /** 040 * Gets {@code RSGroupInfo} for the given table's group. 041 */ 042 RSGroupInfo getRSGroupInfoOfTable(TableName tableName) throws IOException; 043 044 /** 045 * Move given set of servers to the specified target RegionServer group. 046 */ 047 void moveServers(Set<Address> servers, String targetGroup) throws IOException; 048 049 /** 050 * Move given set of tables to the specified target RegionServer group. 051 * This will unassign all of a table's region so it can be reassigned to the correct group. 052 */ 053 void moveTables(Set<TableName> tables, String targetGroup) throws IOException; 054 055 /** 056 * Creates a new RegionServer group with the given name. 057 */ 058 void addRSGroup(String groupName) throws IOException; 059 060 /** 061 * Removes RegionServer group associated with the given name. 062 */ 063 void removeRSGroup(String groupName) throws IOException; 064 065 /** 066 * Balance regions in the given RegionServer group. 067 * 068 * @return boolean Whether balance ran or not 069 */ 070 boolean balanceRSGroup(String groupName) throws IOException; 071 072 /** 073 * Lists current set of RegionServer groups. 074 */ 075 List<RSGroupInfo> listRSGroups() throws IOException; 076 077 /** 078 * Retrieve the RSGroupInfo a server is affiliated to 079 * @param hostPort HostPort to get RSGroupInfo for 080 */ 081 RSGroupInfo getRSGroupOfServer(Address hostPort) throws IOException; 082 083 /** 084 * Move given set of servers and tables to the specified target RegionServer group. 085 * @param servers set of servers to move 086 * @param tables set of tables to move 087 * @param targetGroup the target group name 088 * @throws IOException if moving the server and tables fail 089 */ 090 void moveServersAndTables(Set<Address> servers, Set<TableName> tables, 091 String targetGroup) throws IOException; 092 093 /** 094 * Remove decommissioned servers from rsgroup. 095 * 1. Sometimes we may find the server aborted due to some hardware failure and we must offline 096 * the server for repairing. Or we need to move some servers to join other clusters. 097 * So we need to remove these servers from the rsgroup. 098 * 2. Dead/recovering/live servers will be disallowed. 099 * @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 110 /** 111 * Update RSGroup configuration 112 * @param groupName the group name 113 * @param configuration new configuration of the group name to be set 114 * @throws IOException if a remote or network exception occurs 115 */ 116 void updateRSGroupConfig(String groupName, Map<String, String> configuration) throws IOException; 117}