Package org.apache.hadoop.hbase.rsgroup
Class RSGroupInfoManagerImpl
java.lang.Object
org.apache.hadoop.hbase.rsgroup.RSGroupInfoManagerImpl
- All Implemented Interfaces:
RSGroupInfoManager
This is an implementation of
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.
Concurrency
RSGroup state is kept locally in Maps. There is a rsgroup name to cached RSGroupInfo Map atrsGroupMap
and a Map of tables to the name of the rsgroup they belong
too (in tableMap
). 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.
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
private class
private class
CallsupdateDefaultServers(SortedSet)
to update list of known servers. -
Field Summary
Modifier and TypeFieldDescriptionprivate final Connection
private static final org.slf4j.Logger
private final MasterServices
private static final TableDescriptor
Table descriptor forhbase:rsgroup
catalog tableprivate Map<String,
RSGroupInfo> private final RSGroupInfoManagerImpl.RSGroupStartupWorker
(package private) RSGroupInfoManagerImpl.RSGroupMappingScript
Get rsgroup table mapping scriptprivate final RSGroupInfoManagerImpl.ServerEventsListenerThread
private final ZKWatcher
Fields inherited from interface org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager
DEFAULT_REASSIGN_WAIT_INTERVAL, META_FAMILY_BYTES, META_QUALIFIER_BYTES, REASSIGN_WAIT_INTERVAL_KEY, ROW_KEY, RSGROUP_TABLE_NAME, rsGroupZNode
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addRSGroup
(RSGroupInfo rsGroupInfo) Add given RSGroupInfo to existing list of group infos.private void
checkGroupName
(String groupName) determineRSGroupInfoForTable
(TableName tableName) Will try to get the rsgroup fromtableMap
first then try to get the rsgroup fromscript
try to get the rsgroup from theNamespaceDescriptor
lastly.private void
private void
flushConfig
(Map<String, RSGroupInfo> newGroupMap) flushConfigTable
(Map<String, RSGroupInfo> groupMap) getDefaultServers
(List<RSGroupInfo> rsGroupInfoList) (package private) static RSGroupInfoManager
getInstance
(MasterServices master) private List<ServerName>
getOnlineServers
(MasterServices master) getRSGroup
(String groupName) GetsRSGroupInfo
for the given group name.private RSGroupInfo
getRSGroupInfo
(String groupName) getRSGroupOfServer
(Address serverHostPort) Gets the group info of server.getRSGroupOfTable
(TableName tableName) Get the group membership of a tableprivate void
init()
private static boolean
isMasterRunning
(MasterServices masterServices) boolean
isOnline()
Whether the manager is able to fully return group metadataList the existingRSGroupInfo
s.moveServers
(Set<Address> servers, String srcGroup, String dstGroup) Move servers to a new group.void
Move servers and tables to a new group.void
moveTables
(Set<TableName> tableNames, String groupName) Set the group membership of a set of tablesprivate void
multiMutate
(List<Mutation> mutations) void
refresh()
Refresh/reload the group information from the persistent storeprivate 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 rsgroupvoid
renameRSGroup
(String oldName, String newName) Rename RSGroupprivate void
resetRSGroupAndTableMaps
(Map<String, RSGroupInfo> newRSGroupMap, Map<TableName, String> newTableMap) Make changes visible.(package private) List<RSGroupInfo>
(package private) List<RSGroupInfo>
void
start()
private void
updateCacheOfRSGroups
(Set<String> currentGroups) Update cache of rsgroups.private void
updateDefaultServers
(SortedSet<Address> servers) void
updateRSGroupConfig
(String groupName, Map<String, String> configuration) Update RSGroup configuration
-
Field Details
-
LOG
-
RSGROUP_TABLE_DESC
Table descriptor forhbase:rsgroup
catalog table -
rsGroupMap
-
tableMap
-
masterServices
-
conn
-
watcher
-
rsGroupStartupWorker
-
prevRSGroups
-
serverEventsListenerThread
-
script
Get rsgroup table mapping script
-
-
Constructor Details
-
RSGroupInfoManagerImpl
- Throws:
IOException
-
-
Method Details
-
init
- Throws:
IOException
-
getInstance
- Throws:
IOException
-
start
- Specified by:
start
in interfaceRSGroupInfoManager
-
addRSGroup
Description copied from interface:RSGroupInfoManager
Add given RSGroupInfo to existing list of group infos.- Specified by:
addRSGroup
in interfaceRSGroupInfoManager
- Throws:
IOException
-
getRSGroupInfo
- Throws:
DoNotRetryIOException
-
getOnlineServers
- Parameters:
master
- the master to get online servers for- Returns:
- Set of online Servers named for their hostname and port (not ServerName).
-
moveServers
public Set<Address> moveServers(Set<Address> servers, String srcGroup, String dstGroup) throws IOException Description copied from interface:RSGroupInfoManager
Move servers to a new group.- Specified by:
moveServers
in interfaceRSGroupInfoManager
- Parameters:
servers
- list of servers, must be part of the same groupsrcGroup
- groupName being moved fromdstGroup
- groupName being moved to- Returns:
- Set of servers moved (May be a subset of
servers
). - Throws:
IOException
-
getRSGroupOfServer
Description copied from interface:RSGroupInfoManager
Gets the group info of server.- Specified by:
getRSGroupOfServer
in interfaceRSGroupInfoManager
- Throws:
IOException
-
getRSGroup
Description copied from interface:RSGroupInfoManager
GetsRSGroupInfo
for the given group name.- Specified by:
getRSGroup
in interfaceRSGroupInfoManager
-
getRSGroupOfTable
Description copied from interface:RSGroupInfoManager
Get the group membership of a table- Specified by:
getRSGroupOfTable
in interfaceRSGroupInfoManager
-
moveTables
Description copied from interface:RSGroupInfoManager
Set the group membership of a set of tables- Specified by:
moveTables
in interfaceRSGroupInfoManager
- Parameters:
tableNames
- set of tables to movegroupName
- name of group of tables to move to- Throws:
IOException
-
removeRSGroup
Description copied from interface:RSGroupInfoManager
Remove a region server group.- Specified by:
removeRSGroup
in interfaceRSGroupInfoManager
- Throws:
IOException
-
listRSGroups
Description copied from interface:RSGroupInfoManager
List the existingRSGroupInfo
s.- Specified by:
listRSGroups
in interfaceRSGroupInfoManager
-
isOnline
Description copied from interface:RSGroupInfoManager
Whether the manager is able to fully return group metadata- Specified by:
isOnline
in interfaceRSGroupInfoManager
- Returns:
- whether the manager is in online mode
-
moveServersAndTables
public void moveServersAndTables(Set<Address> servers, Set<TableName> tables, String srcGroup, String dstGroup) throws IOException Description copied from interface:RSGroupInfoManager
Move servers and tables to a new group.- Specified by:
moveServersAndTables
in interfaceRSGroupInfoManager
- Parameters:
servers
- list of servers, must be part of the same grouptables
- set of tables to movesrcGroup
- groupName being moved fromdstGroup
- groupName being moved to- Throws:
IOException
-
removeServers
Description copied from interface:RSGroupInfoManager
Remove decommissioned servers from rsgroup- Specified by:
removeServers
in interfaceRSGroupInfoManager
- Parameters:
servers
- set of servers to remove- Throws:
IOException
-
renameRSGroup
Description copied from interface:RSGroupInfoManager
Rename RSGroup- Specified by:
renameRSGroup
in interfaceRSGroupInfoManager
- Parameters:
oldName
- old rsgroup namenewName
- new rsgroup name- Throws:
IOException
-
determineRSGroupInfoForTable
Will try to get the rsgroup fromtableMap
first then try to get the rsgroup fromscript
try to get the rsgroup from theNamespaceDescriptor
lastly. If still not present, return default group.- Specified by:
determineRSGroupInfoForTable
in interfaceRSGroupInfoManager
- Parameters:
tableName
- table name- Returns:
RSGroupInfo
which table should belong to- Throws:
IOException
-
updateRSGroupConfig
public void updateRSGroupConfig(String groupName, Map<String, String> configuration) throws IOExceptionDescription copied from interface:RSGroupInfoManager
Update RSGroup configuration- Specified by:
updateRSGroupConfig
in interfaceRSGroupInfoManager
- Parameters:
groupName
- the group nameconfiguration
- new configuration of the group name to be set- Throws:
IOException
- if a remote or network exception occurs
-
retrieveGroupListFromGroupTable
- Throws:
IOException
-
retrieveGroupListFromZookeeper
- Throws:
IOException
-
refresh
Description copied from interface:RSGroupInfoManager
Refresh/reload the group information from the persistent store- Specified by:
refresh
in interfaceRSGroupInfoManager
- Throws:
IOException
-
refresh
Read rsgroup info from the source of truth, the hbase:rsgroup table. Update zk cache. Called on startup of the manager.- Throws:
IOException
-
flushConfigTable
- Throws:
IOException
-
flushConfig
- Throws:
IOException
-
flushConfig
- Throws:
IOException
-
resetRSGroupAndTableMaps
private void resetRSGroupAndTableMaps(Map<String, RSGroupInfo> newRSGroupMap, Map<TableName, String> newTableMap) Make changes visible. Caller must be synchronized on 'this'. -
updateCacheOfRSGroups
Update cache of rsgroups. Caller must be synchronized on 'this'.- Parameters:
currentGroups
- Current list of Groups.
-
getOnlineRS
- Throws:
IOException
-
getDefaultServers
- Throws:
IOException
-
getDefaultServers
- Throws:
IOException
-
updateDefaultServers
- Throws:
IOException
-
isMasterRunning
-
multiMutate
- Throws:
IOException
-
checkGroupName
- Throws:
ConstraintException
-