@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 |
|---|---|
private class |
RSGroupInfoManagerImpl.FailedOpenUpdaterThread |
private class |
RSGroupInfoManagerImpl.RSGroupStartupWorker |
private class |
RSGroupInfoManagerImpl.ServerEventsListenerThread
Calls
updateDefaultServers(SortedSet) to update list of known
servers. |
| Modifier and Type | Field and Description |
|---|---|
private ClusterConnection |
conn |
private RSGroupInfoManagerImpl.FailedOpenUpdaterThread |
failedOpenUpdaterThread |
private static org.slf4j.Logger |
LOG |
private MasterServices |
masterServices |
private Set<String> |
prevRSGroups |
private static HTableDescriptor |
RSGROUP_TABLE_DESC
Table descriptor for
hbase:rsgroup catalog table |
private Map<String,RSGroupInfo> |
rsGroupMap |
private RSGroupInfoManagerImpl.RSGroupStartupWorker |
rsGroupStartupWorker |
private Table |
rsGroupTable |
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) |
private void |
flushConfig() |
private void |
flushConfig(Map<String,RSGroupInfo> newGroupMap) |
private Map<TableName,String> |
flushConfigTable(Map<String,RSGroupInfo> groupMap) |
private SortedSet<Address> |
getDefaultServers() |
(package private) static RSGroupInfoManager |
getInstance(MasterServices master) |
private List<ServerName> |
getOnlineRS() |
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
RSGroupInfos. |
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
|
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) |
private void |
updateFailedAssignments() |
private static final org.slf4j.Logger LOG
private static final HTableDescriptor RSGROUP_TABLE_DESC
hbase:rsgroup catalog tableprivate volatile Map<String,RSGroupInfo> rsGroupMap
private final MasterServices masterServices
private Table rsGroupTable
private final ClusterConnection conn
private final RSGroupInfoManagerImpl.RSGroupStartupWorker rsGroupStartupWorker
private Set<String> prevRSGroups
private final RSGroupInfoManagerImpl.ServerEventsListenerThread serverEventsListenerThread
private RSGroupInfoManagerImpl.FailedOpenUpdaterThread failedOpenUpdaterThread
private RSGroupInfoManagerImpl(MasterServices masterServices) throws IOException
IOExceptionprivate void init() throws IOException
IOExceptionstatic RSGroupInfoManager getInstance(MasterServices master) throws IOException
IOExceptionpublic void start()
start in interface RSGroupInfoManagerpublic void addRSGroup(RSGroupInfo rsGroupInfo) throws IOException
RSGroupInfoManageraddRSGroup in interface RSGroupInfoManagerIOExceptionprivate RSGroupInfo getRSGroupInfo(String groupName) throws DoNotRetryIOException
DoNotRetryIOExceptionpublic Set<Address> moveServers(Set<Address> servers, String srcGroup, String dstGroup) throws IOException
RSGroupInfoManagermoveServers in interface RSGroupInfoManagerservers - list of servers, must be part of the same groupsrcGroup - groupName being moved fromdstGroup - groupName being moved toservers).IOExceptionpublic RSGroupInfo getRSGroupOfServer(Address serverHostPort) throws IOException
RSGroupInfoManagergetRSGroupOfServer in interface RSGroupInfoManagerIOExceptionpublic RSGroupInfo getRSGroup(String groupName)
RSGroupInfoManagerRSGroupInfo for the given group name.getRSGroup in interface RSGroupInfoManagerpublic String getRSGroupOfTable(TableName tableName)
RSGroupInfoManagergetRSGroupOfTable in interface RSGroupInfoManagerpublic void moveTables(Set<TableName> tableNames, String groupName) throws IOException
RSGroupInfoManagermoveTables in interface RSGroupInfoManagertableNames - set of tables to movegroupName - name of group of tables to move toIOExceptionpublic void removeRSGroup(String groupName) throws IOException
RSGroupInfoManagerremoveRSGroup in interface RSGroupInfoManagerIOExceptionpublic List<RSGroupInfo> listRSGroups()
RSGroupInfoManagerRSGroupInfos.listRSGroups in interface RSGroupInfoManagerpublic boolean isOnline()
RSGroupInfoManagerisOnline in interface RSGroupInfoManagerpublic void moveServersAndTables(Set<Address> servers, Set<TableName> tables, String srcGroup, String dstGroup) throws IOException
RSGroupInfoManagermoveServersAndTables in interface RSGroupInfoManagerservers - list of servers, must be part of the same grouptables - set of tables to movesrcGroup - groupName being moved fromdstGroup - groupName being moved toIOExceptionpublic void removeServers(Set<Address> servers) throws IOException
RSGroupInfoManagerremoveServers in interface RSGroupInfoManagerservers - set of servers to removeIOExceptionList<RSGroupInfo> retrieveGroupListFromGroupTable() throws IOException
IOExceptionList<RSGroupInfo> retrieveGroupListFromZookeeper() throws IOException
IOExceptionpublic void refresh() throws IOException
RSGroupInfoManagerrefresh in interface RSGroupInfoManagerIOExceptionprivate void refresh(boolean forceOnline) throws IOException
IOExceptionprivate Map<TableName,String> flushConfigTable(Map<String,RSGroupInfo> groupMap) throws IOException
IOExceptionprivate void flushConfig() throws IOException
IOExceptionprivate void flushConfig(Map<String,RSGroupInfo> newGroupMap) throws IOException
IOExceptionprivate 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
IOExceptionprivate SortedSet<Address> getDefaultServers() throws IOException
IOExceptionprivate void updateDefaultServers(SortedSet<Address> servers) throws IOException
IOExceptionprivate void updateFailedAssignments()
private static boolean isMasterRunning(MasterServices masterServices)
private void multiMutate(List<Mutation> mutations) throws IOException
IOExceptionprivate void checkGroupName(String groupName) throws ConstraintException
ConstraintExceptionCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.