You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by dd...@apache.org on 2025/03/21 19:29:37 UTC

(accumulo) branch bugfix/remove-SingleTableConstructor created (now 0b3938cf28)

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

ddanielr pushed a change to branch bugfix/remove-SingleTableConstructor
in repository https://gitbox.apache.org/repos/asf/accumulo.git


      at 0b3938cf28 Remove tableId constructor for SimpleLoadBalancer

This branch includes the following new commits:

     new 0b3938cf28 Remove tableId constructor for SimpleLoadBalancer

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(accumulo) 01/01: Remove tableId constructor for SimpleLoadBalancer

Posted by dd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ddanielr pushed a commit to branch bugfix/remove-SingleTableConstructor
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 0b3938cf2860a0a0535ec39665c39b385cbd227b
Author: Daniel Roberts ddanielr <dd...@gmail.com>
AuthorDate: Wed Feb 26 22:13:24 2025 +0000

    Remove tableId constructor for SimpleLoadBalancer
    
    Removes the single tableId constructor for SimpleLoadBalancer as it is
    no longer needed with the addition of the tablesToBalance map to the
    balancerParams.
---
 .../accumulo/core/spi/balancer/SimpleLoadBalancer.java | 18 +-----------------
 .../accumulo/core/spi/balancer/TableLoadBalancer.java  |  9 ++++-----
 .../core/spi/balancer/TableLoadBalancerTest.java       |  8 ++------
 3 files changed, 7 insertions(+), 28 deletions(-)

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 068e12bfcf..135cb4244c 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
@@ -66,15 +66,9 @@ public class SimpleLoadBalancer implements TabletBalancer {
   protected BalancerEnvironment environment;
 
   Iterator<TabletServerId> assignments;
-  // if tableToBalance is set, then only balance the given table
-  TableId tableToBalance = null;
 
   public SimpleLoadBalancer() {}
 
-  public SimpleLoadBalancer(TableId table) {
-    tableToBalance = table;
-  }
-
   @Override
   public void init(BalancerEnvironment balancerEnvironment) {
     this.environment = balancerEnvironment;
@@ -167,13 +161,7 @@ public class SimpleLoadBalancer implements TabletBalancer {
         int serverTotal = 0;
         if (entry.getValue() != null && entry.getValue().getTableMap() != null) {
           for (Entry<String,TableStatistics> e : entry.getValue().getTableMap().entrySet()) {
-            /*
-             * The check below was on entry.getKey(), but that resolves to a tabletserver not a
-             * tablename. Believe it should be e.getKey() which is a tablename
-             */
-            if (tableToBalance == null || tableToBalance.canonical().equals(e.getKey())) {
-              serverTotal += e.getValue().getOnlineTabletCount();
-            }
+            serverTotal += e.getValue().getOnlineTabletCount();
           }
         }
         totals.add(new ServerCounts(serverTotal, entry.getKey(), entry.getValue()));
@@ -288,10 +276,6 @@ public class SimpleLoadBalancer implements TabletBalancer {
   private TableId getTableToMigrate(ServerCounts tooMuch, Map<TableId,Integer> tooMuchMap,
       Map<TableId,Integer> tooLittleMap) {
 
-    if (tableToBalance != null) {
-      return tableToBalance;
-    }
-
     // find a table to migrate
     // look for an uneven table count
     Entry<TableId,Integer> biggestEntry = tooMuchMap.entrySet().stream().map(entry -> {
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 94e10960a3..1e7c52d89a 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
@@ -74,8 +74,8 @@ public class TableLoadBalancer implements TabletBalancer {
     String context = environment.tableContext(tableId);
     Class<? extends TabletBalancer> clazz =
         ClassLoaderUtil.loadClass(context, clazzName, TabletBalancer.class);
-    Constructor<? extends TabletBalancer> constructor = clazz.getConstructor(TableId.class);
-    return constructor.newInstance(tableId);
+    Constructor<? extends TabletBalancer> constructor = clazz.getConstructor();
+    return constructor.newInstance();
   }
 
   protected String getLoadBalancerClassNameForTable(TableId table) {
@@ -124,9 +124,8 @@ public class TableLoadBalancer implements TabletBalancer {
       }
 
       if (balancer == null) {
-        log.info("Creating balancer {} limited to balancing table {}",
-            SimpleLoadBalancer.class.getName(), tableId);
-        balancer = new SimpleLoadBalancer(tableId);
+        log.info("Creating balancer {} for table {}", SimpleLoadBalancer.class.getName(), tableId);
+        balancer = new SimpleLoadBalancer();
       }
       perTableBalancers.put(tableId, balancer);
       balancer.init(environment);
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 18ab400ac9..52b35af70d 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
@@ -104,10 +104,6 @@ public class TableLoadBalancerTest {
 
   public static class TestSimpleLoadBalancer extends SimpleLoadBalancer {
 
-    public TestSimpleLoadBalancer(TableId table) {
-      super(table);
-    }
-
     @Override
     public void init(BalancerEnvironment balancerEnvironment) {}
 
@@ -147,7 +143,7 @@ public class TableLoadBalancerTest {
     tls.init(environment);
     tls.balance(
         new BalanceParamsImpl(state, Map.of(Constants.DEFAULT_RESOURCE_GROUP_NAME, state.keySet()),
-            migrations, migrationsOut, DataLevel.USER, tableIdMap));
+            migrations, migrationsOut, DataLevel.USER, Map.of("t1", TableId.of(t1Id))));
     assertEquals(0, migrationsOut.size());
 
     state.put(mkts("10.0.0.2", 2345, "0x02030405"), status());
@@ -155,7 +151,7 @@ public class TableLoadBalancerTest {
     tls.init(environment);
     tls.balance(
         new BalanceParamsImpl(state, Map.of(Constants.DEFAULT_RESOURCE_GROUP_NAME, state.keySet()),
-            migrations, migrationsOut, DataLevel.USER, tableIdMap));
+            migrations, migrationsOut, DataLevel.USER, Map.of("t1", TableId.of(t1Id))));
     int count = 0;
     Map<TableId,Integer> movedByTable = new HashMap<>();
     movedByTable.put(TableId.of(t1Id), 0);