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