keith-turner commented on code in PR #5537:
URL: https://github.com/apache/accumulo/pull/5537#discussion_r2166986675


##########
server/manager/src/main/java/org/apache/accumulo/manager/BalanceManager.java:
##########
@@ -321,6 +373,83 @@ void 
getAssignments(SortedMap<TServerInstance,TabletServerStatus> currentStatus,
                 Map::putAll),
             assignedOut);
     tabletBalancer.getAssignments(params);
+    if (!canAssignAndBalance()) {
+      // remove assignment for user tables
+      Iterator<KeyExtent> iter = assignedOut.keySet().iterator();
+      while (iter.hasNext()) {
+        KeyExtent ke = iter.next();
+        if (!ke.isMeta()) {
+          iter.remove();
+          log.trace("Removed assignment for {} as assignments for user tables 
is disabled.", ke);
+        }
+      }
+    }
+  }
+
+  private boolean canAssignAndBalance() {
+    final int threshold = getManager().getConfiguration()
+        .getCount(Property.MANAGER_TABLET_BALANCER_TSERVER_THRESHOLD);
+    if (threshold == 0) {
+      return true;
+    }
+    final int numTServers = getManager().tserverSet.size();
+    final boolean result = numTServers >= threshold;
+    if (!result) {
+      log.warn("Not assigning or balancing as number of tservers ({}) is below 
threshold ({})",
+          numTServers, threshold);
+    }
+    return result;
+  }
+
+  boolean shouldCleanupMigration(TabletMetadata tabletMetadata) {
+    var tableState = 
getContext().getTableManager().getTableState(tabletMetadata.getTableId());
+    var migration = tabletMetadata.getMigration();
+    Preconditions.checkState(migration != null,
+        "This method should only be called if there is a migration");
+    return tableState == TableState.OFFLINE
+        || !getManager().onlineTabletServers().contains(migration)
+        || (tabletMetadata.getLocation() != null
+            && 
tabletMetadata.getLocation().getServerInstance().equals(migration));
+  }
+
+  public void upgradeComplete() {

Review Comment:
   Named it that because the manger is calling this after upgrade is complete.  
I can change the name to reflect the functionality of the method.



-- 
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: notifications-unsubscr...@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to