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
FieldsModifier and TypeFieldDescriptionstatic final Stringprivate static final org.slf4j.Loggerprivate MasterServicesprivate final RSGroupInfoManager -
Constructor Summary
ConstructorsConstructorDescriptionRSGroupAdminServer(MasterServices master, RSGroupInfoManager rsGroupInfoManager) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddRegion(LinkedList<RegionInfo> regions, RegionInfo hri) voidaddRSGroup(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 voidcheckForDeadOrOnlineServers(Set<Address> servers) Check if the set of servers are belong to dead servers list or online servers list.private voidcheckOnlineServersOnly(Set<Address> servers) private voidCheck servers and tables.private RSGroupInfogetAndCheckRSGroupInfo(String name) Check passed name.private Addressprivate 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) GetsRSGroupInfofor given group name.getRSGroupInfoOfTable(TableName tableName) GetsRSGroupInfofor the given table's group.getRSGroupOfServer(Address hostPort) Retrieve the RSGroupInfo a server is affiliated toLists current set of RegionServer groups.(package private) voidmodifyOrMoveTables(Set<TableName> tables, RSGroupInfo targetGroup) modifyTables(Set<TableDescriptor> tableDescriptors, String targetGroup) private voidmodifyTablesAndWaitForCompletion(Set<TableDescriptor> tableDescriptors, String targetGroup) private voidmoveServerRegionsFromGroup(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.voidmoveServers(Set<Address> servers, String targetGroupName) Move given set of servers to the specified target RegionServer group.voidMove given set of servers and tables to the specified target RegionServer group.private voidmoveTableRegionsToGroup(Set<TableName> tables, RSGroupInfo targetGrp) Moves regions of tables which are not on target group servers.voidmoveTables(Set<TableName> tables, String targetGroup) Move given set of tables to the specified target RegionServer group.voidremoveRSGroup(String name) Removes RegionServer group associated with the given name.voidremoveServers(Set<Address> servers) Remove decommissioned servers from rsgroup.voidrenameRSGroup(String oldName, String newName) Rename rsgroup.private Map<String,RegionState> rsGroupGetRegionsInTransition(String groupName) voidupdateConfiguration(String groupName) Because theRSGroupAdminClient.updateConfiguration(String)callsAdmin.updateConfiguration(ServerName)method, the implementation of this method on the Server side is empty.voidupdateRSGroupConfig(String groupName, Map<String, String> configuration) Update RSGroup configurationprivate voidwaitForProcedureCompletion(List<Long> procIds) private booleanwaitForRegionMovement(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, waitMethods 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:RSGroupAdminGetsRSGroupInfofor given group name.- Specified by:
getRSGroupInfoin interfaceRSGroupAdmin- Throws:
IOException
-
getRSGroupInfoOfTable
Description copied from interface:RSGroupAdminGetsRSGroupInfofor the given table's group.- Specified by:
getRSGroupInfoOfTablein 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:RSGroupAdminMove given set of servers to the specified target RegionServer group.- Specified by:
moveServersin interfaceRSGroupAdmin- Throws:
IOException
-
moveTables
Description copied from interface:RSGroupAdminMove 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:
moveTablesin interfaceRSGroupAdmin- Throws:
IOException
-
addRSGroup
Description copied from interface:RSGroupAdminCreates a new RegionServer group with the given name.- Specified by:
addRSGroupin interfaceRSGroupAdmin- Throws:
IOException
-
removeRSGroup
Description copied from interface:RSGroupAdminRemoves RegionServer group associated with the given name.- Specified by:
removeRSGroupin interfaceRSGroupAdmin- Throws:
IOException
-
balanceRSGroup
Description copied from interface:RSGroupAdminBalance regions in the given RegionServer group, running based on the givenBalanceRequest.- Specified by:
balanceRSGroupin interfaceRSGroupAdmin- Returns:
- boolean Whether balance ran or not
- Throws:
IOException
-
listRSGroups
Description copied from interface:RSGroupAdminLists current set of RegionServer groups.- Specified by:
listRSGroupsin interfaceRSGroupAdmin- Throws:
IOException
-
getRSGroupOfServer
Description copied from interface:RSGroupAdminRetrieve the RSGroupInfo a server is affiliated to- Specified by:
getRSGroupOfServerin 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:RSGroupAdminMove given set of servers and tables to the specified target RegionServer group.- Specified by:
moveServersAndTablesin 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:RSGroupAdminRemove 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:
removeServersin interfaceRSGroupAdmin- Parameters:
servers- set of servers to remove- Throws:
IOException
-
renameRSGroup
Description copied from interface:RSGroupAdminRename rsgroup.- Specified by:
renameRSGroupin 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:RSGroupAdminUpdate RSGroup configuration- Specified by:
updateRSGroupConfigin 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:
updateConfigurationin 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
-