You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ja...@apache.org on 2023/03/12 01:21:27 UTC
[pinot] branch master updated: 10271: Updated the code for handling the slash at the end for controller.data.dir (#10395)
This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 6db6d65adf 10271: Updated the code for handling the slash at the end for controller.data.dir (#10395)
6db6d65adf is described below
commit 6db6d65adfc7b54e9b07494f2420bc8c1b90d612
Author: Abhishek Sharma <ab...@spothero.com>
AuthorDate: Sat Mar 11 20:21:21 2023 -0500
10271: Updated the code for handling the slash at the end for controller.data.dir (#10395)
---
.../apache/pinot/controller/ControllerConf.java | 3 ++-
.../pinot/controller/ControllerConfTest.java | 23 ++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java b/pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java
index bf6e9adc81..8a07fe25be 100644
--- a/pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java
+++ b/pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java
@@ -27,6 +27,7 @@ import java.util.Optional;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.apache.commons.configuration.Configuration;
+import org.apache.commons.lang3.StringUtils;
import org.apache.helix.controller.rebalancer.strategy.AutoRebalanceStrategy;
import org.apache.pinot.common.protocols.SegmentCompletionProtocol;
import org.apache.pinot.spi.env.PinotConfiguration;
@@ -374,7 +375,7 @@ public class ControllerConf extends PinotConfiguration {
}
public void setDataDir(String dataDir) {
- setProperty(DATA_DIR, dataDir);
+ setProperty(DATA_DIR, StringUtils.removeEnd(dataDir, "/"));
}
public void setRealtimeSegmentCommitTimeoutSeconds(int timeoutSec) {
diff --git a/pinot-controller/src/test/java/org/apache/pinot/controller/ControllerConfTest.java b/pinot-controller/src/test/java/org/apache/pinot/controller/ControllerConfTest.java
index 159af6dc00..49494b914e 100644
--- a/pinot-controller/src/test/java/org/apache/pinot/controller/ControllerConfTest.java
+++ b/pinot-controller/src/test/java/org/apache/pinot/controller/ControllerConfTest.java
@@ -158,6 +158,29 @@ public class ControllerConfTest {
Assert.assertEquals(conf.getTaskManagerFrequencyInSeconds(), -1);
}
+ @Test
+ public void shouldBeAbleToSetDataDir() {
+ Map<String, Object> controllerConfig = new HashMap<>();
+ ControllerConf conf = new ControllerConf(controllerConfig);
+ Assert.assertEquals(conf.getDataDir(), null);
+
+ // test for the dataDir s3 value with ending slash
+ conf.setDataDir("s3://<bucket_name>/controller/");
+ Assert.assertEquals(conf.getDataDir(), "s3://<bucket_name>/controller");
+
+ // test for the dataDir s3 value without ending slash
+ conf.setDataDir("s3://<bucket_name>/controller");
+ Assert.assertEquals(conf.getDataDir(), "s3://<bucket_name>/controller");
+
+ // test for the dataDir non-s3 value without ending slash
+ conf.setDataDir("/tmp/PinotController");
+ Assert.assertEquals(conf.getDataDir(), "/tmp/PinotController");
+
+ // test for the dataDir non-s3 value with ending slash
+ conf.setDataDir("/tmp/PinotController/");
+ Assert.assertEquals(conf.getDataDir(), "/tmp/PinotController");
+ }
+
private void assertOnDurations(ControllerConf conf, long expectedDuration, Map<String, Object> controllerConfig) {
int segmentLevelValidationIntervalInSeconds = conf.getSegmentLevelValidationIntervalInSeconds();
int segmentRelocatorFrequencyInSeconds = conf.getSegmentRelocatorFrequencyInSeconds();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org