You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ma...@apache.org on 2021/09/24 16:07:46 UTC
[pinot] branch master updated: define and enforce static import
code style (#7483)
This is an automated email from the ASF dual-hosted git repository.
mayanks 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 f67666a define and enforce static import code style (#7483)
f67666a is described below
commit f67666aaecb4eed0acd30f4fdb6924f07fd90491
Author: Richard Startin <ri...@startree.ai>
AuthorDate: Fri Sep 24 17:07:27 2021 +0100
define and enforce static import code style (#7483)
---
config/checkstyle.xml | 49 ++++++++++++
config/suppressions.xml | 3 +
.../apache/pinot/client/DynamicBrokerSelector.java | 6 +-
.../presto/PinotScatterGatherQueryClient.java | 6 +-
.../pinot/perf/BenchmarkGeospatialSerde.java | 89 +++++++++++-----------
.../batch/hadoop/HadoopSegmentCreationMapper.java | 3 +-
.../job/partitioners/GenericPartitioner.java | 13 ++--
.../spark/jobs/SparkSegmentCreationFunction.java | 8 +-
.../apache/pinot/plugin/filesystem/GcsPinotFS.java | 8 +-
.../org/apache/pinot/plugin/filesystem/GcsUri.java | 12 +--
.../segment/local/customobject/QuantileDigest.java | 9 +--
.../segment/spi/store/SegmentDirectoryPaths.java | 6 +-
.../pinot/spi/data/DateTimeFormatPatternSpec.java | 10 +--
.../admin/command/StartControllerCommand.java | 4 +-
.../tools/admin/command/StartServerCommand.java | 6 +-
.../tools/admin/command/StartZookeeperCommand.java | 5 +-
.../tools/query/comparison/ClusterStarter.java | 5 +-
.../pinot/tools/service/PinotServiceManager.java | 5 +-
.../service/PinotServiceManagerStatusCallback.java | 7 +-
.../PinotServiceManagerInstanceResource.java | 21 +++--
20 files changed, 149 insertions(+), 126 deletions(-)
diff --git a/config/checkstyle.xml b/config/checkstyle.xml
index 6f263ee..5fb7afc 100644
--- a/config/checkstyle.xml
+++ b/config/checkstyle.xml
@@ -112,6 +112,55 @@
<module name="AvoidStarImport">
<property name="allowStaticMemberImports" value="true"/>
</module>
+ <!-- no static imports except in tests -->
+ <module name="AvoidStaticImport">
+ <property name="excludes"
+ value="com.google.common.base.Preconditions.*,
+ java.lang.Math.*,
+ java.lang.Character.*,
+ java.lang.invoke.MethodHandles.*,
+ java.lang.invoke.MethodType.*,
+ java.nio.charset.StandardCharsets.*,
+ java.util.Locale.*,
+ java.util.Objects.*,
+ java.util.concurrent.TimeUnit.*,
+ org.apache.pinot.common.request.context.FilterContext.Type.*,
+ org.apache.pinot.common.request.context.predicate.Predicate.Type.*,
+ org.apache.pinot.common.segment.generation.SegmentGenerationUtils.*,
+ org.apache.pinot.controller.recommender.realtime.provisioning.MemoryEstimator.*,
+ org.apache.pinot.controller.recommender.rules.io.params.RecommenderConstants.*,
+ org.apache.pinot.controller.recommender.rules.io.params.RecommenderConstants.FlagQueryRuleParams.*,
+ org.apache.pinot.controller.recommender.rules.io.params.RecommenderConstants.InvertedSortedIndexJointRule.*,
+ org.apache.pinot.controller.recommender.rules.io.params.RecommenderConstants.NoDictionaryOnHeapDictionaryJointRule.*,
+ org.apache.pinot.controller.recommender.rules.io.params.RecommenderConstants.PartitionRule.*,
+ org.apache.pinot.controller.recommender.rules.io.params.RecommenderConstants.RulesToExecute.*,
+ org.apache.pinot.controller.recommender.rules.utils.PredicateParseResult.*,
+ org.apache.pinot.client.utils.Constants.*,
+ org.apache.pinot.segment.local.startree.StarTreeBuilderUtils.*,
+ org.apache.pinot.segment.local.startree.v2.store.StarTreeIndexMapUtils.*,
+ org.apache.pinot.segment.local.utils.GeometryType.*,
+ org.apache.pinot.segment.spi.Constants.*,
+ org.apache.pinot.segment.spi.V1Constants.Indexes.*,
+ org.apache.pinot.segment.spi.V1Constants.MetadataKeys.Column.*,
+ org.apache.pinot.segment.spi.V1Constants.MetadataKeys.Segment.*,
+ org.apache.pinot.segment.spi.creator.SegmentVersion.*,
+ org.apache.pinot.segment.spi.index.startree.StarTreeV2Constants.*,
+ org.apache.pinot.spi.data.FieldSpec.*,
+ org.apache.pinot.spi.data.FieldSpec.DataType,
+ org.apache.pinot.spi.data.FieldSpec.DataType.*,
+ org.apache.pinot.spi.data.FieldSpec.FieldType.*,
+ org.apache.pinot.spi.plugin.PluginManager.*,
+ org.apache.pinot.spi.utils.CommonConstants.*,
+ org.apache.pinot.spi.utils.CommonConstants.Broker.*,
+ org.apache.pinot.spi.utils.CommonConstants.Broker.Request.*,
+ org.apache.pinot.spi.utils.CommonConstants.Controller.*,
+ org.apache.pinot.spi.utils.CommonConstants.Helix.*,
+ org.apache.pinot.spi.utils.CommonConstants.Segment.*,
+ org.apache.pinot.spi.utils.CommonConstants.Server.*,
+ org.apache.pinot.spi.utils.CommonConstants.Server.SegmentCompletionProtocol.*,
+ org.apache.pinot.spi.utils.EqualityUtils.*,
+ org.apache.pinot.tools.Quickstart.*"/>
+ </module>
<!-- Do not import 'sun' packages -->
<module name="IllegalImport"/>
<!-- Do not duplicate import statements -->
diff --git a/config/suppressions.xml b/config/suppressions.xml
index 8ea9d1f..a5bb097 100644
--- a/config/suppressions.xml
+++ b/config/suppressions.xml
@@ -40,4 +40,7 @@
<!-- Suppress autogenerated test files by protobuf compiler -->
<suppress checks=".*" files="/protobuf/ComplexTypes.java"/>
<suppress checks=".*" files="/protobuf/Sample.java"/>
+
+ <!-- Allow static imports in tests -->
+ <suppress checks="AvoidStaticImport" files="[\\/]src[\\/]test[\\/].*" />
</suppressions>
diff --git a/pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/DynamicBrokerSelector.java b/pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/DynamicBrokerSelector.java
index cf3cfd9..ddd10b4 100644
--- a/pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/DynamicBrokerSelector.java
+++ b/pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/DynamicBrokerSelector.java
@@ -33,9 +33,6 @@ import org.I0Itec.zkclient.IZkDataListener;
import org.I0Itec.zkclient.ZkClient;
import org.I0Itec.zkclient.serialize.BytesPushThroughSerializer;
-import static org.apache.pinot.client.ExternalViewReader.OFFLINE_SUFFIX;
-import static org.apache.pinot.client.ExternalViewReader.REALTIME_SUFFIX;
-
/**
* Maintains a mapping between table name and list of brokers
@@ -90,7 +87,8 @@ public class DynamicBrokerSelector implements BrokerSelector, IZkDataListener {
return null;
}
}
- String tableName = table.replace(OFFLINE_SUFFIX, "").replace(REALTIME_SUFFIX, "");
+ String tableName = table.replace(ExternalViewReader.OFFLINE_SUFFIX, "")
+ .replace(ExternalViewReader.REALTIME_SUFFIX, "");
List<String> list = _tableToBrokerListMapRef.get().get(tableName);
if (list != null && !list.isEmpty()) {
return list.get(RANDOM.nextInt(list.size()));
diff --git a/pinot-connectors/presto-pinot-driver/src/main/java/org/apache/pinot/connector/presto/PinotScatterGatherQueryClient.java b/pinot-connectors/presto-pinot-driver/src/main/java/org/apache/pinot/connector/presto/PinotScatterGatherQueryClient.java
index 8867a33..8a8b5f1 100644
--- a/pinot-connectors/presto-pinot-driver/src/main/java/org/apache/pinot/connector/presto/PinotScatterGatherQueryClient.java
+++ b/pinot-connectors/presto-pinot-driver/src/main/java/org/apache/pinot/connector/presto/PinotScatterGatherQueryClient.java
@@ -45,8 +45,6 @@ import org.apache.pinot.pql.parsers.Pql2Compiler;
import org.apache.pinot.spi.config.table.TableType;
import org.apache.pinot.spi.utils.builder.TableNameBuilder;
-import static java.lang.String.format;
-
public class PinotScatterGatherQueryClient {
private static final Pql2Compiler REQUEST_COMPILER = new Pql2Compiler();
@@ -249,7 +247,7 @@ public class PinotScatterGatherQueryClient {
brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(pql);
} catch (Pql2CompilationException e) {
throw new PinotException(ErrorCode.PINOT_INVALID_PQL_GENERATED,
- format("Parsing error with on %s, Error = %s", serverHost, e.getMessage()), e);
+ String.format("Parsing error with on %s, Error = %s", serverHost, e.getMessage()), e);
}
Map<org.apache.pinot.core.transport.ServerInstance, List<String>> routingTable = new HashMap<>();
@@ -313,7 +311,7 @@ public class PinotScatterGatherQueryClient {
if (queryResponses.size() != routingTable.size()) {
Map<String, String> routingTableForLogging = new HashMap<>();
routingTable.entrySet().forEach(entry -> {
- String valueToPrint = entry.getValue().size() > 10 ? format("%d segments", entry.getValue().size())
+ String valueToPrint = entry.getValue().size() > 10 ? String.format("%d segments", entry.getValue().size())
: entry.getValue().toString();
routingTableForLogging.put(entry.getKey().toString(), valueToPrint);
});
diff --git a/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkGeospatialSerde.java b/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkGeospatialSerde.java
index 6c99104..5684943 100644
--- a/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkGeospatialSerde.java
+++ b/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkGeospatialSerde.java
@@ -22,6 +22,8 @@ import com.google.common.base.Joiner;
import com.google.common.io.Resources;
import java.io.IOException;
import java.io.UncheckedIOException;
+import org.apache.pinot.core.common.ObjectSerDeUtils;
+import org.apache.pinot.segment.local.utils.GeometrySerializer;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;
@@ -29,6 +31,7 @@ import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
@@ -40,12 +43,8 @@ import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.VerboseMode;
-import static com.google.common.io.Resources.getResource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.apache.pinot.core.common.ObjectSerDeUtils.serialize;
-import static org.apache.pinot.segment.local.utils.GeometrySerializer.deserialize;
-import static org.openjdk.jmh.annotations.Mode.Throughput;
@State(Scope.Thread)
@@ -53,143 +52,143 @@ import static org.openjdk.jmh.annotations.Mode.Throughput;
@Warmup(iterations = 3, time = 3, timeUnit = SECONDS)
@Measurement(iterations = 5, time = 4, timeUnit = SECONDS)
@OutputTimeUnit(SECONDS)
-@BenchmarkMode(Throughput)
+@BenchmarkMode(Mode.Throughput)
public class BenchmarkGeospatialSerde {
// POINT
@Benchmark
public Object serializePoint(BenchmarkData data) {
- return serialize(data._point);
+ return ObjectSerDeUtils.serialize(data._point);
}
@Benchmark
public Object deserializePoint(BenchmarkData data) {
- return deserialize(data._pointSerialized);
+ return GeometrySerializer.deserialize(data._pointSerialized);
}
// MULTI POINT
@Benchmark
public Object serializeSimpleMultipoint(BenchmarkData data) {
- return serialize(data._simpleMultipoint);
+ return ObjectSerDeUtils.serialize(data._simpleMultipoint);
}
@Benchmark
public Object deserializeSimpleMultipoint(BenchmarkData data) {
- return deserialize(data._simpleMultipointSerialized);
+ return GeometrySerializer.deserialize(data._simpleMultipointSerialized);
}
@Benchmark
public Object serializeComplexMultipoint(BenchmarkData data) {
- return serialize(data._complexMultipoint);
+ return ObjectSerDeUtils.serialize(data._complexMultipoint);
}
@Benchmark
public Object deserializeComplexMultipoint(BenchmarkData data) {
- return deserialize(data._complexMultipointSerialized);
+ return GeometrySerializer.deserialize(data._complexMultipointSerialized);
}
// LINE STRING
@Benchmark
public Object serializeSimpleLineString(BenchmarkData data) {
- return serialize(data._simpleLineString);
+ return ObjectSerDeUtils.serialize(data._simpleLineString);
}
@Benchmark
public Object deserializeSimpleLineString(BenchmarkData data) {
- return deserialize(data._simpleLineStringSerialized);
+ return GeometrySerializer.deserialize(data._simpleLineStringSerialized);
}
@Benchmark
public Object serializeComplexLineString(BenchmarkData data) {
- return serialize(data._complexLineString);
+ return ObjectSerDeUtils.serialize(data._complexLineString);
}
@Benchmark
public Object deserializeComplexLineString(BenchmarkData data) {
- return deserialize(data._complexLineStringSerialized);
+ return GeometrySerializer.deserialize(data._complexLineStringSerialized);
}
// MULTILINE STRING
@Benchmark
public Object serializeSimpleMultiLineString(BenchmarkData data) {
- return serialize(data._simpleMultiLineString);
+ return ObjectSerDeUtils.serialize(data._simpleMultiLineString);
}
@Benchmark
public Object deserializeSimpleMultiLineString(BenchmarkData data) {
- return deserialize(data._simpleMultiLineStringSerialized);
+ return GeometrySerializer.deserialize(data._simpleMultiLineStringSerialized);
}
@Benchmark
public Object serializeComplexMultiLineString(BenchmarkData data) {
- return serialize(data._complexMultiLineString);
+ return ObjectSerDeUtils.serialize(data._complexMultiLineString);
}
@Benchmark
public Object deserializeComplexMultiLineString(BenchmarkData data) {
- return deserialize(data._complexMultiLineStringSerialized);
+ return GeometrySerializer.deserialize(data._complexMultiLineStringSerialized);
}
// POLYGON
@Benchmark
public Object serializeSimplePolygon(BenchmarkData data) {
- return serialize(data._simplePolygon);
+ return ObjectSerDeUtils.serialize(data._simplePolygon);
}
@Benchmark
public Object deserializeSimplePolygon(BenchmarkData data) {
- return deserialize(data._simplePolygonSerialized);
+ return GeometrySerializer.deserialize(data._simplePolygonSerialized);
}
@Benchmark
public Object serializeComplexPolygon(BenchmarkData data) {
- return serialize(data._complexPolygon);
+ return ObjectSerDeUtils.serialize(data._complexPolygon);
}
@Benchmark
public Object deserializeComplexPolygon(BenchmarkData data) {
- return deserialize(data._complexPolygonSerialized);
+ return GeometrySerializer.deserialize(data._complexPolygonSerialized);
}
// MULTI POLYGON
@Benchmark
public Object serializeSimpleMultiPolygon(BenchmarkData data) {
- return serialize(data._simpleMultiPolygon);
+ return ObjectSerDeUtils.serialize(data._simpleMultiPolygon);
}
@Benchmark
public Object deserializeSimpleMultiPolygon(BenchmarkData data) {
- return deserialize(data._simpleMultiPolygonSerialized);
+ return GeometrySerializer.deserialize(data._simpleMultiPolygonSerialized);
}
@Benchmark
public Object serializeComplexMultiPolygon(BenchmarkData data) {
- return serialize(data._complexMultiPolygon);
+ return ObjectSerDeUtils.serialize(data._complexMultiPolygon);
}
@Benchmark
public Object deserializeComplexMultiPolygon(BenchmarkData data) {
- return deserialize(data._complexMultiPolygonSerialized);
+ return GeometrySerializer.deserialize(data._complexMultiPolygonSerialized);
}
// GEOMETRY COLLECTION
@Benchmark
public Object serializeSimpleGeometryCollection(BenchmarkData data) {
- return serialize(data._simpleGeometryCollection);
+ return ObjectSerDeUtils.serialize(data._simpleGeometryCollection);
}
@Benchmark
public Object deserializeSimpleGeometryCollection(BenchmarkData data) {
- return deserialize(data._simpleGeometryCollectionSerialized);
+ return GeometrySerializer.deserialize(data._simpleGeometryCollectionSerialized);
}
@Benchmark
public Object serializeComplexGeometryCollection(BenchmarkData data) {
- return serialize(data._complexGeometryCollection);
+ return ObjectSerDeUtils.serialize(data._complexGeometryCollection);
}
@Benchmark
public Object deserializeComplexGeometryCollection(BenchmarkData data) {
- return deserialize(data._complexGeometryCollectionSerialized);
+ return GeometrySerializer.deserialize(data._complexGeometryCollectionSerialized);
}
@State(Scope.Thread)
@@ -237,42 +236,42 @@ public class BenchmarkGeospatialSerde {
@Setup
public void setup() {
_point = fromText(BenchmarkResource.POINT);
- _pointSerialized = serialize(_point);
+ _pointSerialized = ObjectSerDeUtils.serialize(_point);
_simpleMultipoint = fromText(BenchmarkResource.MULTIPOINT);
- _simpleMultipointSerialized = serialize(_simpleMultipoint);
+ _simpleMultipointSerialized = ObjectSerDeUtils.serialize(_simpleMultipoint);
_complexMultipoint = fromText(BenchmarkResource.readResource("geospatial/complex-multipoint.txt"));
- _complexMultipointSerialized = serialize(_complexMultipoint);
+ _complexMultipointSerialized = ObjectSerDeUtils.serialize(_complexMultipoint);
_simpleLineString = fromText(BenchmarkResource.LINESTRING);
- _simpleLineStringSerialized = serialize(_simpleLineString);
+ _simpleLineStringSerialized = ObjectSerDeUtils.serialize(_simpleLineString);
_complexLineString = fromText(BenchmarkResource.readResource("geospatial/complex-linestring.txt"));
- _complexLineStringSerialized = serialize(_complexLineString);
+ _complexLineStringSerialized = ObjectSerDeUtils.serialize(_complexLineString);
_simpleMultiLineString = fromText(BenchmarkResource.MULTILINESTRING);
- _simpleMultiLineStringSerialized = serialize(_simpleMultiLineString);
+ _simpleMultiLineStringSerialized = ObjectSerDeUtils.serialize(_simpleMultiLineString);
_complexMultiLineString = fromText(BenchmarkResource.readResource("geospatial/complex-multilinestring.txt"));
- _complexMultiLineStringSerialized = serialize(_complexMultiLineString);
+ _complexMultiLineStringSerialized = ObjectSerDeUtils.serialize(_complexMultiLineString);
_simplePolygon = fromText(BenchmarkResource.POLYGON);
- _simplePolygonSerialized = serialize(_simplePolygon);
+ _simplePolygonSerialized = ObjectSerDeUtils.serialize(_simplePolygon);
_complexPolygon = fromText(BenchmarkResource.readResource("geospatial/complex-polygon.txt"));
- _complexPolygonSerialized = serialize(_complexPolygon);
+ _complexPolygonSerialized = ObjectSerDeUtils.serialize(_complexPolygon);
_simpleMultiPolygon = fromText(BenchmarkResource.MULTIPOLYGON);
- _simpleMultiPolygonSerialized = serialize(_simpleMultiPolygon);
+ _simpleMultiPolygonSerialized = ObjectSerDeUtils.serialize(_simpleMultiPolygon);
_complexMultiPolygon = fromText(BenchmarkResource.readResource("geospatial/complex-multipolygon.txt"));
- _complexMultiPolygonSerialized = serialize(_complexMultiPolygon);
+ _complexMultiPolygonSerialized = ObjectSerDeUtils.serialize(_complexMultiPolygon);
_simpleGeometryCollection = fromText(BenchmarkResource.GEOMETRYCOLLECTION);
- _simpleGeometryCollectionSerialized = serialize(_simpleGeometryCollection);
+ _simpleGeometryCollectionSerialized = ObjectSerDeUtils.serialize(_simpleGeometryCollection);
_complexGeometryCollection = fromText("GEOMETRYCOLLECTION (" + Joiner.on(", ")
.join(BenchmarkResource.readResource("geospatial/complex-multipoint.txt"),
BenchmarkResource.readResource("geospatial/complex-linestring.txt"),
BenchmarkResource.readResource("geospatial/complex-multilinestring.txt"),
BenchmarkResource.readResource("geospatial/complex-polygon.txt"),
BenchmarkResource.readResource("geospatial/complex-multipolygon.txt")) + ")");
- _complexGeometryCollectionSerialized = serialize(_complexGeometryCollection);
+ _complexGeometryCollectionSerialized = ObjectSerDeUtils.serialize(_complexGeometryCollection);
}
}
@@ -296,7 +295,7 @@ public class BenchmarkGeospatialSerde {
public static String readResource(String resource) {
try {
- return Resources.toString(getResource(resource), UTF_8);
+ return Resources.toString(Resources.getResource(resource), UTF_8);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
diff --git a/pinot-plugins/pinot-batch-ingestion/pinot-batch-ingestion-hadoop/src/main/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentCreationMapper.java b/pinot-plugins/pinot-batch-ingestion/pinot-batch-ingestion-hadoop/src/main/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentCreationMapper.java
index 06d97b6..c503e42 100644
--- a/pinot-plugins/pinot-batch-ingestion/pinot-batch-ingestion-hadoop/src/main/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentCreationMapper.java
+++ b/pinot-plugins/pinot-batch-ingestion/pinot-batch-ingestion-hadoop/src/main/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentCreationMapper.java
@@ -51,7 +51,6 @@ import org.yaml.snakeyaml.Yaml;
import static org.apache.pinot.common.segment.generation.SegmentGenerationUtils.PINOT_PLUGINS_DIR;
import static org.apache.pinot.common.segment.generation.SegmentGenerationUtils.PINOT_PLUGINS_TAR_GZ;
import static org.apache.pinot.common.segment.generation.SegmentGenerationUtils.getFileName;
-import static org.apache.pinot.plugin.ingestion.batch.hadoop.HadoopSegmentGenerationJobRunner.SEGMENT_GENERATION_JOB_SPEC;
import static org.apache.pinot.spi.plugin.PluginManager.PLUGINS_DIR_PROPERTY_NAME;
import static org.apache.pinot.spi.plugin.PluginManager.PLUGINS_INCLUDE_PROPERTY_NAME;
@@ -70,7 +69,7 @@ public class HadoopSegmentCreationMapper extends Mapper<LongWritable, Text, Long
throws IOException {
_jobConf = context.getConfiguration();
Yaml yaml = new Yaml();
- String segmentGenerationJobSpecStr = _jobConf.get(SEGMENT_GENERATION_JOB_SPEC);
+ String segmentGenerationJobSpecStr = _jobConf.get(HadoopSegmentGenerationJobRunner.SEGMENT_GENERATION_JOB_SPEC);
_spec = yaml.loadAs(segmentGenerationJobSpecStr, SegmentGenerationJobSpec.class);
LOGGER.info("Segment generation job spec : {}", segmentGenerationJobSpecStr);
_localTempDir = new File(FileUtils.getTempDirectory(), "pinot-" + UUID.randomUUID());
diff --git a/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/partitioners/GenericPartitioner.java b/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/partitioners/GenericPartitioner.java
index 7ca22cf..118d310 100644
--- a/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/partitioners/GenericPartitioner.java
+++ b/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/partitioners/GenericPartitioner.java
@@ -23,14 +23,11 @@ import org.apache.avro.mapred.AvroValue;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapreduce.Partitioner;
+import org.apache.pinot.hadoop.job.InternalConfigConstants;
import org.apache.pinot.segment.spi.partition.PartitionFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.pinot.hadoop.job.InternalConfigConstants.NUM_PARTITIONS_CONFIG;
-import static org.apache.pinot.hadoop.job.InternalConfigConstants.PARTITION_COLUMN_CONFIG;
-import static org.apache.pinot.hadoop.job.InternalConfigConstants.PARTITION_FUNCTION_CONFIG;
-
public class GenericPartitioner<T> extends Partitioner<T, AvroValue<GenericRecord>> implements Configurable {
@@ -43,10 +40,10 @@ public class GenericPartitioner<T> extends Partitioner<T, AvroValue<GenericRecor
@Override
public void setConf(Configuration conf) {
_configuration = conf;
- _partitionColumn = _configuration.get(PARTITION_COLUMN_CONFIG);
- _numPartitions = Integer.parseInt(_configuration.get(NUM_PARTITIONS_CONFIG));
- _partitionFunction = PartitionFunctionFactory
- .getPartitionFunction(_configuration.get(PARTITION_FUNCTION_CONFIG, null), _numPartitions);
+ _partitionColumn = _configuration.get(InternalConfigConstants.PARTITION_COLUMN_CONFIG);
+ _numPartitions = Integer.parseInt(_configuration.get(InternalConfigConstants.NUM_PARTITIONS_CONFIG));
+ _partitionFunction = PartitionFunctionFactory.getPartitionFunction(
+ _configuration.get(InternalConfigConstants.PARTITION_FUNCTION_CONFIG, null), _numPartitions);
LOGGER.info("The partition function is: " + _partitionFunction.getClass().getName());
LOGGER.info("The partition column is: " + _partitionColumn);
diff --git a/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-spark/src/main/java/org/apache/pinot/spark/jobs/SparkSegmentCreationFunction.java b/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-spark/src/main/java/org/apache/pinot/spark/jobs/SparkSegmentCreationFunction.java
index 879d39f..3f1ecf8 100644
--- a/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-spark/src/main/java/org/apache/pinot/spark/jobs/SparkSegmentCreationFunction.java
+++ b/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-spark/src/main/java/org/apache/pinot/spark/jobs/SparkSegmentCreationFunction.java
@@ -33,6 +33,7 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.pinot.common.utils.TarGzCompressionUtils;
import org.apache.pinot.ingestion.common.JobConfigConstants;
+import org.apache.pinot.ingestion.jobs.SegmentCreationJob;
import org.apache.pinot.plugin.inputformat.csv.CSVRecordReaderConfig;
import org.apache.pinot.plugin.inputformat.protobuf.ProtoBufRecordReaderConfig;
import org.apache.pinot.plugin.inputformat.thrift.ThriftRecordReaderConfig;
@@ -55,8 +56,6 @@ import org.apache.pinot.spi.utils.JsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.pinot.spark.jobs.SparkSegmentCreationJob.getRelativeOutputPath;
-
public class SparkSegmentCreationFunction implements Serializable {
protected static final String LOCAL_TEMP_DIR = "pinot_spark_tmp";
@@ -250,9 +249,8 @@ public class SparkSegmentCreationFunction implements Serializable {
Path hdfsSegmentTarFile = new Path(_hdfsSegmentTarDir, segmentTarFileName);
if (_useRelativePath) {
- Path relativeOutputPath =
- getRelativeOutputPath(new Path(_jobConf.get(JobConfigConstants.PATH_TO_INPUT)).toUri(), hdfsInputFile.toUri(),
- _hdfsSegmentTarDir);
+ Path relativeOutputPath = SegmentCreationJob.getRelativeOutputPath(
+ new Path(_jobConf.get(JobConfigConstants.PATH_TO_INPUT)).toUri(), hdfsInputFile.toUri(), _hdfsSegmentTarDir);
hdfsSegmentTarFile = new Path(relativeOutputPath, segmentTarFileName);
}
_logger.info("Copying segment tar file from: {} to: {}", localSegmentTarFile, hdfsSegmentTarFile);
diff --git a/pinot-plugins/pinot-file-system/pinot-gcs/src/main/java/org/apache/pinot/plugin/filesystem/GcsPinotFS.java b/pinot-plugins/pinot-file-system/pinot-gcs/src/main/java/org/apache/pinot/plugin/filesystem/GcsPinotFS.java
index b506b78..65b1f82 100644
--- a/pinot-plugins/pinot-file-system/pinot-gcs/src/main/java/org/apache/pinot/plugin/filesystem/GcsPinotFS.java
+++ b/pinot-plugins/pinot-file-system/pinot-gcs/src/main/java/org/apache/pinot/plugin/filesystem/GcsPinotFS.java
@@ -51,8 +51,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkState;
-import static java.lang.String.format;
-import static org.apache.pinot.plugin.filesystem.GcsUri.createGcsUri;
public class GcsPinotFS extends PinotFS {
@@ -326,7 +324,7 @@ public class GcsPinotFS extends PinotFS {
}
page.iterateAll().forEach(blob -> {
if (!blob.getName().equals(prefix)) {
- builder.add(createGcsUri(fileUri.getBucketName(), blob.getName()).toString());
+ builder.add(GcsUri.createGcsUri(fileUri.getBucketName(), blob.getName()).toString());
}
});
String[] listedFiles = builder.build().toArray(new String[0]);
@@ -411,7 +409,7 @@ public class GcsPinotFS extends PinotFS {
private boolean copy(GcsUri srcUri, GcsUri dstUri)
throws IOException {
if (!exists(srcUri)) {
- throw new IOException(format("Source URI '%s' does not exist", srcUri));
+ throw new IOException(String.format("Source URI '%s' does not exist", srcUri));
}
if (srcUri.equals(dstUri)) {
return true;
@@ -420,7 +418,7 @@ public class GcsPinotFS extends PinotFS {
return copyFile(srcUri, dstUri);
}
if (srcUri.hasSubpath(dstUri) || dstUri.hasSubpath(srcUri)) {
- throw new IOException(format("Cannot copy from or to a subdirectory: '%s' -> '%s'", srcUri, dstUri));
+ throw new IOException(String.format("Cannot copy from or to a subdirectory: '%s' -> '%s'", srcUri, dstUri));
}
/**
* If an non-empty blob exists and does not end with "/"
diff --git a/pinot-plugins/pinot-file-system/pinot-gcs/src/main/java/org/apache/pinot/plugin/filesystem/GcsUri.java b/pinot-plugins/pinot-file-system/pinot-gcs/src/main/java/org/apache/pinot/plugin/filesystem/GcsUri.java
index 11e8fff..4a76ab7 100644
--- a/pinot-plugins/pinot-file-system/pinot-gcs/src/main/java/org/apache/pinot/plugin/filesystem/GcsUri.java
+++ b/pinot-plugins/pinot-file-system/pinot-gcs/src/main/java/org/apache/pinot/plugin/filesystem/GcsUri.java
@@ -18,15 +18,15 @@
*/
package org.apache.pinot.plugin.filesystem;
+import com.google.common.base.Strings;
import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static com.google.common.base.Suppliers.memoize;
import static java.util.Objects.requireNonNull;
@@ -48,9 +48,9 @@ public class GcsUri {
// Use uri.getAuthority() instead of uri.getHost():
// Bucket names can contain _'s: https://cloud.google.com/storage/docs/naming-buckets
_uri = createUri(uri.getAuthority(), uri.getPath().replaceAll(DELIMITER + "+", DELIMITER));
- _path = memoize(this::calculatePath);
- _prefix = memoize(this::calculatePrefix);
- _absolutePath = memoize(this::calculateAbsolutePath);
+ _path = Suppliers.memoize(this::calculatePath);
+ _prefix = Suppliers.memoize(this::calculatePrefix);
+ _absolutePath = Suppliers.memoize(this::calculateAbsolutePath);
}
public String getBucketName() {
@@ -69,7 +69,7 @@ public class GcsUri {
}
private String calculatePath() {
- if (isNullOrEmpty(_uri.getPath()) || _uri.getPath().equals(DELIMITER)) {
+ if (Strings.isNullOrEmpty(_uri.getPath()) || _uri.getPath().equals(DELIMITER)) {
return "";
}
return _uri.getPath().substring(1);
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/customobject/QuantileDigest.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/customobject/QuantileDigest.java
index 6e2f847..34a9961 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/customobject/QuantileDigest.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/customobject/QuantileDigest.java
@@ -42,7 +42,6 @@ import java.util.concurrent.atomic.AtomicLong;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static java.lang.String.format;
/**
@@ -865,10 +864,10 @@ public class QuantileDigest {
for (Node node : nodes) {
if (node._left != null) {
- builder.append(format("\t%s -> %s;\n", idFor(node), idFor(node._left)));
+ builder.append(String.format("\t%s -> %s;\n", idFor(node), idFor(node._left)));
}
if (node._right != null) {
- builder.append(format("\t%s -> %s;\n", idFor(node), idFor(node._right)));
+ builder.append(String.format("\t%s -> %s;\n", idFor(node), idFor(node._right)));
}
}
@@ -1007,8 +1006,8 @@ public class QuantileDigest {
@Override
public String toString() {
- return format("%s (level = %d, count = %s, left = %s, right = %s)", _bits, _level, _weightedCount, _left != null,
- _right != null);
+ return String.format("%s (level = %d, count = %s, left = %s, right = %s)", _bits, _level, _weightedCount,
+ _left != null, _right != null);
}
@Override
diff --git a/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/store/SegmentDirectoryPaths.java b/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/store/SegmentDirectoryPaths.java
index ef3718c..a831d11 100644
--- a/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/store/SegmentDirectoryPaths.java
+++ b/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/store/SegmentDirectoryPaths.java
@@ -25,8 +25,6 @@ import javax.annotation.Nullable;
import org.apache.pinot.segment.spi.V1Constants;
import org.apache.pinot.segment.spi.creator.SegmentVersion;
-import static org.apache.pinot.segment.spi.creator.SegmentVersion.v3;
-
public class SegmentDirectoryPaths {
private SegmentDirectoryPaths() {
@@ -51,7 +49,7 @@ public class SegmentDirectoryPaths {
public static File findSegmentDirectory(File indexDir) {
Preconditions.checkArgument(indexDir.isDirectory(), "Path: %s is not a directory", indexDir);
- File v3SegmentDir = segmentDirectoryFor(indexDir, v3);
+ File v3SegmentDir = segmentDirectoryFor(indexDir, SegmentVersion.v3);
if (v3SegmentDir.isDirectory()) {
return v3SegmentDir;
} else {
@@ -107,7 +105,7 @@ public class SegmentDirectoryPaths {
Preconditions.checkArgument(indexDir.isDirectory(), "Path: %s is not a directory", indexDir);
// Try to find v3 file first
- File v3Dir = segmentDirectoryFor(indexDir, v3);
+ File v3Dir = segmentDirectoryFor(indexDir, SegmentVersion.v3);
File v3File = new File(v3Dir, fileName);
if (v3File.exists()) {
return v3File;
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatPatternSpec.java b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatPatternSpec.java
index e91c257..2cc32af 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatPatternSpec.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatPatternSpec.java
@@ -27,8 +27,6 @@ import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
-import static org.apache.pinot.spi.data.DateTimeFieldSpec.TimeFormat;
-
public class DateTimeFormatPatternSpec {
@@ -39,14 +37,14 @@ public class DateTimeFormatPatternSpec {
public static final DateTimeZone DEFAULT_DATETIMEZONE = DateTimeZone.UTC;
public static final Locale DEFAULT_LOCALE = Locale.ENGLISH;
- private final TimeFormat _timeFormat;
+ private final DateTimeFieldSpec.TimeFormat _timeFormat;
private String _sdfPattern = null;
private DateTimeZone _dateTimeZone = DEFAULT_DATETIMEZONE;
private transient DateTimeFormatter _dateTimeFormatter;
public DateTimeFormatPatternSpec(String timeFormat, String sdfPatternWithTz) {
- _timeFormat = TimeFormat.valueOf(timeFormat);
- if (_timeFormat.equals(TimeFormat.SIMPLE_DATE_FORMAT)) {
+ _timeFormat = DateTimeFieldSpec.TimeFormat.valueOf(timeFormat);
+ if (_timeFormat.equals(DateTimeFieldSpec.TimeFormat.SIMPLE_DATE_FORMAT)) {
Matcher m = SDF_PATTERN_WITH_TIMEZONE.matcher(sdfPatternWithTz);
_sdfPattern = sdfPatternWithTz;
if (m.find()) {
@@ -58,7 +56,7 @@ public class DateTimeFormatPatternSpec {
}
}
- public TimeFormat getTimeFormat() {
+ public DateTimeFieldSpec.TimeFormat getTimeFormat() {
return _timeFormat;
}
diff --git a/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/StartControllerCommand.java b/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/StartControllerCommand.java
index f526e7a..c0f1c0f 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/StartControllerCommand.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/StartControllerCommand.java
@@ -33,8 +33,6 @@ import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.pinot.tools.utils.PinotConfigUtils.TMP_DIR;
-
/**
* Class to implement StartController command.
@@ -58,7 +56,7 @@ public class StartControllerCommand extends AbstractBaseAdminCommand implements
private String _controllerPort = DEFAULT_CONTROLLER_PORT;
@Option(name = "-dataDir", required = false, metaVar = "<string>", usage = "Path to directory containging data.")
- private String _dataDir = TMP_DIR + "data/PinotController";
+ private String _dataDir = PinotConfigUtils.TMP_DIR + "data/PinotController";
@Option(name = "-zkAddress", required = false, metaVar = "<http>", usage = "Http address of Zookeeper.")
private String _zkAddress = DEFAULT_ZK_ADDRESS;
diff --git a/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/StartServerCommand.java b/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/StartServerCommand.java
index 9587c08..2d749d7 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/StartServerCommand.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/StartServerCommand.java
@@ -33,8 +33,6 @@ import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.pinot.tools.utils.PinotConfigUtils.TMP_DIR;
-
/**
* Class to implement StartServer command.
@@ -57,11 +55,11 @@ public class StartServerCommand extends AbstractBaseAdminCommand implements Comm
private int _serverAdminPort = CommonConstants.Server.DEFAULT_ADMIN_API_PORT;
@Option(name = "-dataDir", required = false, metaVar = "<string>", usage = "Path to directory containing data.")
- private String _dataDir = TMP_DIR + "data/pinotServerData";
+ private String _dataDir = PinotConfigUtils.TMP_DIR + "data/pinotServerData";
@Option(name = "-segmentDir", required = false, metaVar = "<string>",
usage = "Path to directory containing segments.")
- private String _segmentDir = TMP_DIR + "data/pinotSegments";
+ private String _segmentDir = PinotConfigUtils.TMP_DIR + "data/pinotSegments";
@Option(name = "-zkAddress", required = false, metaVar = "<http>", usage = "Http address of Zookeeper.")
private String _zkAddress = DEFAULT_ZK_ADDRESS;
diff --git a/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/StartZookeeperCommand.java b/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/StartZookeeperCommand.java
index 698fbc0..16ddcbc 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/StartZookeeperCommand.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/StartZookeeperCommand.java
@@ -23,12 +23,11 @@ import java.io.IOException;
import org.I0Itec.zkclient.IDefaultNameSpace;
import org.apache.pinot.common.utils.ZkStarter;
import org.apache.pinot.tools.Command;
+import org.apache.pinot.tools.utils.PinotConfigUtils;
import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.pinot.tools.utils.PinotConfigUtils.TMP_DIR;
-
/**
* Class for command to start ZooKeeper.
@@ -42,7 +41,7 @@ public class StartZookeeperCommand extends AbstractBaseAdminCommand implements C
private int _zkPort = 2181;
@Option(name = "-dataDir", required = false, metaVar = "<string>", usage = "Directory for zookeper data.")
- private String _dataDir = TMP_DIR + "PinotAdmin/zkData";
+ private String _dataDir = PinotConfigUtils.TMP_DIR + "PinotAdmin/zkData";
@Option(name = "-help", required = false, help = true, aliases = {"-h", "--h", "--help"},
usage = "Print this message.")
diff --git a/pinot-tools/src/main/java/org/apache/pinot/tools/query/comparison/ClusterStarter.java b/pinot-tools/src/main/java/org/apache/pinot/tools/query/comparison/ClusterStarter.java
index d08cf87..83da477 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/query/comparison/ClusterStarter.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/query/comparison/ClusterStarter.java
@@ -33,6 +33,7 @@ import org.apache.pinot.spi.config.table.TableConfig;
import org.apache.pinot.spi.config.table.TableType;
import org.apache.pinot.spi.utils.NetUtils;
import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
+import org.apache.pinot.tools.admin.command.AbstractBaseAdminCommand;
import org.apache.pinot.tools.admin.command.AddTableCommand;
import org.apache.pinot.tools.admin.command.CreateSegmentCommand;
import org.apache.pinot.tools.admin.command.DeleteClusterCommand;
@@ -46,8 +47,6 @@ import org.apache.pinot.tools.perf.PerfBenchmarkDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.pinot.tools.admin.command.AbstractBaseAdminCommand.sendPostRequest;
-
public class ClusterStarter {
private static final Logger LOGGER = LoggerFactory.getLogger(ClusterStarter.class);
@@ -201,7 +200,7 @@ public class ClusterStarter {
TableConfig tableConfig =
new TableConfigBuilder(TableType.OFFLINE).setTableName(_tableName).setTimeColumnName(_timeColumnName)
.setTimeType(_timeUnit).setNumReplicas(3).setBrokerTenant("broker").setServerTenant("server").build();
- sendPostRequest(ControllerRequestURLBuilder.baseUrl(controllerAddress).forTableCreate(),
+ AbstractBaseAdminCommand.sendPostRequest(ControllerRequestURLBuilder.baseUrl(controllerAddress).forTableCreate(),
tableConfig.toJsonString());
}
diff --git a/pinot-tools/src/main/java/org/apache/pinot/tools/service/PinotServiceManager.java b/pinot-tools/src/main/java/org/apache/pinot/tools/service/PinotServiceManager.java
index a012647..f51a205 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/service/PinotServiceManager.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/service/PinotServiceManager.java
@@ -33,11 +33,10 @@ import org.apache.pinot.spi.services.ServiceStartable;
import org.apache.pinot.spi.utils.CommonConstants;
import org.apache.pinot.spi.utils.NetUtils;
import org.apache.pinot.tools.service.api.resources.PinotInstanceStatus;
+import org.apache.pinot.tools.utils.PinotConfigUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.pinot.tools.utils.PinotConfigUtils.getAvailablePort;
-
/**
* PinotServiceManager is a user entry point to start Pinot instances in one process.
@@ -68,7 +67,7 @@ public class PinotServiceManager {
_zkAddress = zkAddress;
_clusterName = clusterName;
if (port == 0) {
- port = getAvailablePort();
+ port = PinotConfigUtils.getAvailablePort();
}
_port = port;
if (hostname == null || hostname.isEmpty()) {
diff --git a/pinot-tools/src/main/java/org/apache/pinot/tools/service/PinotServiceManagerStatusCallback.java b/pinot-tools/src/main/java/org/apache/pinot/tools/service/PinotServiceManagerStatusCallback.java
index ab26f6b..a68f6c5 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/service/PinotServiceManagerStatusCallback.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/service/PinotServiceManagerStatusCallback.java
@@ -20,9 +20,6 @@ package org.apache.pinot.tools.service;
import org.apache.pinot.common.utils.ServiceStatus;
-import static org.apache.pinot.common.utils.ServiceStatus.STATUS_DESCRIPTION_INIT;
-import static org.apache.pinot.common.utils.ServiceStatus.STATUS_DESCRIPTION_STARTED;
-
public class PinotServiceManagerStatusCallback implements ServiceStatus.ServiceStatusCallback {
private final PinotServiceManager _pinotServiceManager;
@@ -43,9 +40,9 @@ public class PinotServiceManagerStatusCallback implements ServiceStatus.ServiceS
@Override
public String getStatusDescription() {
if (_pinotServiceManager.isStarted()) {
- return STATUS_DESCRIPTION_STARTED;
+ return ServiceStatus.STATUS_DESCRIPTION_STARTED;
} else {
- return STATUS_DESCRIPTION_INIT;
+ return ServiceStatus.STATUS_DESCRIPTION_INIT;
}
}
}
diff --git a/pinot-tools/src/main/java/org/apache/pinot/tools/service/api/resources/PinotServiceManagerInstanceResource.java b/pinot-tools/src/main/java/org/apache/pinot/tools/service/api/resources/PinotServiceManagerInstanceResource.java
index c9d0649..948c119 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/service/api/resources/PinotServiceManagerInstanceResource.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/service/api/resources/PinotServiceManagerInstanceResource.java
@@ -48,13 +48,12 @@ import org.apache.pinot.spi.utils.CommonConstants;
import org.apache.pinot.spi.utils.JsonUtils;
import org.apache.pinot.spi.utils.NetUtils;
import org.apache.pinot.tools.service.PinotServiceManager;
+import org.apache.pinot.tools.utils.PinotConfigUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.pinot.spi.utils.CommonConstants.Controller.CONFIG_OF_CONTROLLER_METRICS_PREFIX;
import static org.apache.pinot.spi.utils.CommonConstants.Controller.DEFAULT_METRICS_PREFIX;
-import static org.apache.pinot.tools.utils.PinotConfigUtils.TMP_DIR;
-import static org.apache.pinot.tools.utils.PinotConfigUtils.getAvailablePort;
@Api(tags = "Startable")
@@ -188,13 +187,13 @@ public class PinotServiceManagerInstanceResource {
String controllerPort =
Optional.ofNullable(properties.get(ControllerConf.CONTROLLER_PORT)).map(Object::toString).orElse(null);
if (controllerPort == null) {
- controllerPort = Integer.toString(getAvailablePort());
+ controllerPort = Integer.toString(PinotConfigUtils.getAvailablePort());
properties.put(ControllerConf.CONTROLLER_PORT, controllerPort);
}
if (!properties.containsKey(ControllerConf.DATA_DIR)) {
- properties.put(ControllerConf.DATA_DIR,
- TMP_DIR + String.format("Controller_%s_%s/data", controllerHost, controllerPort));
+ properties.put(ControllerConf.DATA_DIR, PinotConfigUtils.TMP_DIR
+ + String.format("Controller_%s_%s/data", controllerHost, controllerPort));
}
if (!properties.containsKey(CONFIG_OF_CONTROLLER_METRICS_PREFIX)) {
@@ -206,7 +205,7 @@ public class PinotServiceManagerInstanceResource {
case BROKER:
if (!properties.containsKey(CommonConstants.Helix.KEY_OF_BROKER_QUERY_PORT)) {
- properties.put(CommonConstants.Helix.KEY_OF_BROKER_QUERY_PORT, getAvailablePort());
+ properties.put(CommonConstants.Helix.KEY_OF_BROKER_QUERY_PORT, PinotConfigUtils.getAvailablePort());
}
if (!properties.containsKey(CommonConstants.Broker.METRICS_CONFIG_PREFIX)) {
String hostname;
@@ -231,18 +230,18 @@ public class PinotServiceManagerInstanceResource {
properties.put(CommonConstants.Helix.KEY_OF_SERVER_NETTY_HOST, hostname);
}
if (!properties.containsKey(CommonConstants.Helix.KEY_OF_SERVER_NETTY_PORT)) {
- properties.put(CommonConstants.Helix.KEY_OF_SERVER_NETTY_PORT, getAvailablePort());
+ properties.put(CommonConstants.Helix.KEY_OF_SERVER_NETTY_PORT, PinotConfigUtils.getAvailablePort());
}
if (!properties.containsKey(CommonConstants.Server.CONFIG_OF_ADMIN_API_PORT)) {
- properties.put(CommonConstants.Server.CONFIG_OF_ADMIN_API_PORT, getAvailablePort());
+ properties.put(CommonConstants.Server.CONFIG_OF_ADMIN_API_PORT, PinotConfigUtils.getAvailablePort());
}
if (!properties.containsKey(CommonConstants.Server.CONFIG_OF_INSTANCE_DATA_DIR)) {
- properties.put(CommonConstants.Server.CONFIG_OF_INSTANCE_DATA_DIR, TMP_DIR + String
+ properties.put(CommonConstants.Server.CONFIG_OF_INSTANCE_DATA_DIR, PinotConfigUtils.TMP_DIR + String
.format("Server_%s_%s/data", properties.get(CommonConstants.Helix.KEY_OF_SERVER_NETTY_HOST),
properties.get(CommonConstants.Helix.KEY_OF_SERVER_NETTY_PORT)));
}
if (!properties.containsKey(CommonConstants.Server.CONFIG_OF_INSTANCE_SEGMENT_TAR_DIR)) {
- properties.put(CommonConstants.Server.CONFIG_OF_INSTANCE_SEGMENT_TAR_DIR, TMP_DIR + String
+ properties.put(CommonConstants.Server.CONFIG_OF_INSTANCE_SEGMENT_TAR_DIR, PinotConfigUtils.TMP_DIR + String
.format("Server_%s_%s/segment", properties.get(CommonConstants.Helix.KEY_OF_SERVER_NETTY_HOST),
properties.get(CommonConstants.Helix.KEY_OF_SERVER_NETTY_PORT)));
}
@@ -256,7 +255,7 @@ public class PinotServiceManagerInstanceResource {
case MINION:
if (!properties.containsKey(CommonConstants.Helix.KEY_OF_MINION_PORT)) {
- properties.put(CommonConstants.Helix.KEY_OF_MINION_PORT, getAvailablePort());
+ properties.put(CommonConstants.Helix.KEY_OF_MINION_PORT, PinotConfigUtils.getAvailablePort());
}
if (!properties.containsKey(CommonConstants.Minion.CONFIG_OF_METRICS_PREFIX_KEY)) {
String hostname;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org