diff --git a/core/src/main/java/org/apache/accumulo/core/manager/balancer/AssignmentParamsImpl.java b/core/src/main/java/org/apache/accumulo/core/manager/balancer/AssignmentParamsImpl.java index 7bdbf70fc1a..f318352e9dd 100644 --- a/core/src/main/java/org/apache/accumulo/core/manager/balancer/AssignmentParamsImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/manager/balancer/AssignmentParamsImpl.java @@ -34,8 +34,13 @@ import org.apache.accumulo.core.spi.balancer.TabletBalancer; import org.apache.accumulo.core.spi.balancer.data.TServerStatus; import org.apache.accumulo.core.spi.balancer.data.TabletServerId; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AssignmentParamsImpl implements TabletBalancer.AssignmentParameters { + + private static final Logger LOG = LoggerFactory.getLogger(AssignmentParamsImpl.class); + private final SortedMap currentStatus; private final Map unassigned; private final Map assignmentsOut; @@ -50,16 +55,23 @@ public static AssignmentParamsImpl fromThrift( Map unassigned, Map assignmentsOut) { SortedMap currentStatusNew = new TreeMap<>(); - currentStatus.forEach((tsi, status) -> currentStatusNew.put(new TabletServerIdImpl(tsi), - TServerStatusImpl.fromThrift(status))); - Map> tserverGroups = new HashMap<>(); - currentTServerGrouping.forEach((k, v) -> { + currentTServerGrouping.forEach((group, serversInGroup) -> { Set servers = new HashSet<>(); - v.forEach(tsi -> servers.add(TabletServerIdImpl.fromThrift(tsi))); - tserverGroups.put(k, servers); + serversInGroup.forEach(tsi -> { + TabletServerIdImpl id = TabletServerIdImpl.fromThrift(tsi); + if (currentStatus.containsKey(tsi)) { + currentStatusNew.put(id, TServerStatusImpl.fromThrift(currentStatus.get(tsi))); + servers.add(id); + } else { + LOG.debug("Dropping tserver {} from group as it's not in set of all servers", id, group); + } + }); + tserverGroups.put(group, servers); }); + LOG.debug("TServer groups for balancer assignment: {}", tserverGroups); + Map unassignedNew = new HashMap<>(); unassigned.forEach( (ke, tsi) -> unassignedNew.put(new TabletIdImpl(ke), TabletServerIdImpl.fromThrift(tsi))); diff --git a/core/src/main/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancer.java b/core/src/main/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancer.java index 50fcd8417fb..09189c0192a 100644 --- a/core/src/main/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancer.java +++ b/core/src/main/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancer.java @@ -356,6 +356,10 @@ private static TableId busiest(Map tables) { @Override public void getAssignments(AssignmentParameters params) { + if (params.currentStatus().isEmpty()) { + log.debug("No known TabletServers, skipping tablet assignment for now."); + return; + } params.unassignedTablets().forEach((tabletId, tserverId) -> params.addAssignment(tabletId, getAssignment(params.currentStatus(), tserverId))); } diff --git a/core/src/main/java/org/apache/accumulo/core/spi/balancer/TableLoadBalancer.java b/core/src/main/java/org/apache/accumulo/core/spi/balancer/TableLoadBalancer.java index 853608018f9..44cf29d1e87 100644 --- a/core/src/main/java/org/apache/accumulo/core/spi/balancer/TableLoadBalancer.java +++ b/core/src/main/java/org/apache/accumulo/core/spi/balancer/TableLoadBalancer.java @@ -149,10 +149,12 @@ private SortedMap getCurrentSetForTable( 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"); + log.warn( + "Excluding TabletServer {} from group {} because TabletServerStatus is null, likely that Manager.StatusThread.updateStatus has not discovered it yet.", + tsid, groupNameInUse); + } else { + group.put(tsid, tss); } - group.put(tsid, tss); }); return group; }