-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-26163 Better logging in RSGroupInfoManagerImpl #3610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
61450e6
c8145e0
80e7bf7
e7aeb13
4ecd3ed
608893b
fb2282e
1c7711a
6847cce
87d6d71
a8720f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -257,6 +257,10 @@ private synchronized void updateDefaultServers() { | |
| // do not need to persist, as we do not persist default group. | ||
| resetRSGroupMap(newGroupMap); | ||
| LOG.info("Updated default servers, {} servers", newDefaultGroupInfo.getServers().size()); | ||
| if (LOG.isDebugEnabled()) { | ||
| LOG.debug("New default servers list: {}", newDefaultGroupInfo.getServers().stream() | ||
| .map(Address::toString).collect(Collectors.toSet())); | ||
| } | ||
| } | ||
|
|
||
| private synchronized void init() throws IOException { | ||
|
|
@@ -298,6 +302,7 @@ public synchronized void addRSGroup(RSGroupInfo rsGroupInfo) throws IOException | |
| Map<String, RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap); | ||
| newGroupMap.put(rsGroupInfo.getName(), rsGroupInfo); | ||
| flushConfig(newGroupMap); | ||
| LOG.info("Add group {} done.", rsGroupInfo.getName()); | ||
| } | ||
|
|
||
| private RSGroupInfo getRSGroupInfo(final String groupName) throws ConstraintException { | ||
|
|
@@ -331,7 +336,7 @@ public synchronized Set<Address> moveServers(Set<Address> servers, String srcGro | |
| if (onlineServers != null) { | ||
| if (!onlineServers.contains(el)) { | ||
| if (LOG.isDebugEnabled()) { | ||
| LOG.debug("Dropping " + el + " during move-to-default rsgroup because not online"); | ||
| LOG.debug("Dropping " + el + " during move-to-default RSGroup because not online"); | ||
| } | ||
| continue; | ||
| } | ||
|
|
@@ -373,8 +378,8 @@ public synchronized void removeRSGroup(String groupName) throws IOException { | |
| for (TableDescriptor td : masterServices.getTableDescriptors().getAll().values()) { | ||
| if (td.getRegionServerGroup().map(groupName::equals).orElse(false)) { | ||
| throw new ConstraintException("RSGroup " + groupName + " is already referenced by " + | ||
| td.getTableName() + "; you must remove all the tables from the rsgroup before " + | ||
| "the rsgroup can be removed."); | ||
| td.getTableName() + "; you must remove all the tables from the RSGroup before " + | ||
| "the RSGroup can be removed."); | ||
| } | ||
| } | ||
| for (NamespaceDescriptor ns : masterServices.getClusterSchema().getNamespaces()) { | ||
|
|
@@ -392,6 +397,7 @@ public synchronized void removeRSGroup(String groupName) throws IOException { | |
| Map<String, RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap); | ||
| newGroupMap.remove(groupName); | ||
| flushConfig(newGroupMap); | ||
| LOG.info("Remove group {} done", groupName); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -639,6 +645,8 @@ private synchronized void flushConfig(Map<String, RSGroupInfo> newGroupMap) thro | |
| return; | ||
| } | ||
|
|
||
| LOG.debug("Offline mode, cannot persist to {}", RSGROUP_TABLE_NAME); | ||
|
|
||
| Map<String, RSGroupInfo> oldGroupMap = Maps.newHashMap(holder.groupName2Group); | ||
| RSGroupInfo oldDefaultGroup = oldGroupMap.remove(RSGroupInfo.DEFAULT_GROUP); | ||
| RSGroupInfo newDefaultGroup = newGroupMap.remove(RSGroupInfo.DEFAULT_GROUP); | ||
|
|
@@ -655,22 +663,27 @@ private synchronized void flushConfig(Map<String, RSGroupInfo> newGroupMap) thro | |
| // according to the inputted newGroupMap (an updated copy of rsGroupMap) | ||
| this.holder = new RSGroupInfoHolder(newGroupMap); | ||
|
|
||
| LOG.debug("New RSGroup map: {}", newGroupMap); | ||
|
|
||
| // Do not need to update tableMap | ||
| // because only the update on servers in default group is allowed above, | ||
| // or IOException will be thrown | ||
| return; | ||
| } | ||
|
|
||
| /* For online mode, persist to hbase:rsgroup and Zookeeper */ | ||
| LOG.debug("Online mode, persisting to {} and ZK", RSGROUP_TABLE_NAME); | ||
| flushConfigTable(newGroupMap); | ||
|
|
||
| // Make changes visible after having been persisted to the source of truth | ||
| resetRSGroupMap(newGroupMap); | ||
| saveRSGroupMapToZK(newGroupMap); | ||
| updateCacheOfRSGroups(newGroupMap.keySet()); | ||
| LOG.info("Flush config done, new RSGroup map: {}", newGroupMap); | ||
| } | ||
|
|
||
| private void saveRSGroupMapToZK(Map<String, RSGroupInfo> newGroupMap) throws IOException { | ||
| LOG.debug("Saving RSGroup info to ZK"); | ||
| try { | ||
| String groupBasePath = | ||
| ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, RS_GROUP_ZNODE); | ||
|
|
@@ -800,6 +813,7 @@ private void createRSGroupTable() throws IOException { | |
| if (optProcId.isPresent()) { | ||
| procId = optProcId.getAsLong(); | ||
| } else { | ||
| LOG.debug("Creating group table {}", RSGROUP_TABLE_NAME); | ||
| procId = masterServices.createSystemTable(RSGROUP_TABLE_DESC); | ||
| } | ||
| // wait for region to be online | ||
|
|
@@ -849,9 +863,11 @@ private void multiMutate(List<Mutation> mutations) throws IOException { | |
| } | ||
| MutateRowsRequest request = builder.build(); | ||
| AsyncTable<?> table = conn.getTable(RSGROUP_TABLE_NAME); | ||
| LOG.debug("Multimutating {} with {} mutations", RSGROUP_TABLE_NAME, mutations.size()); | ||
| FutureUtils.get(table.<MultiRowMutationService, MutateRowsResponse> coprocessorService( | ||
| MultiRowMutationService::newStub, | ||
| (stub, controller, done) -> stub.mutateRows(controller, request, done), ROW_KEY)); | ||
| LOG.info("Multimutating {} with {} mutations done", RSGROUP_TABLE_NAME, mutations.size()); | ||
| } | ||
|
|
||
| private void checkGroupName(String groupName) throws ConstraintException { | ||
|
|
@@ -871,7 +887,7 @@ public RSGroupInfo getRSGroupForTable(TableName tableName) throws IOException { | |
| * @param servers servers to remove | ||
| */ | ||
| private void checkForDeadOrOnlineServers(Set<Address> servers) throws IOException { | ||
| // This uglyness is because we only have Address, not ServerName. | ||
| // This ugliness is because we only have Address, not ServerName. | ||
| Set<Address> onlineServers = new HashSet<>(); | ||
| List<ServerName> drainingServers = masterServices.getServerManager().getDrainingServersList(); | ||
| for (ServerName server : masterServices.getServerManager().getOnlineServers().keySet()) { | ||
|
|
@@ -1001,7 +1017,7 @@ private <T> void moveRegionsBetweenGroups(Set<T> regionsOwners, Set<Address> new | |
| // Get regions that are associated with this server and filter regions by group tables. | ||
| for (RegionInfo region : getRegionsInfo.apply((T) owner.getAddress())) { | ||
| if (!validation.apply(region)) { | ||
| LOG.info("Moving region {}, which do not belong to RSGroup {}", | ||
| LOG.info("Moving region {}, which does not belong to RSGroup {}", | ||
| region.getShortNameToLog(), targetGroupName); | ||
| // Move region back to source RSGroup servers | ||
| ServerName dest = | ||
|
|
@@ -1186,6 +1202,7 @@ public boolean balanceRSGroup(String groupName) throws IOException { | |
| } | ||
|
|
||
| private void moveTablesAndWait(Set<TableName> tables, String targetGroup) throws IOException { | ||
| LOG.debug("Moving {} tables to target group {}", tables.size(), targetGroup); | ||
| List<Long> procIds = new ArrayList<Long>(); | ||
| for (TableName tableName : tables) { | ||
| TableDescriptor oldTd = masterServices.getTableDescriptors().get(tableName); | ||
|
|
@@ -1205,6 +1222,8 @@ private void moveTablesAndWait(Set<TableName> tables, String targetGroup) throws | |
| ProcedureSyncWait.waitForProcedureToCompleteIOE(masterServices.getMasterProcedureExecutor(), | ||
| proc, Long.MAX_VALUE); | ||
| } | ||
| LOG.info("Move tables done. Moved {} tables to {}: {}", tables.size(), targetGroup, | ||
| tables.stream().map(TableName::getNameAsString).collect(Collectors.toSet())); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think tableName.toString is the same with getNameAsString? So we do not need to generate a new String set? |
||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -1270,7 +1289,9 @@ public void moveServers(Set<Address> servers, String targetGroupName) throws IOE | |
| Set<Address> movedServers = moveServers(servers, srcGrp.getName(), | ||
| targetGroupName); | ||
| moveServerRegionsFromGroup(movedServers, srcGrp.getServers(), targetGroupName, srcGrp.getName()); | ||
| LOG.info("Move servers done: {} => {}", srcGrp.getName(), targetGroupName); | ||
| LOG.info("Move servers done. Moved {} servers {} => {}: {}", movedServers.size(), | ||
| srcGrp.getName(), targetGroupName, | ||
| movedServers.stream().map(Address::toString).collect(Collectors.toSet())); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also here, I do not think we need to call toString explicitly... |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -1304,6 +1325,7 @@ public synchronized void renameRSGroup(String oldName, String newName) throws IO | |
| .map(TableDescriptor::getTableName) | ||
| .collect(Collectors.toSet()); | ||
| setRSGroup(updateTables, newName); | ||
| LOG.info("Rename RSGroup done: {} => {}", oldName, newName); | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.