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

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


The following commit(s) were added to refs/heads/main by this push:
     new 8f18db4  Warn in constructor when deprecated balancers are used re 
#1880
8f18db4 is described below

commit 8f18db4e3c1c4ba3fffffe6b32743e7772686526
Author: Brian Loss <brianl...@apache.org>
AuthorDate: Fri Feb 5 09:08:47 2021 -0500

    Warn in constructor when deprecated balancers are used re #1880
---
 .../apache/accumulo/core/spi/balancer/SimpleLoadBalancer.java  |  6 ++++++
 .../accumulo/server/master/balancer/DefaultLoadBalancer.java   | 10 ++++++++--
 .../apache/accumulo/server/master/balancer/GroupBalancer.java  |  8 ++++++++
 .../accumulo/server/master/balancer/TableLoadBalancer.java     |  8 ++++++++
 4 files changed, 30 insertions(+), 2 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 c19f650..683f6cc 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
@@ -55,6 +55,12 @@ import org.slf4j.LoggerFactory;
  * if possible, but otherwise assignments are made in a random fashion across 
all available tablet
  * servers.
  *
+ * <p>
+ * This balancer replaces the deprecated
+ * org.apache.accumulo.server.master.balancer.DefaultLoadBalancer which will 
be removed in a future
+ * release. This balancer has the same functionality but uses the stable SPI 
which does not expose
+ * internal types on public methods.
+ *
  * @since 2.1.0
  */
 public class SimpleLoadBalancer implements TabletBalancer {
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java
 
b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java
index 5a0f859..3f681ff 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java
@@ -34,13 +34,15 @@ import org.apache.accumulo.core.dataImpl.KeyExtent;
 import org.apache.accumulo.core.master.thrift.TableInfo;
 import org.apache.accumulo.core.master.thrift.TabletServerStatus;
 import org.apache.accumulo.core.metadata.TServerInstance;
+import org.apache.accumulo.core.spi.balancer.SimpleLoadBalancer;
 import org.apache.accumulo.core.tabletserver.thrift.TabletStats;
 import org.apache.accumulo.server.master.state.TabletMigration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * @deprecated since 2.1.0. Use {@link 
org.apache.accumulo.core.spi.balancer.TabletBalancer} instead
+ * @deprecated since 2.1.0. Use {@link 
org.apache.accumulo.core.spi.balancer.SimpleLoadBalancer}
+ *             instead, as it as the same functionality but a stable API.
  */
 @Deprecated(since = "2.1.0")
 public class DefaultLoadBalancer extends TabletBalancer {
@@ -52,10 +54,14 @@ public class DefaultLoadBalancer extends TabletBalancer {
   TableId tableToBalance = null;
 
   public DefaultLoadBalancer() {
-
+    log.warn(
+        "{} has been deprecated and will be removed in a future release. 
Please update your "
+            + "configuration to use the equivalent {} instead.",
+        getClass().getName(), SimpleLoadBalancer.class.getName());
   }
 
   public DefaultLoadBalancer(TableId table) {
+    this(); // emit warning
     tableToBalance = table;
   }
 
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/GroupBalancer.java
 
b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/GroupBalancer.java
index d6ec3f4..561ae3f 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/GroupBalancer.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/GroupBalancer.java
@@ -46,6 +46,7 @@ import org.apache.accumulo.core.util.MapCounter;
 import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.server.master.state.TabletMigration;
 import org.apache.commons.lang3.mutable.MutableInt;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.HashBasedTable;
 import com.google.common.collect.HashMultimap;
@@ -80,6 +81,13 @@ public abstract class GroupBalancer extends TabletBalancer {
 
   public GroupBalancer(TableId tableId) {
     this.tableId = tableId;
+
+    LoggerFactory.getLogger(getClass().getName())
+        .warn("{} has been deprecated and will be "
+            + "removed in a future release. Please update your configuration 
to use the equivalent "
+            + "{} instead.", getClass().getName(),
+            
org.apache.accumulo.core.spi.balancer.GroupBalancer.class.getName());
+
   }
 
   protected Map<KeyExtent,TServerInstance> getLocationProvider() {
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java
 
b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java
index fc652a1..1c786f3 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java
@@ -50,6 +50,14 @@ public class TableLoadBalancer extends TabletBalancer {
 
   Map<TableId,TabletBalancer> perTableBalancers = new HashMap<>();
 
+  public TableLoadBalancer() {
+    log.warn(
+        "{} has been deprecated and will be removed in a future release. 
Please update your "
+            + "configuration to use the equivalent {} instead.",
+        getClass().getName(),
+        
org.apache.accumulo.core.spi.balancer.TableLoadBalancer.class.getName());
+  }
+
   private TabletBalancer constructNewBalancerForTable(String clazzName, 
TableId tableId)
       throws Exception {
     String context = null;

Reply via email to