keith-turner commented on code in PR #3496:
URL: https://github.com/apache/accumulo/pull/3496#discussion_r1258913767
##########
core/src/main/java/org/apache/accumulo/core/spi/balancer/TableLoadBalancer.java:
##########
@@ -106,17 +134,59 @@ protected TabletBalancer getBalancerForTable(TableId
tableId) {
return balancer;
}
+ private SortedMap<TabletServerId,TServerStatus> getCurrentSetForTable(
+ SortedMap<TabletServerId,TServerStatus> allTServers,
+ Map<String,Set<TabletServerId>> groupedTServers, String resourceGroup) {
+
+ String groupName =
+ resourceGroup == null ? Constants.DEFAULT_RESOURCE_GROUP_NAME :
resourceGroup;
+ Set<TabletServerId> tserversInGroup = groupedTServers.get(groupName);
+ if (tserversInGroup == null || tserversInGroup.isEmpty()) {
+ log.warn("No TabletServers in assignment group {}", groupName);
+ return null;
+ }
+ log.trace("{} TabletServers in group: {}", tserversInGroup.size(),
groupName);
+ SortedMap<TabletServerId,TServerStatus> group = new TreeMap<>();
+ final String groupNameInUse = groupName;
+ tserversInGroup.forEach(tsid -> {
+ TServerStatus tss = allTServers.get(tsid);
+ if (tss == null) {
+ throw new IllegalStateException("TabletServer " + tsid + " in " +
groupNameInUse
+ + " TabletServer group, but not in set of all TabletServers");
+ }
+ group.put(tsid, tss);
+ });
+ return group;
+ }
+
@Override
public void getAssignments(AssignmentParameters params) {
// separate the unassigned into tables
Map<TableId,Map<TabletId,TabletServerId>> groupedUnassigned = new
HashMap<>();
params.unassignedTablets().forEach((tid, lastTserver) -> groupedUnassigned
.computeIfAbsent(tid.getTable(), k -> new HashMap<>()).put(tid,
lastTserver));
for (Entry<TableId,Map<TabletId,TabletServerId>> e :
groupedUnassigned.entrySet()) {
- Map<TabletId,TabletServerId> newAssignments = new HashMap<>();
- getBalancerForTable(e.getKey()).getAssignments(
- new AssignmentParamsImpl(params.currentStatus(), e.getValue(),
newAssignments));
- newAssignments.forEach(params::addAssignment);
+ final String tableResourceGroup =
getResourceGroupNameForTable(e.getKey());
+ log.trace("Table {} is set to use resource group: {}", e.getKey(),
tableResourceGroup);
+ final Map<TabletId,TabletServerId> newAssignments = new HashMap<>();
+ // get the group of tservers for this table
+ final SortedMap<TabletServerId,TServerStatus> groupedTServers =
getCurrentSetForTable(
Review Comment:
This could be a follow on. Need to determine if we need to do anything to
avoid recomputing this map on every call to getAssignments. Not sure if it
matters, depends on how frequently the manager calls this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]