This is an automated email from the ASF dual-hosted git repository.

dlmarion pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.1 by this push:
     new 93365b4f23 Fixed failures in RegexGroupBalanceIT after merging PR 
#5070 (#5140)
93365b4f23 is described below

commit 93365b4f2330cc54268149e6ebc24a87af44e89f
Author: Dave Marion <dlmar...@apache.org>
AuthorDate: Fri Dec 6 08:07:35 2024 -0500

    Fixed failures in RegexGroupBalanceIT after merging PR #5070 (#5140)
    
    After merging #5070 RegexGroupBalanceIT started failing. Both
    GroupBalancer and HostRegexTableLoadBalancer have logic that
    throttles the frequency that they can be called do not return
    any migrations in this scenario. The change in #5070 modified
    the frequency in which the balancer is called from once for all
    DataLevel's to once per DataLevel. This caused the GroupBalancer
    and HostRegexTableLoadBalancer to return migrations for the ROOT
    DataLevel, but not the METADATA and USER DataLevels.
    
    The solution in this commit is to push the DataLevel down to
    the Balancer in the BalancerParams so that the throttling can
    be done at the DataLevel level.
---
 .../core/manager/balancer/BalanceParamsImpl.java   | 18 +++++++++++++----
 .../accumulo/core/spi/balancer/GroupBalancer.java  | 10 +++++++---
 .../spi/balancer/HostRegexTableLoadBalancer.java   | 14 ++++++++-----
 .../core/spi/balancer/TableLoadBalancer.java       |  7 +++++--
 .../accumulo/core/spi/balancer/TabletBalancer.java |  9 +++++++++
 .../BaseHostRegexTableLoadBalancerTest.java        |  8 ++++++++
 .../core/spi/balancer/GroupBalancerTest.java       | 11 +++++++----
 ...tRegexTableLoadBalancerReconfigurationTest.java | 12 +++++++----
 .../balancer/HostRegexTableLoadBalancerTest.java   | 23 ++++++++++++----------
 .../core/spi/balancer/SimpleLoadBalancerTest.java  |  7 +++++--
 .../core/spi/balancer/TableLoadBalancerTest.java   |  5 +++--
 .../java/org/apache/accumulo/manager/Manager.java  |  2 +-
 .../accumulo/test/ChaoticLoadBalancerTest.java     |  4 +++-
 13 files changed, 92 insertions(+), 38 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/manager/balancer/BalanceParamsImpl.java
 
b/core/src/main/java/org/apache/accumulo/core/manager/balancer/BalanceParamsImpl.java
index a0c30d43f5..97b9315c6e 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/manager/balancer/BalanceParamsImpl.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/manager/balancer/BalanceParamsImpl.java
@@ -29,6 +29,7 @@ import org.apache.accumulo.core.dataImpl.KeyExtent;
 import org.apache.accumulo.core.dataImpl.TabletIdImpl;
 import org.apache.accumulo.core.master.thrift.TabletServerStatus;
 import org.apache.accumulo.core.metadata.TServerInstance;
+import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
 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.TabletMigration;
