@InterfaceAudience.Private final class RSGroupInfoManagerImpl extends Object implements RSGroupInfoManager
RSGroupInfoManager
which makes use of an HBase table as the
persistence store for the group information. It also makes use of zookeeper to store group
information needed for bootstrapping during offline mode.
RSGroupInfoManagerImpl.RSGroupInfoHolder.groupName2Group
. These Maps are persisted to the
hbase:rsgroup table (and cached in zk) on each modification.
Mutations on state are synchronized but reads can continue without having to wait on an instance
monitor, mutations do wholesale replace of the Maps on update -- Copy-On-Write; the local Maps of
state are read-only, just-in-case (see flushConfig).
Reads must not block else there is a danger we'll deadlock.
Clients of this class, the RSGroupAdminEndpoint
for example, want to query and then act
on the results of the query modifying cache in zookeeper without another thread making
intermediate modifications. These clients synchronize on the 'this' instance so no other has
access concurrently. Reads must be able to continue concurrently.Modifier and Type | Class and Description |
---|---|
private static class |
RSGroupInfoManagerImpl.RSGroupInfoHolder |
(package private) static class |
RSGroupInfoManagerImpl.RSGroupMappingScript |
private class |
RSGroupInfoManagerImpl.RSGroupStartupWorker |
Modifier and Type | Field and Description |
---|---|
private AsyncClusterConnection |
conn |
(package private) static int |
DEFAULT_MAX_RETRY_VALUE
Define the default number of retries
|
(package private) static String |
FAILED_MOVE_MAX_RETRY
Define the config key of retries threshold when movements failed
|
private RSGroupInfoManagerImpl.RSGroupInfoHolder |
holder |
(package private) static String |
KEEP_ONE_SERVER_IN_DEFAULT_ERROR_MESSAGE |
private static org.slf4j.Logger |
LOG |
private MasterServices |
masterServices |
(package private) static byte[] |
META_FAMILY_BYTES |
(package private) static byte[] |
META_QUALIFIER_BYTES |
(package private) static String |
MIGRATE_THREAD_NAME |
private Set<String> |
prevRSGroups |
private static byte[] |
ROW_KEY |
private static String |
RS_GROUP_ZNODE |
private static TableDescriptor |
RSGROUP_TABLE_DESC
Table descriptor for
hbase:rsgroup catalog table |
(package private) static TableName |
RSGROUP_TABLE_NAME |
private RSGroupInfoManagerImpl.RSGroupStartupWorker |
rsGroupStartupWorker |
private RSGroupInfoManagerImpl.RSGroupMappingScript |
script |
private ZKWatcher |
watcher |
Modifier | Constructor and Description |
---|---|
private |
RSGroupInfoManagerImpl(MasterServices masterServices) |
Modifier and Type | Method and Description |
---|---|
private void |
addRegion(LinkedList<RegionInfo> regions,
RegionInfo hri) |
void |
addRSGroup(RSGroupInfo rsGroupInfo)
Add given RSGroupInfo to existing list of group infos.
|
BalanceResponse |
balanceRSGroup(String groupName,
BalanceRequest request)
Balance a region server group.
|
private void |
checkForDeadOrOnlineServers(Set<Address> servers)
Check if the set of servers are belong to dead servers list or online servers list.
|
private void |
checkGroupName(String groupName) |
private void |
checkOnlineServersOnly(Set<Address> servers) |
String |
determineRSGroupInfoForTable(TableName tableName)
Determine
RSGroupInfo for the given table. |
private void |
flushConfig() |
private void |
flushConfig(Map<String,RSGroupInfo> newGroupMap) |
private void |
flushConfigTable(Map<String,RSGroupInfo> groupMap) |
private SortedSet<Address> |
getDefaultServers() |
private SortedSet<Address> |
getDefaultServers(List<RSGroupInfo> rsGroupInfoList) |
(package private) static RSGroupInfoManager |
getInstance(MasterServices masterServices) |
private Set<Address> |
getOnlineServers()
Returns Set of online Servers named for their hostname and port (not ServerName).
|
private List<RegionInfo> |
getRegions(Address server)
Returns List of Regions associated with this
server . |
RSGroupInfo |
getRSGroup(String groupName)
Gets
RSGroupInfo for the given group name. |
(package private) Map<TableName,Map<ServerName,List<RegionInfo>>> |
getRSGroupAssignmentsByTable(TableStateManager tableStateManager,
String groupName)
This is an EXPENSIVE clone.
|
RSGroupInfo |
getRSGroupForTable(TableName tableName)
Get
RSGroupInfo for the given table. |
private RSGroupInfo |
getRSGroupInfo(String groupName) |
RSGroupInfo |
getRSGroupOfServer(Address serverHostPort)
Gets the group info of server.
|
private void |
init() |
private static boolean |
isMasterRunning(MasterServices masterServices) |
boolean |
isOnline()
Whether the manager is able to fully return group metadata
|
private boolean |
isTableInGroup(TableName tableName,
String groupName,
Set<TableName> tablesInGroupCache) |
List<RSGroupInfo> |
listRSGroups()
List the existing
RSGroupInfo s. |
private void |
migrate() |
private void |
migrate(Collection<RSGroupInfo> groupList) |
private <T> void |
moveRegionsBetweenGroups(Set<T> regionsOwners,
Set<Address> newRegionsOwners,
String targetGroupName,
String sourceGroupName,
Function<T,List<RegionInfo>> getRegionsInfo,
Function<RegionInfo,Boolean> validation) |
private void |
moveServerRegionsFromGroup(Set<Address> movedServers,
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 servers to a new group.
|
Set<Address> |
moveServers(Set<Address> servers,
String srcGroup,
String dstGroup) |
private void |
moveTablesAndWait(Set<TableName> tables,
String targetGroup) |
private void |
multiMutate(List<Mutation> mutations) |
private void |
refresh(boolean forceOnline)
Read rsgroup info from the source of truth, the hbase:rsgroup table.
|
void |
removeRSGroup(String groupName)
Remove a region server group.
|
void |
removeServers(Set<Address> servers)
Remove decommissioned servers from rsgroup
|
void |
renameRSGroup(String oldName,
String newName)
Rename rsgroup
|
private void |
resetRSGroupMap(Map<String,RSGroupInfo> newRSGroupMap)
Make changes visible.
|
private List<RSGroupInfo> |
retrieveGroupListFromGroupTable() |
private List<RSGroupInfo> |
retrieveGroupListFromZookeeper() |
private Map<String,RegionState> |
rsGroupGetRegionsInTransition(String groupName) |
private void |
saveRSGroupMapToZK(Map<String,RSGroupInfo> newGroupMap) |
void |
setRSGroup(Set<TableName> tables,
String groupName)
Set group for tables.
|
void |
start() |
private void |
updateCacheOfRSGroups(Set<String> currentGroups)
Update cache of rsgroups.
|
private void |
updateDefaultServers() |
void |
updateRSGroupConfig(String groupName,
Map<String,String> configuration)
Update RSGroup configuration
|
private void |
waitForRegionMovement(List<Pair<RegionInfo,Future<byte[]>>> regionMoveFutures,
Set<String> failedRegions,
String sourceGroupName,
int retryCount)
Wait for all the region move to complete.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
create
private static final org.slf4j.Logger LOG
static final TableName RSGROUP_TABLE_NAME
static final String KEEP_ONE_SERVER_IN_DEFAULT_ERROR_MESSAGE
static final String FAILED_MOVE_MAX_RETRY
static final int DEFAULT_MAX_RETRY_VALUE
private static final String RS_GROUP_ZNODE
static final byte[] META_FAMILY_BYTES
static final byte[] META_QUALIFIER_BYTES
static final String MIGRATE_THREAD_NAME
private static final byte[] ROW_KEY
private static final TableDescriptor RSGROUP_TABLE_DESC
hbase:rsgroup
catalog tableprivate volatile RSGroupInfoManagerImpl.RSGroupInfoHolder holder
private final MasterServices masterServices
private final AsyncClusterConnection conn
private final RSGroupInfoManagerImpl.RSGroupStartupWorker rsGroupStartupWorker
private Set<String> prevRSGroups
private RSGroupInfoManagerImpl.RSGroupMappingScript script
private RSGroupInfoManagerImpl(MasterServices masterServices)
private void updateDefaultServers()
private void init() throws IOException
IOException
static RSGroupInfoManager getInstance(MasterServices masterServices) throws IOException
IOException
public void start()
start
in interface RSGroupInfoManager
public void addRSGroup(RSGroupInfo rsGroupInfo) throws IOException
RSGroupInfoManager
addRSGroup
in interface RSGroupInfoManager
IOException
private RSGroupInfo getRSGroupInfo(String groupName) throws ConstraintException
ConstraintException
private Set<Address> getOnlineServers()
public Set<Address> moveServers(Set<Address> servers, String srcGroup, String dstGroup) throws IOException
IOException
public RSGroupInfo getRSGroupOfServer(Address serverHostPort)
RSGroupInfoManager
getRSGroupOfServer
in interface RSGroupInfoManager
public RSGroupInfo getRSGroup(String groupName)
RSGroupInfoManager
RSGroupInfo
for the given group name.getRSGroup
in interface RSGroupInfoManager
public void removeRSGroup(String groupName) throws IOException
RSGroupInfoManager
removeRSGroup
in interface RSGroupInfoManager
IOException
public List<RSGroupInfo> listRSGroups()
RSGroupInfoManager
RSGroupInfo
s.listRSGroups
in interface RSGroupInfoManager
public boolean isOnline()
RSGroupInfoManager
isOnline
in interface RSGroupInfoManager
public void removeServers(Set<Address> servers) throws IOException
RSGroupInfoManager
removeServers
in interface RSGroupInfoManager
servers
- set of servers to removeIOException
private List<RSGroupInfo> retrieveGroupListFromGroupTable() throws IOException
IOException
private List<RSGroupInfo> retrieveGroupListFromZookeeper() throws IOException
IOException
private void migrate(Collection<RSGroupInfo> groupList)
private void migrate()
private void refresh(boolean forceOnline) throws IOException
IOException
private void flushConfigTable(Map<String,RSGroupInfo> groupMap) throws IOException
IOException
private void flushConfig() throws IOException
IOException
private void flushConfig(Map<String,RSGroupInfo> newGroupMap) throws IOException
IOException
private void saveRSGroupMapToZK(Map<String,RSGroupInfo> newGroupMap) throws IOException
IOException
private void resetRSGroupMap(Map<String,RSGroupInfo> newRSGroupMap)
private void updateCacheOfRSGroups(Set<String> currentGroups)
currentGroups
- Current list of Groups.private SortedSet<Address> getDefaultServers()
private SortedSet<Address> getDefaultServers(List<RSGroupInfo> rsGroupInfoList)
private static boolean isMasterRunning(MasterServices masterServices)
private void multiMutate(List<Mutation> mutations) throws IOException
IOException
private void checkGroupName(String groupName) throws ConstraintException
ConstraintException
public RSGroupInfo getRSGroupForTable(TableName tableName) throws IOException
RSGroupInfoManager
RSGroupInfo
for the given table.getRSGroupForTable
in interface RSGroupInfoManager
IOException
private void checkForDeadOrOnlineServers(Set<Address> servers) throws IOException
servers
- servers to removeIOException
private void checkOnlineServersOnly(Set<Address> servers) throws IOException
IOException
private List<RegionInfo> getRegions(Address server)
server
.private void addRegion(LinkedList<RegionInfo> regions, RegionInfo hri)
private void moveServerRegionsFromGroup(Set<Address> movedServers, Set<Address> srcGrpServers, String targetGroupName, String sourceGroupName) throws IOException
movedServers
- the servers that are moved to new groupsrcGrpServers
- all servers in the source group, excluding the movedServerstargetGroupName
- the target groupsourceGroupName
- the source groupIOException
- if moving the server and tables failprivate <T> void moveRegionsBetweenGroups(Set<T> regionsOwners, Set<Address> newRegionsOwners, String targetGroupName, String sourceGroupName, Function<T,List<RegionInfo>> getRegionsInfo, Function<RegionInfo,Boolean> validation) throws IOException
IOException
private void waitForRegionMovement(List<Pair<RegionInfo,Future<byte[]>>> regionMoveFutures, Set<String> failedRegions, String sourceGroupName, int retryCount)
private boolean isTableInGroup(TableName tableName, String groupName, Set<TableName> tablesInGroupCache) throws IOException
IOException
private Map<String,RegionState> rsGroupGetRegionsInTransition(String groupName) throws IOException
IOException
Map<TableName,Map<ServerName,List<RegionInfo>>> getRSGroupAssignmentsByTable(TableStateManager tableStateManager, String groupName) throws IOException
balanceRSGroup(java.lang.String, org.apache.hadoop.hbase.client.BalanceRequest)
IOException
public BalanceResponse balanceRSGroup(String groupName, BalanceRequest request) throws IOException
RSGroupInfoManager
balanceRSGroup
in interface RSGroupInfoManager
IOException
private void moveTablesAndWait(Set<TableName> tables, String targetGroup) throws IOException
IOException
public void setRSGroup(Set<TableName> tables, String groupName) throws IOException
RSGroupInfoManager
setRSGroup
in interface RSGroupInfoManager
IOException
public void moveServers(Set<Address> servers, String targetGroupName) throws IOException
RSGroupInfoManager
moveServers
in interface RSGroupInfoManager
IOException
public String determineRSGroupInfoForTable(TableName tableName)
RSGroupInfoManager
RSGroupInfo
for the given table.determineRSGroupInfoForTable
in interface RSGroupInfoManager
tableName
- table namepublic void renameRSGroup(String oldName, String newName) throws IOException
RSGroupInfoManager
renameRSGroup
in interface RSGroupInfoManager
oldName
- old rsgroup namenewName
- new rsgroup nameIOException
public void updateRSGroupConfig(String groupName, Map<String,String> configuration) throws IOException
RSGroupInfoManager
updateRSGroupConfig
in interface RSGroupInfoManager
groupName
- the group nameconfiguration
- new configuration of the group name to be setIOException
- if a remote or network exception occursCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.