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


##########
server/manager/src/main/java/org/apache/accumulo/manager/Manager.java:
##########
@@ -959,27 +957,57 @@ private void 
checkForHeldServer(SortedMap<TServerInstance,TabletServerStatus> ts
     }
 
     private long balanceTablets() {
-      BalanceParamsImpl params = 
BalanceParamsImpl.fromThrift(tserverStatusForBalancer,
-          tserverStatus, migrationsSnapshot());
-      long wait = tabletBalancer.balance(params);
-
-      for (TabletMigration m : 
checkMigrationSanity(tserverStatusForBalancer.keySet(),
-          params.migrationsOut())) {
-        KeyExtent ke = KeyExtent.fromTabletId(m.getTablet());
-        if (migrations.containsKey(ke)) {
-          log.warn("balancer requested migration more than once, skipping {}", 
m);
+
+      Map<DataLevel,Set<KeyExtent>> partitionedMigrations =
+          new HashMap<>(DataLevel.values().length);
+      migrationsSnapshot().forEach(ke -> {
+        partitionedMigrations.computeIfAbsent(DataLevel.of(ke.tableId()), f -> 
new HashSet<>())
+            .add(ke);
+      });
+
+      final int tabletsNotHosted = notHosted();
+      BalanceParamsImpl params = null;
+      long wait = 0;
+      long totalMigrationsOut = 0;
+      for (DataLevel dl : DataLevel.values()) {
+        final Set<KeyExtent> migrationsForLevel = 
partitionedMigrations.get(dl);
+        if (migrationsForLevel == null) {
+          continue;
+        }
+        if (dl == DataLevel.USER && tabletsNotHosted > 0) {
+          log.debug("not balancing user tablets because there are {} unhosted 
tablets",
+              tabletsNotHosted);
           continue;
         }
-        TServerInstance tserverInstance = 
TabletServerIdImpl.toThrift(m.getNewTabletServer());
-        migrations.put(ke, tserverInstance);
-        log.debug("migration {}", m);
+        long migrationsOutForLevel = 0;
+        int i = 0;
+        do {
+          i++;
+          log.debug("Balancing for tables at level {}, times-in-loop: {}", dl, 
i);

Review Comment:
   The times in loop info is nice, w/o it would have to dig through logs and 
look for changes in level.



-- 
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]

Reply via email to