You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/09/07 14:43:03 UTC

[GitHub] [pinot] KKcorps commented on a diff in pull request #9288: Add Spark Job Launcher tool

KKcorps commented on code in PR #9288:
URL: https://github.com/apache/pinot/pull/9288#discussion_r964936044


##########
pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/LaunchSparkDataIngestionJobCommand.java:
##########
@@ -0,0 +1,368 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.tools.admin.command;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.JavaVersion;
+import org.apache.commons.lang3.SystemUtils;
+import org.apache.pinot.spi.auth.AuthProvider;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.filesystem.PinotFS;
+import org.apache.pinot.spi.filesystem.PinotFSFactory;
+import org.apache.pinot.spi.ingestion.batch.IngestionJobLauncher;
+import org.apache.pinot.spi.ingestion.batch.spec.PinotFSSpec;
+import org.apache.pinot.spi.ingestion.batch.spec.SegmentGenerationJobSpec;
+import org.apache.pinot.spi.plugin.PluginManager;
+import org.apache.pinot.spi.utils.GroovyTemplateUtils;
+import org.apache.pinot.tools.Command;
+import org.apache.spark.launcher.SparkLauncher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+
+/**
+ * Class to implement LaunchDataIngestionJob command.
+ *
+ */
+@CommandLine.Command(name = "LaunchSparkDataIngestionJob")
+public class LaunchSparkDataIngestionJobCommand extends AbstractBaseAdminCommand implements Command {
+  private static final Logger LOGGER = LoggerFactory.getLogger(LaunchSparkDataIngestionJobCommand.class);
+  public static final String MAIN_CLASS = "org.apache.pinot.tools.admin.command.LaunchDataIngestionJobCommand";
+  public static final String SPARK_HOME = "SPARK_HOME";
+  public static final String BASEDIR = "basedir";
+  public static final String LOCAL_FILE_PREFIX = "local://";
+  public static final String PINOT_MAIN_JAR_PREFIX = "pinot-all";
+
+  @CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, help = true, description = "Print "
+      + "this message.")
+  private boolean _help = false;
+  @CommandLine.Option(names = {"-jobSpecFile", "-jobSpec"}, required = true, description = "Ingestion job spec file")
+  private String _jobSpecFile;
+  @CommandLine.Option(names = {"-values"}, required = false, arity = "1..*", description = "Context values set to the"
+      + " job spec template")
+  private List<String> _values;
+  @CommandLine.Option(names = {"-propertyFile"}, required = false, description = "A property file contains context "
+      + "values to set the job spec template")
+  private String _propertyFile;
+  @CommandLine.Option(names = {"-pluginsToLoad"}, required = false, arity = "1..*", split = ":", description = "List "
+      + "of plugin name separated by : to load at runtime. e.g. pinto-s3:pinot-parquet")
+  private List<String> _pluginsToLoad;
+
+  // Kafka plugins need to be excluded as they contain scala dependencies which cause
+  // NoSuchMethodErrors with runtime spark.
+  // It is also fine to exclude Kafka plugins as they are not going to be used in batch ingestion in any case
+  @CommandLine.Option(names = {"-pluginsToExclude"}, defaultValue = "pinot-kafka-0.9:pinot-kafka-2.0", required =

Review Comment:
   Yes, that can be done as well. My initial thought process when writing this was to not use ingestion spec at all in the command code and only use it inside the spark job. Reason being it puts the limitation of always providing ingestion spec as a local file path and not S3.
   
   However, I did ended up using the spec because otherwise we can't load the PinotFS classes and find appropriate plugin jars in S3, GCS etc.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org