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
Nested ClassesModifier and TypeClassDescription(package private) static classprivate classprivate classCallsupdateDefaultServers(SortedSet)to update list of known servers. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Connectionprivate static final org.slf4j.Loggerprivate final MasterServicesprivate static final TableDescriptorTable descriptor forhbase:rsgroupcatalog tableprivate Map<String,RSGroupInfo> private final RSGroupInfoManagerImpl.RSGroupStartupWorker(package private) RSGroupInfoManagerImpl.RSGroupMappingScriptGet rsgroup table mapping scriptprivate final RSGroupInfoManagerImpl.ServerEventsListenerThreadprivate final ZKWatcherFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRSGroup(RSGroupInfo rsGroupInfo) Add given RSGroupInfo to existing list of group infos.private voidcheckGroupName(String groupName) determineRSGroupInfoForTable(TableName tableName) Will try to get the rsgroup fromtableMapfirst then try to get the rsgroup fromscripttry to get the rsgroup from theNamespaceDescriptorlastly.private voidprivate voidflushConfig(Map<String, RSGroupInfo> newGroupMap) flushConfigTable(Map<String, RSGroupInfo> groupMap) getDefaultServers(List<RSGroupInfo> rsGroupInfoList) (package private) static RSGroupInfoManagergetInstance(MasterServices master) private List<ServerName>getOnlineServers(MasterServices master) getRSGroup(String groupName) GetsRSGroupInfofor the given group name.private RSGroupInfogetRSGroupInfo(String groupName) getRSGroupOfServer(Address serverHostPort) Gets the group info of server.getRSGroupOfTable(TableName tableName) Get the group membership of a tableprivate voidinit()private static booleanisMasterRunning(MasterServices masterServices) booleanisOnline()Whether the manager is able to fully return group metadataList the existingRSGroupInfos.moveServers(Set<Address> servers, String srcGroup, String dstGroup) Move servers to a new group.voidMove servers and tables to a new group.voidmoveTables(Set<TableName> tableNames, String groupName) Set the group membership of a set of tablesprivate voidmultiMutate(List<Mutation> mutations) voidrefresh()Refresh/reload the group information from the persistent storeprivate voidrefresh(boolean forceOnline) Read rsgroup info from the source of truth, the hbase:rsgroup table.voidremoveRSGroup(String groupName) Remove a region server group.voidremoveServers(Set<Address> servers) Remove decommissioned servers from rsgroupvoidrenameRSGroup(String oldName, String newName) Rename RSGroupprivate voidresetRSGroupAndTableMaps(Map<String, RSGroupInfo> newRSGroupMap, Map<TableName, String> newTableMap) Make changes visible.(package private) List<RSGroupInfo>(package private) List<RSGroupInfo>voidstart()private voidupdateCacheOfRSGroups(Set<String> currentGroups) Update cache of rsgroups.private voidupdateDefaultServers(SortedSet<Address> servers) voidupdateRSGroupConfig(String groupName, Map<String, String> configuration) Update RSGroup configuration
-
Field Details
-
LOG
-
RSGROUP_TABLE_DESC
Table descriptor forhbase:rsgroupcatalog 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:
startin interfaceRSGroupInfoManager
-
addRSGroup
Description copied from interface:RSGroupInfoManagerAdd given RSGroupInfo to existing list of group infos.- Specified by:
addRSGroupin 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:RSGroupInfoManagerMove servers to a new group.- Specified by:
moveServersin 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:RSGroupInfoManagerGets the group info of server.- Specified by:
getRSGroupOfServerin interfaceRSGroupInfoManager- Throws:
IOException
-
getRSGroup
Description copied from interface:RSGroupInfoManagerGetsRSGroupInfofor the given group name.- Specified by:
getRSGroupin interfaceRSGroupInfoManager
-
getRSGroupOfTable
Description copied from interface:RSGroupInfoManagerGet the group membership of a table- Specified by:
getRSGroupOfTablein interfaceRSGroupInfoManager
-
moveTables
Description copied from interface:RSGroupInfoManagerSet the group membership of a set of tables- Specified by:
moveTablesin interfaceRSGroupInfoManager- Parameters:
tableNames- set of tables to movegroupName- name of group of tables to move to- Throws:
IOException
-
removeRSGroup
Description copied from interface:RSGroupInfoManagerRemove a region server group.- Specified by:
removeRSGroupin interfaceRSGroupInfoManager- Throws:
IOException
-
listRSGroups
Description copied from interface:RSGroupInfoManagerList the existingRSGroupInfos.- Specified by:
listRSGroupsin interfaceRSGroupInfoManager
-
isOnline
Description copied from interface:RSGroupInfoManagerWhether the manager is able to fully return group metadata- Specified by:
isOnlinein 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:RSGroupInfoManagerMove servers and tables to a new group.- Specified by:
moveServersAndTablesin 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:RSGroupInfoManagerRemove decommissioned servers from rsgroup- Specified by:
removeServersin interfaceRSGroupInfoManager- Parameters:
servers- set of servers to remove- Throws:
IOException
-
renameRSGroup
Description copied from interface:RSGroupInfoManagerRename RSGroup- Specified by:
renameRSGroupin interfaceRSGroupInfoManager- Parameters:
oldName- old rsgroup namenewName- new rsgroup name- Throws:
IOException
-
determineRSGroupInfoForTable
Will try to get the rsgroup fromtableMapfirst then try to get the rsgroup fromscripttry to get the rsgroup from theNamespaceDescriptorlastly. If still not present, return default group.- Specified by:
determineRSGroupInfoForTablein interfaceRSGroupInfoManager- Parameters:
tableName- table name- Returns:
RSGroupInfowhich table should belong to- Throws:
IOException
-
updateRSGroupConfig
public void updateRSGroupConfig(String groupName, Map<String, String> configuration) throws IOExceptionDescription copied from interface:RSGroupInfoManagerUpdate RSGroup configuration- Specified by:
updateRSGroupConfigin 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:RSGroupInfoManagerRefresh/reload the group information from the persistent store- Specified by:
refreshin 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
-