From 9ac9ddd95cb7c616e7f6ad38e41e952341730253 Mon Sep 17 00:00:00 2001 From: Dave Marion Date: Fri, 3 Jan 2025 14:14:16 -0500 Subject: [PATCH] Validate group names passed in server arguments (#5222) Closes #5042 --- .../src/main/java/org/apache/accumulo/compactor/Compactor.java | 3 +++ .../test/java/org/apache/accumulo/compactor/CompactorTest.java | 2 +- .../src/main/java/org/apache/accumulo/tserver/ScanServer.java | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java b/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java index b7426ce31bc..83ff5de7ee0 100644 --- a/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java +++ b/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java @@ -30,6 +30,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import java.util.UUID; import java.util.concurrent.CountDownLatch; @@ -60,6 +61,7 @@ import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.ConfigurationCopy; import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.conf.cluster.ClusterConfigParser; import org.apache.accumulo.core.data.NamespaceId; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.dataImpl.KeyExtent; @@ -175,6 +177,7 @@ public String getQueueName() { protected Compactor(CompactorServerOpts opts, String[] args) { super("compactor", opts, args); queueName = opts.getQueueName(); + ClusterConfigParser.validateGroupNames(Set.of(queueName)); } private long getTotalEntriesRead() { diff --git a/server/compactor/src/test/java/org/apache/accumulo/compactor/CompactorTest.java b/server/compactor/src/test/java/org/apache/accumulo/compactor/CompactorTest.java index 1eb76e1016f..e6d4a32b4ed 100644 --- a/server/compactor/src/test/java/org/apache/accumulo/compactor/CompactorTest.java +++ b/server/compactor/src/test/java/org/apache/accumulo/compactor/CompactorTest.java @@ -507,7 +507,7 @@ public void testCompactionWaitProperty() { Compactor.CompactorServerOpts compactorServerOpts = PowerMock.createNiceMock(Compactor.CompactorServerOpts.class); - expect(compactorServerOpts.getQueueName()).andReturn(null); + expect(compactorServerOpts.getQueueName()).andReturn("default"); PowerMock.replayAll(); diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServer.java index 90a4fc0854e..b3301f426c2 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServer.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServer.java @@ -53,6 +53,7 @@ import org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.conf.cluster.ClusterConfigParser; import org.apache.accumulo.core.dataImpl.KeyExtent; import org.apache.accumulo.core.dataImpl.thrift.InitialMultiScan; import org.apache.accumulo.core.dataImpl.thrift.InitialScan; @@ -280,6 +281,7 @@ public ScanServer(ScanServerOpts opts, String[] args) { delegate = newThriftScanClientHandler(new WriteTracker()); this.groupName = Objects.requireNonNull(opts.getGroupName()); + ClusterConfigParser.validateGroupNames(Set.of(groupName)); ThreadPools.watchCriticalScheduledTask(getContext().getScheduledExecutor() .scheduleWithFixedDelay(() -> cleanUpReservedFiles(scanServerReservationExpiration),