@@ -40,35 +41,39 @@ public class BalanceParamsImpl implements 
TabletBalancer.BalanceParameters {
   private final List<TabletMigration> migrationsOut;
   private final SortedMap<TServerInstance,TabletServerStatus> 
thriftCurrentStatus;
   private final Set<KeyExtent> thriftCurrentMigrations;
+  private final DataLevel currentDataLevel;
 
   public static BalanceParamsImpl 
fromThrift(SortedMap<TabletServerId,TServerStatus> currentStatus,
       SortedMap<TServerInstance,TabletServerStatus> thriftCurrentStatus,
-      Set<KeyExtent> thriftCurrentMigrations) {
+      Set<KeyExtent> thriftCurrentMigrations, DataLevel currentLevel) {
     Set<TabletId> currentMigrations = 
thriftCurrentMigrations.stream().map(TabletIdImpl::new)
         .collect(Collectors.toUnmodifiableSet());
 
     return new BalanceParamsImpl(currentStatus, currentMigrations, new 
ArrayList<>(),
-        thriftCurrentStatus, thriftCurrentMigrations);
+        thriftCurrentStatus, thriftCurrentMigrations, currentLevel);
   }
 
   public BalanceParamsImpl(SortedMap<TabletServerId,TServerStatus> 
currentStatus,
-      Set<TabletId> currentMigrations, List<TabletMigration> migrationsOut) {
+      Set<TabletId> currentMigrations, List<TabletMigration> migrationsOut,
+      DataLevel currentLevel) {
     this.currentStatus = currentStatus;
     this.currentMigrations = currentMigrations;
     this.migrationsOut = migrationsOut;
     this.thriftCurrentStatus = null;
     this.thriftCurrentMigrations = null;
+    this.currentDataLevel = currentLevel;
   }
 
   private BalanceParamsImpl(SortedMap<TabletServerId,TServerStatus> 
currentStatus,
       Set<TabletId> currentMigrations, List<TabletMigration> migrationsOut,
       SortedMap<TServerInstance,TabletServerStatus> thriftCurrentStatus,
-      Set<KeyExtent> thriftCurrentMigrations) {
+      Set<KeyExtent> thriftCurrentMigrations, DataLevel currentLevel) {
     this.currentStatus = currentStatus;
     this.currentMigrations = currentMigrations;
     this.migrationsOut = migrationsOut;
     this.thriftCurrentStatus = thriftCurrentStatus;
     this.thriftCurrentMigrations = thriftCurrentMigrations;
+    this.currentDataLevel = currentLevel;
   }
 
   @Override
@@ -100,4 +105,9 @@ public class BalanceParamsImpl implements 
TabletBalancer.BalanceParameters {
     TabletServerId newTsid = new TabletServerIdImpl(newServer);
     migrationsOut.add(new TabletMigration(id, oldTsid, newTsid));
   }
+
+  @Override
+  public String currentLevel() {
+    return currentDataLevel.name();
+  }
 }
diff --git 
a/core/src/main/java/org/apache/accumulo/core/spi/balancer/GroupBalancer.java 
b/core/src/main/java/org/apache/accumulo/core/spi/balancer/GroupBalancer.java
index 3527ba6f4c..dc34e70444 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/spi/balancer/GroupBalancer.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/spi/balancer/GroupBalancer.java
@@ -36,6 +36,7 @@ import java.util.function.Function;
 import org.apache.accumulo.core.data.TableId;
 import org.apache.accumulo.core.data.TabletId;
 import org.apache.accumulo.core.manager.balancer.TabletServerIdImpl;
+import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
 import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
 import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
 import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
