Spring for Apache Hadoop

org.springframework.yarn.config.annotation.builders
Class YarnEnvironmentBuilder

java.lang.Object
  extended by org.springframework.data.hadoop.config.common.annotation.AbstractAnnotationBuilder<O>
      extended by org.springframework.data.hadoop.config.common.annotation.AbstractConfiguredAnnotationBuilder<java.util.Map<java.lang.String,java.lang.String>,YarnEnvironmentConfigurer,YarnEnvironmentBuilder>
          extended by org.springframework.yarn.config.annotation.builders.YarnEnvironmentBuilder
All Implemented Interfaces:
AnnotationBuilder<java.util.Map<java.lang.String,java.lang.String>>, PropertiesConfigurerAware, YarnEnvironmentConfigurer

public final class YarnEnvironmentBuilder
extends AbstractConfiguredAnnotationBuilder<java.util.Map<java.lang.String,java.lang.String>,YarnEnvironmentConfigurer,YarnEnvironmentBuilder>
implements PropertiesConfigurerAware, YarnEnvironmentConfigurer

AnnotationBuilder for Yarn environment.

Author:
Janne Valkealahti

Constructor Summary
YarnEnvironmentBuilder()
          Instantiates a new yarn environment builder.
 
Method Summary
 void addClasspathEntries(java.util.ArrayList<java.lang.String> classpathEntries)
          Adds the classpath entries.
 void configuration(org.apache.hadoop.conf.Configuration configuration)
          Sets the yarn configuration.
 void configureProperties(java.util.Properties properties)
          Configure Properties.
 YarnEnvironmentConfigurer entry(java.lang.String key, java.lang.String value)
          Specify an environment variable.
 YarnEnvironmentConfigurer includeLocalSystemEnv(boolean includeLocalSystemEnv)
          Specify if existing system environment variables should be included automatically.
protected  java.util.Map<java.lang.String,java.lang.String> performBuild()
          Subclasses must implement this method to build the object that is being returned.
 YarnEnvironmentConfigurer propertiesLocation(java.lang.String... locations)
          Specify properties locations.
 void setDefaultYarnAppClasspath(java.lang.String defaultYarnAppClasspath)
          Sets the default yarn app classpath.
 void setDelimiter(java.lang.String delimiter)
          Sets the delimiter.
 void setIncludeBaseDirectory(boolean includeBaseDirectory)
          Sets the include base directory.
 void setUseDefaultYarnClasspath(boolean useDefaultClasspath)
          Sets the default classpath.
 EnvironmentClasspathConfigurer withClasspath()
          Specify a classpath environment variable.
 PropertiesConfigurer<YarnEnvironmentConfigurer> withProperties()
          Specify properties with a PropertiesConfigurer.
 
Methods inherited from class org.springframework.data.hadoop.config.common.annotation.AbstractConfiguredAnnotationBuilder
apply, apply, beforeConfigureMains, beforeConfigurePosts, beforeInit, doBuild, getConfigurer, getConfigurers, getOrApply, getOrBuild, getSharedObject, getSharedObjects, objectPostProcessor, postProcess, removeConfigurer, removeConfigurers, setSharedObject
 
Methods inherited from class org.springframework.data.hadoop.config.common.annotation.AbstractAnnotationBuilder
build, getObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

YarnEnvironmentBuilder

public YarnEnvironmentBuilder()
Instantiates a new yarn environment builder.

Method Detail

performBuild

protected java.util.Map<java.lang.String,java.lang.String> performBuild()
                                                                 throws java.lang.Exception
Description copied from class: AbstractConfiguredAnnotationBuilder
Subclasses must implement this method to build the object that is being returned.

Specified by:
performBuild in class AbstractConfiguredAnnotationBuilder<java.util.Map<java.lang.String,java.lang.String>,YarnEnvironmentConfigurer,YarnEnvironmentBuilder>
Returns:
Object build by this builder
Throws:
java.lang.Exception

configureProperties

public void configureProperties(java.util.Properties properties)
Description copied from interface: PropertiesConfigurerAware
Configure Properties.

Specified by:
configureProperties in interface PropertiesConfigurerAware
Parameters:
properties - the properties

withClasspath

public EnvironmentClasspathConfigurer withClasspath()
                                             throws java.lang.Exception
Description copied from interface: YarnEnvironmentConfigurer
Specify a classpath environment variable.

Applies a new DefaultEnvironmentClasspathConfigurer into current builder. Equivalents between JavaConfig and XML are shown below.

JavaConfig:

 public void configure(YarnEnvironmentBuilder environment) throws Exception {
   environment
     .withClasspath()
       .entry("cpEntry1")
       .entry("cpEntry2")
       .useDefaultYarnClasspath(true);
 }
 

