manojpec commented on a change in pull request #4092:
URL: https://github.com/apache/hudi/pull/4092#discussion_r757686219



##########
File path: hudi-cli/src/main/java/org/apache/hudi/cli/utils/SparkUtil.java
##########
@@ -62,39 +63,59 @@ public static SparkLauncher initLauncher(String 
propertiesFile) throws URISyntax
     return sparkLauncher;
   }
 
-  public static JavaSparkContext initJavaSparkConf(String name) {
-    return initJavaSparkConf(name, Option.empty(), Option.empty());
-  }
-
-  public static JavaSparkContext initJavaSparkConf(String name, Option<String> 
master,
-      Option<String> executorMemory) {
-    SparkConf sparkConf = new SparkConf().setAppName(name);
+  /**
+   * Get the default spark configuration.
+   *
+   * @param appName     - Spark application name
+   * @param sparkMaster - Spark master node name
+   * @return Spark configuration
+   */
+  public static SparkConf getDefaultConf(final String appName, final 
Option<String> sparkMaster) {
+    final Properties properties = System.getProperties();
+    SparkConf sparkConf = new SparkConf().setAppName(appName);
 
-    String defMaster = 
master.orElse(sparkConf.getenv(HoodieCliSparkConfig.CLI_SPARK_MASTER));
-    if ((null == defMaster) || (defMaster.isEmpty())) {
-      sparkConf.setMaster(DEFAULT_SPARK_MASTER);
-    } else {
-      sparkConf.setMaster(defMaster);
+    // Configure the sparkMaster
+    String sparkMasterNode = DEFAULT_SPARK_MASTER;
+    if (properties.getProperty(HoodieCliSparkConfig.CLI_SPARK_MASTER) != null) 
{
+      sparkMasterNode = 
properties.getProperty(HoodieCliSparkConfig.CLI_SPARK_MASTER);
     }
+    sparkMasterNode = sparkMaster.orElse(sparkMasterNode);
+    sparkConf.setMaster(sparkMasterNode);
 
-    sparkConf.set(HoodieCliSparkConfig.CLI_SERIALIZER, 
"org.apache.spark.serializer.KryoSerializer");
+    // Configure driver
     sparkConf.set(HoodieCliSparkConfig.CLI_DRIVER_MAX_RESULT_SIZE, "2g");
     sparkConf.set(HoodieCliSparkConfig.CLI_EVENT_LOG_OVERWRITE, "true");
-    sparkConf.set(HoodieCliSparkConfig.CLI_EVENT_LOG_ENABLED, "true");
-    if (executorMemory.isPresent()) {
-      sparkConf.set(HoodieCliSparkConfig.CLI_EXECUTOR_MEMORY, 
executorMemory.get());
-    }
+    sparkConf.set(HoodieCliSparkConfig.CLI_EVENT_LOG_ENABLED, "false");
+    sparkConf.set(HoodieCliSparkConfig.CLI_SERIALIZER, 
"org.apache.spark.serializer.KryoSerializer");
 
     // Configure hadoop conf
     sparkConf.set(HoodieCliSparkConfig.CLI_MAPRED_OUTPUT_COMPRESS, "true");
     sparkConf.set(HoodieCliSparkConfig.CLI_MAPRED_OUTPUT_COMPRESSION_CODEC, 
"true");
     sparkConf.set(HoodieCliSparkConfig.CLI_MAPRED_OUTPUT_COMPRESSION_CODEC, 
"org.apache.hadoop.io.compress.GzipCodec");
     sparkConf.set(HoodieCliSparkConfig.CLI_MAPRED_OUTPUT_COMPRESSION_TYPE, 
"BLOCK");
 
+    return sparkConf;
+  }
+
+  public static JavaSparkContext initJavaSparkConf(String name) {
+    return initJavaSparkConf(name, Option.empty(), Option.empty());
+  }
+
+  public static JavaSparkContext initJavaSparkConf(String name, Option<String> 
master, Option<String> executorMemory) {

Review comment:
       SparkMain is the app that uses this. Most other commands are using 
SparkMain infra. We need to migrate metadata command also to use that flow.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to