@@ -68,7 +69,8 @@ public abstract class GroupBalancer implements TabletBalancer 
{
 
   protected BalancerEnvironment environment;
   private final TableId tableId;
-  private long lastRun = 0;
+
+  protected final Map<DataLevel,Long> lastRunTimes = new 
HashMap<>(DataLevel.values().length);
 
   @Override
   public void init(BalancerEnvironment balancerEnvironment) {
@@ -211,7 +213,9 @@ public abstract class GroupBalancer implements 
TabletBalancer {
       return 5000;
     }
 
-    if (System.currentTimeMillis() - lastRun < getWaitTime()) {
+    final DataLevel currentLevel = DataLevel.valueOf(params.currentLevel());
+
+    if (System.currentTimeMillis() - lastRunTimes.getOrDefault(currentLevel, 
0L) < getWaitTime()) {
       return 5000;
     }
 
@@ -275,7 +279,7 @@ public abstract class GroupBalancer implements 
TabletBalancer {
 
     populateMigrations(tservers.keySet(), params.migrationsOut(), moves);
 
-    lastRun = System.currentTimeMillis();
+    lastRunTimes.put(currentLevel, System.currentTimeMillis());
 
     return 5000;
   }
diff --git 
a/core/src/main/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancer.java
 
b/core/src/main/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancer.java
index 0b89e5d4dd..cb88ce320c 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancer.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancer.java
@@ -51,6 +51,7 @@ import 
org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl;
 import org.apache.accumulo.core.manager.balancer.BalanceParamsImpl;
 import org.apache.accumulo.core.manager.balancer.TServerStatusImpl;
 import org.apache.accumulo.core.manager.balancer.TableStatisticsImpl;
+import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
 import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
 import org.apache.accumulo.core.spi.balancer.data.TableStatistics;
 import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
@@ -181,7 +182,7 @@ public class HostRegexTableLoadBalancer extends 
TableLoadBalancer {
   }
 
   private static final Set<TabletId> EMPTY_MIGRATIONS = Collections.emptySet();
-  private volatile long lastOOBCheck = System.currentTimeMillis();
+  protected final Map<DataLevel,Long> lastOOBCheckTimes = new 
HashMap<>(DataLevel.values().length);
   private Map<String,SortedMap<TabletServerId,TServerStatus>> pools = new 
HashMap<>();
   private final Map<TabletId,TabletMigration> migrationsFromLastPass = new 
HashMap<>();
   private final Map<TableId,Long> tableToTimeSinceNoMigrations = new 
HashMap<>();
@@ -394,7 +395,10 @@ public class HostRegexTableLoadBalancer extends 
TableLoadBalancer {
 
     Map<String,SortedMap<TabletServerId,TServerStatus>> currentGrouped =
         splitCurrentByRegex(params.currentStatus());
-    if ((now - this.lastOOBCheck) > myConf.oobCheckMillis) {
+    final DataLevel currentLevel = DataLevel.valueOf(params.currentLevel());
+
+    if ((now - this.lastOOBCheckTimes.getOrDefault(currentLevel, 
System.currentTimeMillis()))
+        > myConf.oobCheckMillis) {
       try {
         // Check to see if a tablet is assigned outside the bounds of the 
pool. If so, migrate it.
         for (String table : tableIdMap.keySet()) {
@@ -454,7 +458,7 @@ public class HostRegexTableLoadBalancer extends 
TableLoadBalancer {
         }
       } finally {
         // this could have taken a while...get a new time
-        this.lastOOBCheck = System.currentTimeMillis();
+        this.lastOOBCheckTimes.put(currentLevel, System.currentTimeMillis());
       }
     }
 
@@ -507,8 +511,8 @@ public class HostRegexTableLoadBalancer extends 
TableLoadBalancer {
         continue;
       }
       ArrayList<TabletMigration> newMigrations = new ArrayList<>();
-      getBalancerForTable(tableId)
-          .balance(new BalanceParamsImpl(currentView, migrations, 
newMigrations));
+      getBalancerForTable(tableId).balance(
+          new BalanceParamsImpl(currentView, migrations, newMigrations, 
DataLevel.of(tableId)));
 
       if (newMigrations.isEmpty()) {
         tableToTimeSinceNoMigrations.remove(tableId);
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 cb89e5b093..55a24c3094 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
@@ -30,6 +30,7 @@ import org.apache.accumulo.core.data.TableId;
 import org.apache.accumulo.core.data.TabletId;
 import org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl;
 import org.apache.accumulo.core.manager.balancer.BalanceParamsImpl;
+import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
 import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
 import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
 import org.slf4j.Logger;
@@ -124,10 +125,12 @@ public class TableLoadBalancer implements TabletBalancer {
   public long balance(BalanceParameters params) {
     long minBalanceTime = 5_000;
     // Iterate over the tables and balance each of them
+    final DataLevel currentDataLevel = 
DataLevel.valueOf(params.currentLevel());
     for (TableId tableId : environment.getTableIdMap().values()) {
       ArrayList<TabletMigration> newMigrations = new ArrayList<>();
-      long tableBalanceTime = getBalancerForTable(tableId).balance(
-          new BalanceParamsImpl(params.currentStatus(), 
params.currentMigrations(), newMigrations));
+      long tableBalanceTime =
+          getBalancerForTable(tableId).balance(new 
BalanceParamsImpl(params.currentStatus(),
+              params.currentMigrations(), newMigrations, currentDataLevel));
       if (tableBalanceTime < minBalanceTime) {
         minBalanceTime = tableBalanceTime;
       }
diff --git 
a/core/src/main/java/org/apache/accumulo/core/spi/balancer/TabletBalancer.java 
b/core/src/main/java/org/apache/accumulo/core/spi/balancer/TabletBalancer.java
index a7dfcbdc2b..356bbc7223 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/spi/balancer/TabletBalancer.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/spi/balancer/TabletBalancer.java
@@ -25,6 +25,7 @@ import java.util.SortedMap;
 
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.TabletId;
+import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
 import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
 import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
 import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
@@ -93,6 +94,14 @@ public interface TabletBalancer {
      *         migrations.
      */
     List<TabletMigration> migrationsOut();
+
+    /**
+     * Return the DataLevel name for which the Manager is currently balancing. 
Balancers should
+     * return migrations for tables within the current DataLevel.
+     *
+     * @return name of current balancing iteration data level
+     */
+    String currentLevel();
   }
 
   /**
diff --git 
a/core/src/test/java/org/apache/accumulo/core/spi/balancer/BaseHostRegexTableLoadBalancerTest.java
 
b/core/src/test/java/org/apache/accumulo/core/spi/balancer/BaseHostRegexTableLoadBalancerTest.java
index c9c478a07f..38d9297881 100644
--- 
a/core/src/test/java/org/apache/accumulo/core/spi/balancer/BaseHostRegexTableLoadBalancerTest.java
+++ 
b/core/src/test/java/org/apache/accumulo/core/spi/balancer/BaseHostRegexTableLoadBalancerTest.java
@@ -268,4 +268,12 @@ public abstract class BaseHostRegexTableLoadBalancerTest 
extends HostRegexTableL
     }
     return current;
   }
+
+  @Override
+  public long balance(BalanceParameters params) {
+    long wait = super.balance(params);
+    super.lastOOBCheckTimes.clear();
+    return wait;
+  }
+
 }
diff --git 
a/core/src/test/java/org/apache/accumulo/core/spi/balancer/GroupBalancerTest.java
 
b/core/src/test/java/org/apache/accumulo/core/spi/balancer/GroupBalancerTest.java
index 3f85ed3b79..e55eb379d2 100644
--- 
a/core/src/test/java/org/apache/accumulo/core/spi/balancer/GroupBalancerTest.java
+++ 
b/core/src/test/java/org/apache/accumulo/core/spi/balancer/GroupBalancerTest.java
@@ -40,6 +40,7 @@ import org.apache.accumulo.core.dataImpl.TabletIdImpl;
 import org.apache.accumulo.core.manager.balancer.BalanceParamsImpl;
 import org.apache.accumulo.core.manager.balancer.TServerStatusImpl;
 import org.apache.accumulo.core.manager.balancer.TabletServerIdImpl;
+import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
 import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
 import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
 import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
@@ -83,7 +84,8 @@ public class GroupBalancerTest {
     }
 
     public void balance(final int maxMigrations) {
-      GroupBalancer balancer = new GroupBalancer(TableId.of("1")) {
+      TableId tid = TableId.of("1");
+      GroupBalancer balancer = new GroupBalancer(tid) {
 
         @Override
         protected Map<TabletId,TabletServerId> getLocationProvider() {
@@ -106,10 +108,10 @@ public class GroupBalancerTest {
         }
       };
 
-      balance(balancer, maxMigrations);
+      balance(balancer, maxMigrations, tid);
     }
 
-    public void balance(TabletBalancer balancer, int maxMigrations) {
+    public void balance(TabletBalancer balancer, int maxMigrations, TableId 
tid) {
 
       while (true) {
         Set<TabletId> migrations = new HashSet<>();
@@ -121,7 +123,8 @@ public class GroupBalancerTest {
               new 
org.apache.accumulo.core.master.thrift.TabletServerStatus()));
         }
 
-        balancer.balance(new BalanceParamsImpl(current, migrations, 
migrationsOut));
+        balancer
+            .balance(new BalanceParamsImpl(current, migrations, migrationsOut, 
DataLevel.of(tid)));
 
         assertTrue(migrationsOut.size() <= (maxMigrations + 5),
             "Max Migration exceeded " + maxMigrations + " " + 
migrationsOut.size());
diff --git 
a/core/src/test/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancerReconfigurationTest.java
 
b/core/src/test/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancerReconfigurationTest.java
index f6b2123b6d..58a89ec626 100644
--- 
a/core/src/test/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancerReconfigurationTest.java
+++ 
b/core/src/test/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancerReconfigurationTest.java
@@ -43,6 +43,7 @@ import org.apache.accumulo.core.dataImpl.KeyExtent;
 import org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl;
 import org.apache.accumulo.core.manager.balancer.BalanceParamsImpl;
 import org.apache.accumulo.core.manager.balancer.TabletStatisticsImpl;
+import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
 import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
 import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
 import org.apache.accumulo.core.spi.balancer.data.TabletStatistics;
@@ -107,16 +108,19 @@ public class HostRegexTableLoadBalancerReconfigurationTest
     // getOnlineTabletsForTable
     UtilWaitThread.sleep(3000);
     this.balance(new 
BalanceParamsImpl(Collections.unmodifiableSortedMap(allTabletServers),
-        migrations, migrationsOut));
+        migrations, migrationsOut, DataLevel.USER));
     assertEquals(0, migrationsOut.size());
     // Change property, simulate call by TableConfWatcher
 
     config.set(HostRegexTableLoadBalancer.HOST_BALANCER_PREFIX + 
BAR.getTableName(), "r01.*");
 
-    // Wait to trigger the out of bounds check and the repool check
-    UtilWaitThread.sleep(10000);
+    // calls to balance will clear the lastOOBCheckTimes map
+    // in the HostRegexTableLoadBalancer. For this test we want
+    // to get into the out of bounds checking code, so we need to
+    // populate the map with an older time value
+    this.lastOOBCheckTimes.put(DataLevel.USER, System.currentTimeMillis() / 2);
     this.balance(new 
BalanceParamsImpl(Collections.unmodifiableSortedMap(allTabletServers),
-        migrations, migrationsOut));
+        migrations, migrationsOut, DataLevel.USER));
     assertEquals(5, migrationsOut.size());
     for (TabletMigration migration : migrationsOut) {
       
assertTrue(migration.getNewTabletServer().getHost().startsWith("192.168.0.1")
diff --git 
a/core/src/test/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancerTest.java
 
b/core/src/test/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancerTest.java
index 298bb8b995..4d3162e02d 100644
--- 
a/core/src/test/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancerTest.java
+++ 
b/core/src/test/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancerTest.java
@@ -48,13 +48,13 @@ import 
org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl;
 import org.apache.accumulo.core.manager.balancer.BalanceParamsImpl;
 import org.apache.accumulo.core.manager.balancer.TabletServerIdImpl;
 import org.apache.accumulo.core.manager.balancer.TabletStatisticsImpl;
+import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
 import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
 import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
 import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
 import org.apache.accumulo.core.spi.balancer.data.TabletStatistics;
 import org.apache.accumulo.core.tabletserver.thrift.TabletStats;
 import org.apache.accumulo.core.util.ConfigurationImpl;
-import org.apache.accumulo.core.util.UtilWaitThread;
 import org.junit.jupiter.api.Test;
 
 public class HostRegexTableLoadBalancerTest extends 
BaseHostRegexTableLoadBalancerTest {
@@ -98,7 +98,7 @@ public class HostRegexTableLoadBalancerTest extends 
BaseHostRegexTableLoadBalanc
     List<TabletMigration> migrationsOut = new ArrayList<>();
     long wait =
         this.balance(new 
BalanceParamsImpl(Collections.unmodifiableSortedMap(createCurrent(15)),
-            migrations, migrationsOut));
+            migrations, migrationsOut, DataLevel.USER));
     assertEquals(20000, wait);
     // should balance four tablets in one of the tables before reaching max
     assertEquals(4, migrationsOut.size());
@@ -109,7 +109,7 @@ public class HostRegexTableLoadBalancerTest extends 
BaseHostRegexTableLoadBalanc
     }
     migrationsOut.clear();
     wait = this.balance(new 
BalanceParamsImpl(Collections.unmodifiableSortedMap(createCurrent(15)),
-        migrations, migrationsOut));
+        migrations, migrationsOut, DataLevel.USER));
     assertEquals(20000, wait);
     // should balance four tablets in one of the other tables before reaching 
max
     assertEquals(4, migrationsOut.size());
@@ -120,7 +120,7 @@ public class HostRegexTableLoadBalancerTest extends 
BaseHostRegexTableLoadBalanc
     }
     migrationsOut.clear();
     wait = this.balance(new 
BalanceParamsImpl(Collections.unmodifiableSortedMap(createCurrent(15)),
-        migrations, migrationsOut));
+        migrations, migrationsOut, DataLevel.USER));
     assertEquals(20000, wait);
     // should balance four tablets in one of the other tables before reaching 
max
     assertEquals(4, migrationsOut.size());
@@ -131,7 +131,7 @@ public class HostRegexTableLoadBalancerTest extends 
BaseHostRegexTableLoadBalanc
     }
     migrationsOut.clear();
     wait = this.balance(new 
BalanceParamsImpl(Collections.unmodifiableSortedMap(createCurrent(15)),
-        migrations, migrationsOut));
+        migrations, migrationsOut, DataLevel.USER));
     assertEquals(20000, wait);
     // no more balancing to do
     assertEquals(0, migrationsOut.size());
@@ -148,7 +148,7 @@ public class HostRegexTableLoadBalancerTest extends 
BaseHostRegexTableLoadBalanc
     migrations.addAll(tableTablets.get(BAR.getTableName()));
     long wait =
         this.balance(new 
BalanceParamsImpl(Collections.unmodifiableSortedMap(createCurrent(15)),
-            migrations, migrationsOut));
+            migrations, migrationsOut, DataLevel.USER));
     assertEquals(20000, wait);
     // no migrations should have occurred as 10 is the maxOutstandingMigrations
     assertEquals(0, migrationsOut.size());
@@ -487,13 +487,16 @@ public class HostRegexTableLoadBalancerTest extends 
BaseHostRegexTableLoadBalanc
 
   @Test
   public void testOutOfBoundsTablets() {
+    // calls to balance will clear the lastOOBCheckTimes map
+    // in the HostRegexTableLoadBalancer. For this test we want
+    // to get into the out of bounds checking code, so we need to
+    // populate the map with an older time value
+    this.lastOOBCheckTimes.put(DataLevel.USER, System.currentTimeMillis() / 2);
     init(DEFAULT_TABLE_PROPERTIES);
-    // Wait to trigger the out of bounds check which will call our version of
-    // getOnlineTabletsForTable
-    UtilWaitThread.sleep(11000);
     Set<TabletId> migrations = new HashSet<>();
     List<TabletMigration> migrationsOut = new ArrayList<>();
-    this.balance(new BalanceParamsImpl(createCurrent(15), migrations, 
migrationsOut));
+    this.balance(
+        new BalanceParamsImpl(createCurrent(15), migrations, migrationsOut, 
DataLevel.USER));
     assertEquals(2, migrationsOut.size());
   }
 
diff --git 
a/core/src/test/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancerTest.java
 
b/core/src/test/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancerTest.java
index 53889be484..055898928b 100644
--- 
a/core/src/test/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancerTest.java
+++ 
b/core/src/test/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancerTest.java
@@ -42,6 +42,7 @@ import 
org.apache.accumulo.core.manager.balancer.TServerStatusImpl;
 import org.apache.accumulo.core.manager.balancer.TabletServerIdImpl;
 import org.apache.accumulo.core.manager.balancer.TabletStatisticsImpl;
 import org.apache.accumulo.core.master.thrift.TableInfo;
+import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
 import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
 import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
 import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
@@ -202,7 +203,8 @@ public class SimpleLoadBalancerTest {
     // balance until we can't balance no more!
     while (true) {
       List<TabletMigration> migrationsOut = new ArrayList<>();
-      balancer.balance(new BalanceParamsImpl(getAssignments(servers), 
migrations, migrationsOut));
+      balancer.balance(new BalanceParamsImpl(getAssignments(servers), 
migrations, migrationsOut,
+          DataLevel.USER));
       if (migrationsOut.isEmpty()) {
         break;
       }
@@ -244,7 +246,8 @@ public class SimpleLoadBalancerTest {
     // balance until we can't balance no more!
     while (true) {
       List<TabletMigration> migrationsOut = new ArrayList<>();
-      balancer.balance(new BalanceParamsImpl(getAssignments(servers), 
migrations, migrationsOut));
+      balancer.balance(new BalanceParamsImpl(getAssignments(servers), 
migrations, migrationsOut,
+          DataLevel.USER));
       if (migrationsOut.isEmpty()) {
         break;
       }
diff --git 
a/core/src/test/java/org/apache/accumulo/core/spi/balancer/TableLoadBalancerTest.java
 
b/core/src/test/java/org/apache/accumulo/core/spi/balancer/TableLoadBalancerTest.java
index 9d856e6052..8e9aefd028 100644
--- 
a/core/src/test/java/org/apache/accumulo/core/spi/balancer/TableLoadBalancerTest.java
+++ 
b/core/src/test/java/org/apache/accumulo/core/spi/balancer/TableLoadBalancerTest.java
@@ -44,6 +44,7 @@ import 
org.apache.accumulo.core.manager.balancer.TServerStatusImpl;
 import org.apache.accumulo.core.manager.balancer.TabletServerIdImpl;
 import org.apache.accumulo.core.manager.balancer.TabletStatisticsImpl;
 import org.apache.accumulo.core.master.thrift.TableInfo;
+import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
 import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
 import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
 import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
@@ -141,13 +142,13 @@ public class TableLoadBalancerTest {
     List<TabletMigration> migrationsOut = new ArrayList<>();
     TableLoadBalancer tls = new TableLoadBalancer();
     tls.init(environment);
-    tls.balance(new BalanceParamsImpl(state, migrations, migrationsOut));
+    tls.balance(new BalanceParamsImpl(state, migrations, migrationsOut, 
DataLevel.USER));
     assertEquals(0, migrationsOut.size());
 
     state.put(mkts("10.0.0.2", 2345, "0x02030405"), status());
     tls = new TableLoadBalancer();
     tls.init(environment);
-    tls.balance(new BalanceParamsImpl(state, migrations, migrationsOut));
+    tls.balance(new BalanceParamsImpl(state, migrations, migrationsOut, 
DataLevel.USER));
     int count = 0;
     Map<TableId,Integer> movedByTable = new HashMap<>();
     movedByTable.put(TableId.of(t1Id), 0);
diff --git 
a/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java 
b/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
index 44800d5833..5525575153 100644
--- a/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
+++ b/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
@@ -1076,7 +1076,7 @@ public class Manager extends AbstractServer
           }
 
           params = BalanceParamsImpl.fromThrift(statusForBalancerLevel, 
tserverStatusForLevel,
-              partitionedMigrations.get(dl));
+              partitionedMigrations.get(dl), dl);
           wait = Math.max(tabletBalancer.balance(params), wait);
           migrationsOutForLevel = 0;
           for (TabletMigration m : 
checkMigrationSanity(statusForBalancerLevel.keySet(),
diff --git 
a/test/src/test/java/org/apache/accumulo/test/ChaoticLoadBalancerTest.java 
b/test/src/test/java/org/apache/accumulo/test/ChaoticLoadBalancerTest.java
index 90a2646417..57fbd33247 100644
--- a/test/src/test/java/org/apache/accumulo/test/ChaoticLoadBalancerTest.java
+++ b/test/src/test/java/org/apache/accumulo/test/ChaoticLoadBalancerTest.java
@@ -40,6 +40,7 @@ import 
org.apache.accumulo.core.manager.balancer.TServerStatusImpl;
 import org.apache.accumulo.core.manager.balancer.TabletServerIdImpl;
 import org.apache.accumulo.core.manager.balancer.TabletStatisticsImpl;
 import org.apache.accumulo.core.master.thrift.TableInfo;
+import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
 import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
 import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
 import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
@@ -157,7 +158,8 @@ public class ChaoticLoadBalancerTest {
     // amount, or even expected amount
     List<TabletMigration> migrationsOut = new ArrayList<>();
     while (!migrationsOut.isEmpty()) {
-      balancer.balance(new BalanceParamsImpl(getAssignments(servers), 
migrations, migrationsOut));
+      balancer.balance(new BalanceParamsImpl(getAssignments(servers), 
migrations, migrationsOut,
+          DataLevel.USER));
     }
   }
 

Reply via email to