XML:

 <yarn:environment>
   <yarn:classpath use-default-yarn-classpath="true" delimiter=":">
     cpEntry1
     cpEntry2
   </yarn:classpath>
 </yarn:environment>
 

Specified by:
withClasspath in interface YarnEnvironmentConfigurer
Returns:
DefaultEnvironmentClasspathConfigurer for classpath
Throws:
java.lang.Exception - if error occurred

entry

public YarnEnvironmentConfigurer entry(java.lang.String key,
                                       java.lang.String value)
Description copied from interface: YarnEnvironmentConfigurer
Specify an environment variable.

JavaConfig:

 public void configure(YarnEnvironmentConfigure environment) throws Exception {
   environment
     .entry("myKey1","myValue1")
     .entry("myKey2","myValue2");
 }
 

XML:

 <yarn:environment>
   myKey1=myValue1
   myKey2=myValue2
 </yarn:environment>
 

Specified by:
entry in interface YarnEnvironmentConfigurer
Parameters:
key - The environment key
value - The environment value
Returns:
YarnEnvironmentConfigurer for chaining

propertiesLocation

public YarnEnvironmentConfigurer propertiesLocation(java.lang.String... locations)
                                             throws java.io.IOException
Description copied from interface: YarnEnvironmentConfigurer
Specify properties locations.

JavaConfig:

 public void configure(YarnEnvironmentConfigure environment) throws Exception {
   environment
     .entry("myKey1","myValue1")
     .entry("myKey2","myValue2")
     .propertiesLocation("cfg-1.properties", "cfg-2.properties");
 }
 

XML:

 <yarn:environment properties-location="cfg-1.properties, cfg-2.properties">
   myKey1=myValue1
   myKey2=myValue2
 </yarn:environment>
 

Specified by:
propertiesLocation in interface YarnEnvironmentConfigurer
Parameters:
locations - The properties file locations
Returns:
YarnEnvironmentConfigurer for chaining
Throws:
java.io.IOException - if error occurred

includeLocalSystemEnv

public YarnEnvironmentConfigurer includeLocalSystemEnv(boolean includeLocalSystemEnv)
Description copied from interface: YarnEnvironmentConfigurer
Specify if existing system environment variables should be included automatically.

JavaConfig:

 public void configure(YarnEnvironmentConfigure environment) throws Exception {
   environment
     .includeLocalSystemEnv(false);
 }
 

XML:

 <yarn:environment include-local-system-env="false"/>
 

Specified by:
includeLocalSystemEnv in interface YarnEnvironmentConfigurer
Parameters:
includeLocalSystemEnv - if system env variables should be included
Returns:
YarnEnvironmentConfigurer for chaining

withProperties

public PropertiesConfigurer<YarnEnvironmentConfigurer> withProperties()
                                                               throws java.lang.Exception
Description copied from interface: YarnEnvironmentConfigurer
Specify properties with a PropertiesConfigurer.

JavaConfig:

 public void configure(YarnEnvironmentConfigure environment) throws Exception {
   Properties props = new Properties();
   environment
     .withProperties()
       .properties(props)
       .property("myKey1", ",myValue1")
       .and();
 }
 

XML:

 <util:properties id="props" location="props.properties"/>
   myValue1
 </util:properties>
 <yarn:environment properties-ref="props"/>
 

Specified by:
withProperties in interface YarnEnvironmentConfigurer
Returns:
PropertiesConfigurer for chaining
Throws:
java.lang.Exception - if error occurred

addClasspathEntries

public void addClasspathEntries(java.util.ArrayList<java.lang.String> classpathEntries)
Adds the classpath entries.

Parameters:
classpathEntries - the classpath entries

configuration

public void configuration(org.apache.hadoop.conf.Configuration configuration)
Sets the yarn configuration.

Parameters:
configuration - the yarn configuration

setUseDefaultYarnClasspath

public void setUseDefaultYarnClasspath(boolean useDefaultClasspath)
Sets the default classpath.

Parameters:
useDefaultClasspath - the new default classpath

setIncludeBaseDirectory

public void setIncludeBaseDirectory(boolean includeBaseDirectory)
Sets the include base directory.

Parameters:
includeBaseDirectory - the new include base directory

setDelimiter

public void setDelimiter(java.lang.String delimiter)
Sets the delimiter.

Parameters:
delimiter - the new delimiter

setDefaultYarnAppClasspath

public void setDefaultYarnAppClasspath(java.lang.String defaultYarnAppClasspath)
Sets the default yarn app classpath.

Parameters:
defaultYarnAppClasspath - the new default yarn app classpath

Spring for Apache Hadoop