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

dlmarion 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 a8f22a09e7 Replaced CompactionHost with ServerId (#4963)
a8f22a09e7 is described below

commit a8f22a09e726197cd6db0b9082290cc0c23ea511
Author: Dave Marion <dlmar...@apache.org>
AuthorDate: Thu Oct 17 13:29:42 2024 -0400

    Replaced CompactionHost with ServerId (#4963)
    
    Closes #4954
---
 .../core/client/admin/ActiveCompaction.java        | 21 ++-----------
 .../core/clientImpl/ActiveCompactionImpl.java      | 36 +++-------------------
 .../shell/commands/ActiveCompactionHelper.java     |  8 ++---
 .../accumulo/test/functional/CompactionIT.java     | 25 +++++++--------
 4 files changed, 20 insertions(+), 70 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveCompaction.java
 
b/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveCompaction.java
index 8f8f564869..c3b7831162 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveCompaction.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveCompaction.java
@@ -22,6 +22,7 @@ import java.util.List;
 
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.admin.servers.ServerId;
 import org.apache.accumulo.core.data.TabletId;
 
 /**
@@ -132,28 +133,10 @@ public abstract class ActiveCompaction {
    */
   public abstract List<IteratorSetting> getIterators();
 
-  /**
-   * @since 2.1.0
-   */
-  @Deprecated
-  public interface CompactionHost {
-    enum Type {
-      TSERVER, COMPACTOR
-    }
-
-    Type getType();
-
-    String getAddress();
-
-    int getPort();
-
-    String getResourceGroup();
-  }
-
   /**
    * Return the host where the compaction is running.
    *
    * @since 2.1.0
    */
-  public abstract CompactionHost getHost();
+  public abstract ServerId getHost();
 }
diff --git 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/ActiveCompactionImpl.java
 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/ActiveCompactionImpl.java
index af591d2b38..a041220fd8 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/ActiveCompactionImpl.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/ActiveCompactionImpl.java
@@ -31,28 +31,20 @@ import org.apache.accumulo.core.dataImpl.KeyExtent;
 import org.apache.accumulo.core.dataImpl.TabletIdImpl;
 import org.apache.accumulo.core.dataImpl.thrift.IterInfo;
 
-import com.google.common.net.HostAndPort;
-
 /**
  * @since 1.6.0
  */
-@SuppressWarnings("deprecation")
 public class ActiveCompactionImpl extends ActiveCompaction {
 
   private final org.apache.accumulo.core.tabletserver.thrift.ActiveCompaction 
tac;
   private final ClientContext context;
-  private final HostAndPort hostport;
-  private final CompactionHost.Type type;
-  private final String resourceGroup;
+  private final ServerId server;
 
   ActiveCompactionImpl(ClientContext context,
       org.apache.accumulo.core.tabletserver.thrift.ActiveCompaction tac, 
ServerId server) {
     this.tac = tac;
     this.context = context;
-    this.hostport = HostAndPort.fromParts(server.getHost(), server.getPort());
-    this.type = server.getType() == ServerId.Type.COMPACTOR ? 
CompactionHost.Type.COMPACTOR
-        : CompactionHost.Type.TSERVER;
-    this.resourceGroup = server.getResourceGroup();
+    this.server = server;
   }
 
   @Override
@@ -127,27 +119,7 @@ public class ActiveCompactionImpl extends ActiveCompaction 
{
   }
 
   @Override
-  public CompactionHost getHost() {
-    return new CompactionHost() {
-      @Override
-      public Type getType() {
-        return type;
-      }
-
-      @Override
-      public String getAddress() {
-        return hostport.getHost();
-      }
-
-      @Override
-      public int getPort() {
-        return hostport.getPort();
-      }
-
-      @Override
-      public String getResourceGroup() {
-        return resourceGroup;
-      }
-    };
+  public ServerId getHost() {
+    return server;
   }
 }
diff --git 
a/shell/src/main/java/org/apache/accumulo/shell/commands/ActiveCompactionHelper.java
 
b/shell/src/main/java/org/apache/accumulo/shell/commands/ActiveCompactionHelper.java
index 2ae7c7a8a6..81d9e35cd1 100644
--- 
a/shell/src/main/java/org/apache/accumulo/shell/commands/ActiveCompactionHelper.java
+++ 
b/shell/src/main/java/org/apache/accumulo/shell/commands/ActiveCompactionHelper.java
@@ -67,7 +67,6 @@ class ActiveCompactionHelper {
     return maxDecimal(count / 1_000_000_000.0) + "B";
   }
 
-  @SuppressWarnings("deprecation")
   private static String formatActiveCompactionLine(ActiveCompaction ac) {
     String output = ac.getOutputFile();
     int index = output.indexOf("tables");
@@ -84,7 +83,7 @@ class ActiveCompactionHelper {
 
     String hostSuffix;
     switch (ac.getHost().getType()) {
-      case TSERVER:
+      case TABLET_SERVER:
         hostSuffix = "";
         break;
       case COMPACTOR:
@@ -95,7 +94,7 @@ class ActiveCompactionHelper {
         break;
     }
 
-    String host = ac.getHost().getAddress() + ":" + ac.getHost().getPort() + 
hostSuffix;
+    String host = ac.getHost().toHostPortString() + hostSuffix;
 
     try {
       var dur = new DurationFormat(ac.getAge(), "");
@@ -139,9 +138,8 @@ class ActiveCompactionHelper {
   }
 
   public static Stream<String> activeCompactions(InstanceOperations 
instanceOps) {
-    @SuppressWarnings("deprecation")
     Comparator<ActiveCompaction> comparator =
-        Comparator.comparing((ActiveCompaction ac) -> 
ac.getHost().getAddress())
+        Comparator.comparing((ActiveCompaction ac) -> ac.getHost().getHost())
             .thenComparing(ac -> 
ac.getHost().getPort()).thenComparing(COMPACTION_AGE_DESCENDING);
     try {
       return instanceOps.getActiveCompactions().stream().sorted(comparator)
diff --git 
a/test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java 
b/test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java
index 9d034a933f..0f7acde3b3 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java
@@ -65,7 +65,6 @@ import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.admin.ActiveCompaction;
-import org.apache.accumulo.core.client.admin.ActiveCompaction.CompactionHost;
 import org.apache.accumulo.core.client.admin.CompactionConfig;
 import org.apache.accumulo.core.client.admin.NewTableConfiguration;
 import org.apache.accumulo.core.client.admin.PluginConfig;
@@ -1123,7 +1122,6 @@ public class CompactionIT extends CompactionBaseIT {
     return files;
   }
 
-  @SuppressWarnings("deprecation")
   @Test
   public void testGetActiveCompactions() throws Exception {
     final String table1 = this.getUniqueNames(1)[0];
@@ -1173,21 +1171,20 @@ public class CompactionIT extends CompactionBaseIT {
       } while (compactions.isEmpty());
 
       ActiveCompaction running1 = compactions.get(0);
-      CompactionHost host = running1.getHost();
-      assertTrue(host.getType() == CompactionHost.Type.COMPACTOR);
+      ServerId host = running1.getHost();
+      assertTrue(host.getType() == ServerId.Type.COMPACTOR);
 
       compactions.clear();
       do {
-        client.instanceOperations().getActiveCompactions(new 
ServerId(ServerId.Type.COMPACTOR,
-            host.getResourceGroup(), host.getAddress(), 
host.getPort())).forEach((ac) -> {
-              try {
-                if (ac.getTable().equals(table1)) {
-                  compactions.add(ac);
-                }
-              } catch (TableNotFoundException e1) {
-                fail("Table was deleted during test, should not happen");
-              }
-            });
+        client.instanceOperations().getActiveCompactions(host).forEach((ac) -> 
{
+          try {
+            if (ac.getTable().equals(table1)) {
+              compactions.add(ac);
+            }
+          } catch (TableNotFoundException e1) {
+            fail("Table was deleted during test, should not happen");
+          }
+        });
         Thread.sleep(1000);
       } while (compactions.isEmpty());
 

Reply via email to