Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3916#discussion_r22841693
  
    --- Diff: 
launcher/src/main/java/org/apache/spark/launcher/LauncherCommon.java ---
    @@ -0,0 +1,120 @@
    +/*
    + * 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.spark.launcher;
    +
    +import java.util.Map;
    +
    +/**
    + * Configuration key definitions for Spark jobs, and some helper methods.
    + */
    +public class LauncherCommon {
    +
    +  /** The Spark master. */
    +  public static final String SPARK_MASTER = "spark.master";
    +
    +  /** Configuration key for the driver memory. */
    +  public static final String DRIVER_MEMORY = "spark.driver.memory";
    +  /** Configuration key for the driver class path. */
    +  public static final String DRIVER_CLASSPATH = 
"spark.driver.extraClassPath";
    +  /** Configuration key for the driver VM options. */
    +  public static final String DRIVER_JAVA_OPTIONS = 
"spark.driver.extraJavaOptions";
    +  /** Configuration key for the driver native library path. */
    +  public static final String DRIVER_LIBRARY_PATH = 
"spark.driver.extraLibraryPath";
    +
    +  /** Configuration key for the executor memory. */
    +  public static final String EXECUTOR_MEMORY = "spark.executor.memory";
    +  /** Configuration key for the executor class path. */
    +  public static final String EXECUTOR_CLASSPATH = 
"spark.executor.extraClassPath";
    +  /** Configuration key for the executor VM options. */
    +  public static final String EXECUTOR_JAVA_OPTIONS = 
"spark.executor.extraJavaOptions";
    +  /** Configuration key for the executor native library path. */
    +  public static final String EXECUTOR_LIBRARY_PATH = 
"spark.executor.extraLibraryOptions";
    +  /** Configuration key for the number of executor CPU cores. */
    +  public static final String EXECUTOR_CORES = "spark.executor.cores";
    +
    +  protected static boolean isEmpty(String s) {
    +    return s == null || s.isEmpty();
    +  }
    +
    +  protected static String join(String sep, String... elements) {
    +    StringBuilder sb = new StringBuilder();
    +    for (String e : elements) {
    +      if (e != null) {
    +        if (sb.length() > 0) {
    +          sb.append(sep);
    +        }
    +        sb.append(e);
    +      }
    +    }
    +    return sb.toString();
    +  }
    +
    +  protected static String join(String sep, Iterable<String> elements) {
    +    StringBuilder sb = new StringBuilder();
    +    for (String e : elements) {
    +      if (e != null) {
    +        if (sb.length() > 0) {
    +          sb.append(sep);
    +        }
    +        sb.append(e);
    +      }
    +    }
    +    return sb.toString();
    +  }
    +
    +  protected static String find(String key, Map<?, ?>... maps) {
    +    for (Map<?, ?> map : maps) {
    +      String value = (String) map.get(key);
    +      if (!isEmpty(value)) {
    +        return value;
    +      }
    +    }
    +    return null;
    +  }
    +
    +  protected static String first(String... candidates) {
    +    for (String s : candidates) {
    +      if (!isEmpty(s)) {
    +        return s;
    +      }
    +    }
    +    return null;
    +  }
    +
    +  protected static void checkNotNull(Object o, String arg) {
    +    if (o == null) {
    +      throw new IllegalArgumentException(String.format("'%s' must not be 
null.", arg));
    +    }
    +  }
    +
    +  protected static void checkArgument(boolean check, String msg, Object... 
args) {
    +    if (!check) {
    +      throw new IllegalArgumentException(String.format(msg, args));
    +    }
    +  }
    +
    +  protected static void checkState(boolean check, String msg, Object... 
args) {
    +    if (!check) {
    +      throw new IllegalStateException(String.format(msg, args));
    +    }
    +  }
    +
    +  // To avoid subclassing outside this package.
    +  LauncherCommon() { }
    +
    +}
    --- End diff --
    
    new line


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to