@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.
rsGroupMap
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.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
RSGroupInfoManagerImpl.RSGroupMappingScript |
private class |
RSGroupInfoManagerImpl.RSGroupStartupWorker |
private class |
RSGroupInfoManagerImpl.ServerEventsListenerThread
Calls
updateDefaultServers(SortedSet) to update list of known
servers. |
Modifier and Type | Field and Description |
---|---|
private Connection |
conn |
private static org.slf4j.Logger |
LOG |
private MasterServices |
masterServices |
private Set<String> |
prevRSGroups |
private static TableDescriptor |
RSGROUP_TABLE_DESC
Table descriptor for
hbase:rsgroup catalog table |
private Map<String,RSGroupInfo> |
rsGroupMap |
private RSGroupInfoManagerImpl.RSGroupStartupWorker |
rsGroupStartupWorker |
(package private) RSGroupInfoManagerImpl.RSGroupMappingScript |
script
Get rsgroup table mapping script
|
private RSGroupInfoManagerImpl.ServerEventsListenerThread |
serverEventsListenerThread |
private Map<TableName,String> |
tableMap |
private ZKWatcher |
watcher |
DEFAULT_REASSIGN_WAIT_INTERVAL, META_FAMILY_BYTES, META_QUALIFIER_BYTES, REASSIGN_WAIT_INTERVAL_KEY, ROW_KEY, RSGROUP_TABLE_NAME, rsGroupZNode
Modifier | Constructor and Description |
---|---|
private |
RSGroupInfoManagerImpl(MasterServices masterServices) |
Modifier and Type | Method and Description |
---|---|
void |
addRSGroup(RSGroupInfo rsGroupInfo)
Add given RSGroupInfo to existing list of group infos.
|
private void |
checkGroupName(String groupName) |
RSGroupInfo |
determineRSGroupInfoForTable(TableName tableName)
Will try to get the rsgroup from
tableMap first then try to get the rsgroup from
script try to get the rsgroup from the NamespaceDescriptor lastly. |
private void |
flushConfig() |
private void |
flushConfig(Map<String,RSGroupInfo> newGroupMap) |
private Map<TableName,String> |
flushConfigTable(Map<String,RSGroupInfo> groupMap) |
private SortedSet<Address> |
getDefaultServers() |
private SortedSet<Address> |
getDefaultServers(List<RSGroupInfo> rsGroupInfoList) |
(package private) static RSGroupInfoManager |
getInstance(MasterServices master) |
private List<ServerName> |
getOnlineRS() |
private static Set<Address> |
getOnlineServers(MasterServices master) |
RSGroupInfo |
getRSGroup(String groupName)
Gets
RSGroupInfo for the given group name. |
private RSGroupInfo |
getRSGroupInfo(String groupName) |
RSGroupInfo |
getRSGroupOfServer(Address serverHostPort)
Gets the group info of server.
|
String |
getRSGroupOfTable(TableName tableName)
Get the group membership of a table
|
private void |
init() |
private static boolean |
isMasterRunning(MasterServices masterServices) |
boolean |
isOnline()
Whether the manager is able to fully return group metadata
|
List<RSGroupInfo> |
listRSGroups()
List the existing
RSGroupInfo s. |
Set<Address> |
moveServers(Set<Address> servers,
String srcGroup,
String dstGroup)
Move servers to a new group.
|
void |
moveServersAndTables(Set<Address> servers,
Set<TableName> tables,
String srcGroup,
String dstGroup)
Move servers and tables to a new group.
|
void |
moveTables(Set<TableName> tableNames,
String groupName)
Set the group membership of a set of tables
|
private void |
multiMutate(List<Mutation> mutations) |
void |
refresh()
Refresh/reload the group information from the persistent store
|
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 |
resetRSGroupAndTableMaps(Map<String,RSGroupInfo> newRSGroupMap,
Map<TableName,String> newTableMap)
Make changes visible.
|
(package private) List<RSGroupInfo> |
retrieveGroupListFromGroupTable() |
(package private) List<RSGroupInfo> |
retrieveGroupListFromZookeeper() |
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
|
private static final org.slf4j.Logger LOG
private static final TableDescriptor RSGROUP_TABLE_DESC
hbase:rsgroup
catalog tableprivate volatile Map<String,RSGroupInfo> rsGroupMap
private final MasterServices masterServices
private final Connection conn
private final RSGroupInfoManagerImpl.RSGroupStartupWorker rsGroupStartupWorker
private Set<String> prevRSGroups
private final RSGroupInfoManagerImpl.ServerEventsListenerThread serverEventsListenerThread
RSGroupInfoManagerImpl.RSGroupMappingScript script
private RSGroupInfoManagerImpl(MasterServices masterServices) throws IOException
IOException
private void init() throws IOException
IOException
static RSGroupInfoManager getInstance(MasterServices master) 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 DoNotRetryIOException
DoNotRetryIOException
private static Set<Address> getOnlineServers(MasterServices master)
master
- the master to get online servers forpublic Set<Address> moveServers(Set<Address> servers, String srcGroup, String dstGroup) throws IOException
RSGroupInfoManager
moveServers
in interface RSGroupInfoManager
servers
- list of servers, must be part of the same groupsrcGroup
- groupName being moved fromdstGroup
- groupName being moved toservers
).IOException
public RSGroupInfo getRSGroupOfServer(Address serverHostPort) throws IOException
RSGroupInfoManager
getRSGroupOfServer
in interface RSGroupInfoManager
IOException
public RSGroupInfo getRSGroup(String groupName)
RSGroupInfoManager
RSGroupInfo
for the given group name.getRSGroup
in interface RSGroupInfoManager
public String getRSGroupOfTable(TableName tableName)
RSGroupInfoManager
getRSGroupOfTable
in interface RSGroupInfoManager
public void moveTables(Set<TableName> tableNames, String groupName) throws IOException
RSGroupInfoManager
moveTables
in interface RSGroupInfoManager
tableNames
- set of tables to movegroupName
- name of group of tables to move toIOException
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 moveServersAndTables(Set<Address> servers, Set<TableName> tables, String srcGroup, String dstGroup) throws IOException
RSGroupInfoManager
moveServersAndTables
in interface RSGroupInfoManager
servers
- list of servers, must be part of the same grouptables
- set of tables to movesrcGroup
- groupName being moved fromdstGroup
- groupName being moved toIOException
public void removeServers(Set<Address> servers) throws IOException
RSGroupInfoManager
removeServers
in interface RSGroupInfoManager
servers
- set of servers to removeIOException
public void renameRSGroup(String oldName, String newName) throws IOException
RSGroupInfoManager
renameRSGroup
in interface RSGroupInfoManager
oldName
- old rsgroup namenewName
- new rsgroup nameIOException
public RSGroupInfo determineRSGroupInfoForTable(TableName tableName) throws IOException
tableMap
first then try to get the rsgroup from
script
try to get the rsgroup from the NamespaceDescriptor
lastly. If still not
present, return default group.determineRSGroupInfoForTable
in interface RSGroupInfoManager
tableName
- table nameRSGroupInfo
which table should belong toIOException
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 occursList<RSGroupInfo> retrieveGroupListFromGroupTable() throws IOException
IOException
List<RSGroupInfo> retrieveGroupListFromZookeeper() throws IOException
IOException
public void refresh() throws IOException
RSGroupInfoManager
refresh
in interface RSGroupInfoManager
IOException
private void refresh(boolean forceOnline) throws IOException
IOException
private Map<TableName,String> 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 resetRSGroupAndTableMaps(Map<String,RSGroupInfo> newRSGroupMap, Map<TableName,String> newTableMap)
private void updateCacheOfRSGroups(Set<String> currentGroups)
currentGroups
- Current list of Groups.private List<ServerName> getOnlineRS() throws IOException
IOException
private SortedSet<Address> getDefaultServers() throws IOException
IOException
private SortedSet<Address> getDefaultServers(List<RSGroupInfo> rsGroupInfoList) throws IOException
IOException
private void updateDefaultServers(SortedSet<Address> servers) throws IOException
IOException
private static boolean isMasterRunning(MasterServices masterServices)
private void multiMutate(List<Mutation> mutations) throws IOException
IOException
private void checkGroupName(String groupName) throws ConstraintException
ConstraintException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.