Class JavaCommandLineBuilder

java.lang.Object
org.apache.hadoop.yarn.service.containerlaunch.CommandLineBuilder
org.apache.hadoop.yarn.service.containerlaunch.JavaCommandLineBuilder

public class JavaCommandLineBuilder extends CommandLineBuilder
Command line builder purely for the Java CLI. Some of the define methods are designed to work with Hadoop tool and Slider launcher applications.
  • Constructor Details

    • JavaCommandLineBuilder

      public JavaCommandLineBuilder()
  • Method Details

    • getJavaBinary

      protected String getJavaBinary()
      Get the java binary. This is called in the constructor so don't try and do anything other than return a constant.
      Returns:
      the path to the Java binary
    • setJVMOpts

      public void setJVMOpts(String jvmOpts)
      Set JVM opts.
      Parameters:
      jvmOpts - JVM opts
    • enableJavaAssertions

      public void enableJavaAssertions()
      Turn Java assertions on
    • sysprop

      public void sysprop(String property, String value)
      Add a system property definition -must be used before setting the main entry point
      Parameters:
      property -
      value -
    • forceIPv4

      public JavaCommandLineBuilder forceIPv4()
    • headless

      public JavaCommandLineBuilder headless()
    • addConfOption

      public boolean addConfOption(org.apache.hadoop.conf.Configuration conf, String key)
    • addConfOptions

      public void addConfOptions(org.apache.hadoop.conf.Configuration conf, String... keys)
      Add a varargs list of configuration parameters —if they are present
      Parameters:
      conf - configuration source
      keys - keys
    • addPrefixedConfOptions

      public int addPrefixedConfOptions(org.apache.hadoop.conf.Configuration conf, String prefix)
      Add all configuration options which match the prefix
      Parameters:
      conf - configuration
      prefix - prefix, e.g "slider."
      Returns:
      the number of entries copied
    • addConfOptionToCLI

      public String addConfOptionToCLI(org.apache.hadoop.conf.Configuration conf, String key, String defVal)
      Ass a configuration option to the command line of the application
      Parameters:
      conf - configuration
      key - key
      defVal - default value
      Returns:
      the resolved configuration option
      Throws:
      IllegalArgumentException - if key is null or the looked up value is null (that is: the argument is missing and devVal was null.
    • define

      public void define(String key, String val)
      Add a -D key=val command to the CLI. This is very Hadoop API
      Parameters:
      key - key
      val - value
      Throws:
      IllegalArgumentException - if either argument is null
    • defineIfSet

      public boolean defineIfSet(String key, String val)
      Add a -D key=val command to the CLI if val is not null
      Parameters:
      key - key
      val - value
    • addMandatoryConfOption

      public void addMandatoryConfOption(org.apache.hadoop.conf.Configuration conf, String key) throws BadConfigException
      Add a mandatory config option
      Parameters:
      conf - configuration
      key - key
      Throws:
      BadConfigException - if the key is missing