Spring for Apache Hadoop

org.springframework.yarn.config.annotation.builders
Interface YarnClientConfigurer

All Known Implementing Classes:
YarnClientBuilder

public interface YarnClientConfigurer

YarnClientConfigure is an interface for YarnClientBuilder which is exposed to user via SpringYarnConfigurerAdapter.

Typically configuration is shown below.

 @Configuration
 @EnableYarn(enable=Enable.CLIENT)
 static class Config extends SpringYarnConfigurerAdapter {

   @Override
   public void configure(YarnClientConfigure client) throws Exception {
     client
       .appName("myAppName")
       .withMasterRunner()
         .contextClass(MyAppmasterConfiguration.class);
   }

 }
 

XML:

 <yarn:client app-name="myAppName">
   <yarn:master-runner />
 </yarn:client>
 

Author:
Janne Valkealahti

Method Summary
 YarnClientConfigurer appName(java.lang.String appName)
          Specify a yarn application name.
 YarnClientConfigurer appType(java.lang.String appType)
          Specify a yarn application type.
 YarnClientConfigurer clientClass(java.lang.Class<? extends YarnClient> clazz)
          Specify a YarnClient class.
 YarnClientConfigurer clientClass(java.lang.String clazz)
          Specify a YarnClient as a fully qualified class name.
 YarnClientConfigurer masterCommands(java.lang.String... commands)
          Specify a raw array of commands used to start an application master.
 YarnClientConfigurer memory(int memory)
          Specify a yarn application containers memory reservation.
 YarnClientConfigurer memory(java.lang.String memory)
          Specify a yarn application containers memory reservation.
 YarnClientConfigurer priority(java.lang.Integer priority)
          Specify a yarn application priority.
 YarnClientConfigurer queue(java.lang.String queue)
          Specify a yarn application submission queue.
 YarnClientConfigurer virtualCores(java.lang.Integer virtualCores)
          Specify a yarn application virtual core resource count.
 ClientMasterRunnerConfigurer withMasterRunner()
          Specify a runner for Appmaster.
 

Method Detail

withMasterRunner

ClientMasterRunnerConfigurer withMasterRunner()
                                              throws java.lang.Exception
Specify a runner for Appmaster. Applies a new DefaultClientMasterRunnerConfigurer into current builder.

JavaConfig:


 public void configure(YarnClientConfigure client) throws Exception {
   client
     .withMasterRunner()
       .contextClass(MyAppmasterConfiguration.class);
 }
 

XML:

 <yarn:client>
   <yarn:master-runner />
 </yarn:client>
 

Returns:
ClientMasterRunnerConfigurer for chaining
Throws:
java.lang.Exception

appName

YarnClientConfigurer appName(java.lang.String appName)
Specify a yarn application name.

JavaConfig:


 public void configure(YarnClientConfigure client) throws Exception {
   client
     .appName("myAppName");
 }
 

XML:

 <yarn:client app-name="myAppName"/>
 

Parameters:
appName - The Yarn application name
Returns:
YarnClientConfigurer for chaining

appType

YarnClientConfigurer appType(java.lang.String appType)
Specify a yarn application type. Type is a simple string user will see as a field when querying applications from a resource manager. For example, MapReduce jobs are using type MAPREDUCE and other applications defaults to YARN.

JavaConfig:


 public void configure(YarnClientConfigure client) throws Exception {
   client
     .appType("BOOT");
 }
 

XML:

No equivalent

Parameters:
appType - The Yarn application type
Returns:
YarnClientConfigurer for chaining

masterCommands

YarnClientConfigurer masterCommands(java.lang.String... commands)
Specify a raw array of commands used to start an application master.

JavaConfig:

 public void configure(YarnClientConfigure client) throws Exception {
   client
     .masterCommands("java -jar MyApp.jar", "1>/Appmaster.stdout", "2>/Appmaster.stderr");
 }
 

XML:

 <yarn:client>
   <yarn:master-command>
     <![CDATA[
     java -jar MyApp.jar
     1>/Appmaster.stdout
     2>/Appmaster.stderr
     ]]>
   </yarn:master-command>
 </yarn:client>
 

Parameters:
commands - The Yarn container commands
Returns:
YarnAppmasterConfigurer for chaining

priority

YarnClientConfigurer priority(java.lang.Integer priority)
Specify a yarn application priority.

JavaConfig:


 public void configure(YarnClientConfigure client) throws Exception {
   client
     .priority(0);
 }
 

XML:

 <yarn:client priority="0"/>
 

Parameters:
priority - The Yarn application priority
Returns:
YarnClientConfigurer for chaining

virtualCores

YarnClientConfigurer virtualCores(java.lang.Integer virtualCores)
Specify a yarn application virtual core resource count.

JavaConfig:


 public void configure(YarnClientConfigure client) throws Exception {
   client
     .virtualCores(1);
 }
 

XML:

 <yarn:client virtualcores="1"/>
 

Parameters:
virtualCores - The Yarn application virtual core resource count
Returns:
YarnClientConfigurer for chaining

memory

YarnClientConfigurer memory(java.lang.String memory)
Specify a yarn application containers memory reservation. The memory argument is given as MegaBytes if value is a plain number. Shortcuts like 1G and 500M can be used which translates to 1024 and 500 respectively.

This method is equivalent to #memory(int) so that argument can be given as a String.

NOTE: be careful not to use a too low settings like 1000K or 1000B because those are rounded down to full MBs and thus becomes a zero. Also too high values may make resource allocation to behave badly.

JavaConfig:


 public void configure(YarnClientConfigure client) throws Exception {
   client
     .memory("1G");
 }
 

XML:

 <yarn:client memory="1024"/>
 

Parameters:
memory - The Yarn application containers memory reservation
Returns:
YarnClientConfigurer for chaining

memory

YarnClientConfigurer memory(int memory)
Specify a yarn application containers memory reservation. The memory argument is given as MegaBytes.

JavaConfig:


 public void configure(YarnClientConfigure client) throws Exception {
   client
     .memory(1024);
 }
 

XML:

 <yarn:client memory="1024"/>
 

Parameters:
memory - The Yarn application containers memory reservation
Returns:
YarnClientConfigurer for chaining
See Also:
memory(String)

queue

YarnClientConfigurer queue(java.lang.String queue)
Specify a yarn application submission queue. Specified queue is a one client requests but it's not necessarily a one where application is placed. Some Yarn schedulers may choose to change this so user should be aware of how Yarn is setup.

JavaConfig:


 public void configure(YarnClientConfigure client) throws Exception {
   client
     .queue("default");
 }
 

XML:

 <yarn:client queue="default"/>
 

Parameters:
queue - The Yarn application submission queue
Returns:
YarnClientConfigurer for chaining

clientClass

YarnClientConfigurer clientClass(java.lang.Class<? extends YarnClient> clazz)
Specify a YarnClient class.

JavaConfig:

 public void configure(YarnClientConfigure client) throws Exception {
   client
     .clientClass(MyYarnClient.class);
 }
 

XML:

No equivalent

Parameters:
clazz - The Yarn client class
Returns:
YarnClientConfigurer for chaining

clientClass

YarnClientConfigurer clientClass(java.lang.String clazz)
Specify a YarnClient as a fully qualified class name.

JavaConfig:

 public void configure(YarnClientConfigure client) throws Exception {
   client
     .clientClass("com.example.MyYarnClient");
 }
 

XML:

No equivalent

Parameters:
clazz - The Yarn client class
Returns:
YarnClientConfigurer for chaining

Spring for Apache Hadoop