Package org.apache.hadoop.hbase.rsgroup
Class RSGroupAdminServer
java.lang.Object
org.apache.hadoop.hbase.rsgroup.RSGroupAdminServer
- All Implemented Interfaces:
RSGroupAdmin
Service to support Region Server Grouping (HBase-6721).
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
private static final org.slf4j.Logger
private MasterServices
private final RSGroupInfoManager
-
Constructor Summary
ConstructorDescriptionRSGroupAdminServer
(MasterServices master, RSGroupInfoManager rsGroupInfoManager) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addRegion
(LinkedList<RegionInfo> regions, RegionInfo hri) void
addRSGroup
(String name) Creates a new RegionServer group with the given name.balanceRSGroup
(String groupName, BalanceRequest request) Balance regions in the given RegionServer group, running based on the givenBalanceRequest
.private void
checkForDeadOrOnlineServers
(Set<Address> servers) Check if the set of servers are belong to dead servers list or online servers list.private void
checkOnlineServersOnly
(Set<Address> servers) private void
Check servers and tables.private RSGroupInfo
getAndCheckRSGroupInfo
(String name) Check passed name.private Address
private List<RegionInfo>
getRegions
(Address server) Returns List of Regions associated with thisserver
.(package private) Map<TableName,
Map<ServerName, List<RegionInfo>>> getRSGroupAssignmentsByTable
(TableStateManager tableStateManager, String groupName) This is an EXPENSIVE clone.getRSGroupInfo
(String groupName) GetsRSGroupInfo
for given group name.getRSGroupInfoOfTable
(TableName tableName) GetsRSGroupInfo
for the given table's group.getRSGroupOfServer
(Address hostPort) Retrieve the RSGroupInfo a server is affiliated toLists current set of RegionServer groups.(package private) void
modifyOrMoveTables
(Set<TableName> tables, RSGroupInfo targetGroup) modifyTables
(Set<TableDescriptor> tableDescriptors, String targetGroup) private void
modifyTablesAndWaitForCompletion
(Set<TableDescriptor> tableDescriptors, String targetGroup) private void
moveServerRegionsFromGroup
(Set<Address> movedServers, Set<TableName> movedTables, Set<Address> srcGrpServers, String targetGroupName, String sourceGroupName) Move every region from servers which are currently located on these servers, but should not be located there.void
moveServers
(Set<Address> servers, String targetGroupName) Move given set of servers to the specified target RegionServer group.void
Move given set of servers and tables to the specified target RegionServer group.private void
moveTableRegionsToGroup
(Set<TableName> tables, RSGroupInfo targetGrp) Moves regions of tables which are not on target group servers.void
moveTables
(Set<TableName> tables, String targetGroup) Move given set of tables to the specified target RegionServer group.void
removeRSGroup
(String name) Removes RegionServer group associated with the given name.void
removeServers
(Set<Address> servers) Remove decommissioned servers from rsgroup.void
renameRSGroup
(String oldName, String newName) Rename rsgroup.private Map<String,
RegionState> rsGroupGetRegionsInTransition
(String groupName) void
updateConfiguration
(String groupName) Because theRSGroupAdminClient.updateConfiguration(String)
callsAdmin.updateConfiguration(ServerName)
method, the implementation of this method on the Server side is empty.void
updateRSGroupConfig
(String groupName, Map<String, String> configuration) Update RSGroup configurationprivate void
waitForProcedureCompletion
(List<Long> procIds) private boolean
waitForRegionMovement
(List<Pair<RegionInfo, Future<byte[]>>> regionMoveFutures, String groupName, int retryCount) Wait for all the region move to complete.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.rsgroup.RSGroupAdmin
balanceRSGroup
-
Field Details
-
LOG
-
KEEP_ONE_SERVER_IN_DEFAULT_ERROR_MESSAGE
- See Also:
-
master
-
rsGroupInfoManager
-
-
Constructor Details
-
RSGroupAdminServer
-
-
Method Details
-
getRSGroupInfo
Description copied from interface:RSGroupAdmin
GetsRSGroupInfo
for given group name.- Specified by:
getRSGroupInfo
in interfaceRSGroupAdmin
- Throws:
IOException
-
getRSGroupInfoOfTable
Description copied from interface:RSGroupAdmin
GetsRSGroupInfo
for the given table's group.- Specified by:
getRSGroupInfoOfTable
in interfaceRSGroupAdmin
- Throws:
IOException
-
checkOnlineServersOnly
- Throws:
ConstraintException
-
getAndCheckRSGroupInfo
Check passed name. Fail if nulls or if corresponding RSGroupInfo not found.- Returns:
- The RSGroupInfo named
name
- Throws:
IOException
-
getRegions
Returns List of Regions associated with thisserver
. -
addRegion
-
checkServersAndTables
private void checkServersAndTables(Set<Address> servers, Set<TableName> tables, String targetGroupName) throws IOException Check servers and tables.- Parameters:
servers
- servers to movetables
- tables to movetargetGroupName
- target group name- Throws:
IOException
- if nulls or if servers and tables not belong to the same group
-
moveServerRegionsFromGroup
private void moveServerRegionsFromGroup(Set<Address> movedServers, Set<TableName> movedTables, Set<Address> srcGrpServers, String targetGroupName, String sourceGroupName) throws IOException Move every region from servers which are currently located on these servers, but should not be located there.- Parameters:
movedServers
- the servers that are moved to new groupmovedTables
- the tables that are moved to new groupsrcGrpServers
- all servers in the source group, excluding the movedServerstargetGroupName
- the target groupsourceGroupName
- the source group- Throws:
IOException
- if any error while moving regions
-
getRegionAddress
-
waitForRegionMovement
private boolean waitForRegionMovement(List<Pair<RegionInfo, Future<byte[]>>> regionMoveFutures, String groupName, int retryCount) Wait for all the region move to complete. Keep waiting for other region movement completion even if some region movement fails. -
moveTableRegionsToGroup
private void moveTableRegionsToGroup(Set<TableName> tables, RSGroupInfo targetGrp) throws IOException Moves regions of tables which are not on target group servers.- Parameters:
tables
- the tables that will move to new grouptargetGrp
- the target group- Throws:
IOException
- if moving the region fails
-
moveServers
Description copied from interface:RSGroupAdmin
Move given set of servers to the specified target RegionServer group.- Specified by:
moveServers
in interfaceRSGroupAdmin
- Throws:
IOException
-
moveTables
Description copied from interface:RSGroupAdmin
Move given set of tables to the specified target RegionServer group. This will unassign all of a table's region so it can be reassigned to the correct group.- Specified by:
moveTables
in interfaceRSGroupAdmin
- Throws:
IOException
-
addRSGroup
Description copied from interface:RSGroupAdmin
Creates a new RegionServer group with the given name.- Specified by:
addRSGroup
in interfaceRSGroupAdmin
- Throws:
IOException
-
removeRSGroup
Description copied from interface:RSGroupAdmin
Removes RegionServer group associated with the given name.- Specified by:
removeRSGroup
in interfaceRSGroupAdmin
- Throws:
IOException
-
balanceRSGroup
Description copied from interface:RSGroupAdmin
Balance regions in the given RegionServer group, running based on the givenBalanceRequest
.- Specified by:
balanceRSGroup
in interfaceRSGroupAdmin
- Returns:
- boolean Whether balance ran or not
- Throws:
IOException
-
listRSGroups
Description copied from interface:RSGroupAdmin
Lists current set of RegionServer groups.- Specified by:
listRSGroups
in interfaceRSGroupAdmin
- Throws:
IOException
-
getRSGroupOfServer
Description copied from interface:RSGroupAdmin
Retrieve the RSGroupInfo a server is affiliated to- Specified by:
getRSGroupOfServer
in interfaceRSGroupAdmin
- Parameters:
hostPort
- HostPort to get RSGroupInfo for- Throws:
IOException
-
moveServersAndTables
public void moveServersAndTables(Set<Address> servers, Set<TableName> tables, String targetGroup) throws IOException Description copied from interface:RSGroupAdmin
Move given set of servers and tables to the specified target RegionServer group.- Specified by:
moveServersAndTables
in interfaceRSGroupAdmin
- Parameters:
servers
- set of servers to movetables
- set of tables to movetargetGroup
- the target group name- Throws:
IOException
- if moving the server and tables fail
-
removeServers
Description copied from interface:RSGroupAdmin
Remove decommissioned servers from rsgroup. 1. Sometimes we may find the server aborted due to some hardware failure and we must offline the server for repairing. Or we need to move some servers to join other clusters. So we need to remove these servers from the rsgroup. 2. Dead/recovering/live servers will be disallowed.- Specified by:
removeServers
in interfaceRSGroupAdmin
- Parameters:
servers
- set of servers to remove- Throws:
IOException
-
renameRSGroup
Description copied from interface:RSGroupAdmin
Rename rsgroup.- Specified by:
renameRSGroup
in interfaceRSGroupAdmin
- Parameters:
oldName
- old rsgroup namenewName
- new rsgroup name- Throws:
IOException
-
updateRSGroupConfig
public void updateRSGroupConfig(String groupName, Map<String, String> configuration) throws IOExceptionDescription copied from interface:RSGroupAdmin
Update RSGroup configuration- Specified by:
updateRSGroupConfig
in interfaceRSGroupAdmin
- Parameters:
groupName
- the group nameconfiguration
- new configuration of the group name to be set- Throws:
IOException
- if a remote or network exception occurs
-
updateConfiguration
Because theRSGroupAdminClient.updateConfiguration(String)
callsAdmin.updateConfiguration(ServerName)
method, the implementation of this method on the Server side is empty.- Specified by:
updateConfiguration
in interfaceRSGroupAdmin
- Parameters:
groupName
- the group name- Throws:
IOException
- if a remote or network exception occurs
-
rsGroupGetRegionsInTransition
- Throws:
IOException
-
getRSGroupAssignmentsByTable
Map<TableName,Map<ServerName, getRSGroupAssignmentsByTableList<RegionInfo>>> (TableStateManager tableStateManager, String groupName) throws IOException This is an EXPENSIVE clone. Cloning though is the safest thing to do. Can't let out original since it can change and at least the load balancer wants to iterate this exported list. Load balancer should iterate over this list because cloned list will ignore disabled table and split parent region cases. This method is invoked bybalanceRSGroup(java.lang.String, org.apache.hadoop.hbase.client.BalanceRequest)
- Returns:
- A clone of current assignments for this group.
- Throws:
IOException
-
checkForDeadOrOnlineServers
Check if the set of servers are belong to dead servers list or online servers list.- Parameters:
servers
- servers to remove- Throws:
ConstraintException
-
modifyOrMoveTables
- Throws:
IOException
-
modifyTablesAndWaitForCompletion
private void modifyTablesAndWaitForCompletion(Set<TableDescriptor> tableDescriptors, String targetGroup) throws IOException - Throws:
IOException
-
modifyTables
private List<Long> modifyTables(Set<TableDescriptor> tableDescriptors, String targetGroup) throws IOException - Throws:
IOException
-
waitForProcedureCompletion
- Throws:
IOException
-