Spring for Apache Hadoop

org.springframework.data.hadoop.mapreduce
Class ToolExecutor

java.lang.Object
  extended by org.springframework.data.hadoop.mapreduce.ToolExecutor
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
ToolRunner, ToolTasklet

public abstract class ToolExecutor
extends java.lang.Object

Customized executor for Tool.

Author:
Costin Leau

Constructor Summary
ToolExecutor()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  java.lang.ClassLoader createClassLoaderForJar(org.springframework.core.io.Resource jar, java.lang.ClassLoader parentCL, org.apache.hadoop.conf.Configuration cfg)
           
protected  java.lang.Integer invokeTargetObject(org.apache.hadoop.conf.Configuration cfg, org.apache.hadoop.util.Tool target, java.lang.Class<org.apache.hadoop.util.Tool> targetClass, java.lang.String[] args)
           
protected  java.lang.Class<org.apache.hadoop.util.Tool> loadClass(java.lang.String className, java.lang.ClassLoader cl)
           
protected  void postExecution(org.apache.hadoop.conf.Configuration cfg)
           
protected  void preExecution(org.apache.hadoop.conf.Configuration cfg)
           
protected  org.apache.hadoop.conf.Configuration resolveConfiguration()
           
protected  java.lang.Class<T> resolveTargetClass(org.apache.hadoop.conf.Configuration cfg)
           
protected  T resolveTargetObject(java.lang.Class<T> type)
           
protected  int runCode()
           
 void setArchives(org.springframework.core.io.Resource... archives)
          Sets the archives to be unarchive to the map reduce cluster.
 void setArguments(java.lang.String... arguments)
          Sets the arguments.
 void setBeanClassLoader(java.lang.ClassLoader classLoader)
           
 void setCloseFs(boolean closeFs)
          Indicates whether or not to close the Hadoop file-systems resulting from the custom code execution.
 void setConfiguration(org.apache.hadoop.conf.Configuration configuration)
          Sets the configuration.
 void setFiles(org.springframework.core.io.Resource... files)
          Sets the files to be copied to the map reduce cluster.
 void setJar(org.springframework.core.io.Resource jar)
          Sets the target code jar.
 void setLibs(org.springframework.core.io.Resource... libJars)
          Sets the jar files to include in the classpath.
 void setProperties(java.util.Properties properties)
          Sets the properties.
 void setTool(org.apache.hadoop.util.Tool tool)
          Sets the tool.
 void setToolClass(java.lang.String toolClassName)
          Sets the tool class by name.
 void setUser(java.lang.String user)
          Sets the user impersonation (optional) for running this job.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToolExecutor

public ToolExecutor()
Method Detail

invokeTargetObject

protected java.lang.Integer invokeTargetObject(org.apache.hadoop.conf.Configuration cfg,
                                               org.apache.hadoop.util.Tool target,
                                               java.lang.Class<org.apache.hadoop.util.Tool> targetClass,
                                               java.lang.String[] args)
                                        throws java.lang.Exception
Throws:
java.lang.Exception

loadClass

protected java.lang.Class<org.apache.hadoop.util.Tool> loadClass(java.lang.String className,
                                                                 java.lang.ClassLoader cl)

setTool

public void setTool(org.apache.hadoop.util.Tool tool)
Sets the tool.

Parameters:
tool - The tool to set.

setToolClass

public void setToolClass(java.lang.String toolClassName)
Sets the tool class by name.

Parameters:
toolClassName - the new tool class

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

runCode

protected int runCode()
               throws java.lang.Exception
Throws:
java.lang.Exception

resolveConfiguration

protected org.apache.hadoop.conf.Configuration resolveConfiguration()
                                                             throws java.lang.Exception
Throws:
java.lang.Exception

resolveTargetClass

protected java.lang.Class<T> resolveTargetClass(org.apache.hadoop.conf.Configuration cfg)
                                         throws java.lang.Exception
Throws:
java.lang.Exception

resolveTargetObject

protected T resolveTargetObject(java.lang.Class<T> type)

createClassLoaderForJar

protected java.lang.ClassLoader createClassLoaderForJar(org.springframework.core.io.Resource jar,
                                                        java.lang.ClassLoader parentCL,
                                                        org.apache.hadoop.conf.Configuration cfg)

preExecution

protected void preExecution(org.apache.hadoop.conf.Configuration cfg)

postExecution

protected void postExecution(org.apache.hadoop.conf.Configuration cfg)

setJar

public void setJar(org.springframework.core.io.Resource jar)
Sets the target code jar.

Parameters:
jar -

setArguments

public void setArguments(java.lang.String... arguments)
Sets the arguments.

Parameters:
arguments - The arguments to set.

setConfiguration

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

Parameters:
configuration - The configuration to set.

setProperties

public void setProperties(java.util.Properties properties)
Sets the properties.

Parameters:
properties - The properties to set.

setBeanClassLoader

public void setBeanClassLoader(java.lang.ClassLoader classLoader)
Specified by:
setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware

setCloseFs

public void setCloseFs(boolean closeFs)
Indicates whether or not to close the Hadoop file-systems resulting from the custom code execution. Default is true. Turn this to false if the code reuses the same file-system used by the rest of the application.

Parameters:
closeFs - the new close fs

setLibs

public void setLibs(org.springframework.core.io.Resource... libJars)
Sets the jar files to include in the classpath. Note that a pattern can be used (e.g. mydir/*.jar), which the Spring container will automatically resolve.

Parameters:
libJars - The jar files to include in the classpath.

setFiles

public void setFiles(org.springframework.core.io.Resource... files)
Sets the files to be copied to the map reduce cluster. Note that a pattern can be used (e.g. mydir/*.txt), which the Spring container will automatically resolve.

Parameters:
files - The files to copy.

setArchives

public void setArchives(org.springframework.core.io.Resource... archives)
Sets the archives to be unarchive to the map reduce cluster. Note that a pattern can be used (e.g. mydir/*.zip), which the Spring container will automatically resolve.

Parameters:
archives - The archives to unarchive on the compute machines.

setUser

public void setUser(java.lang.String user)
Sets the user impersonation (optional) for running this job. Should be used when running against a Hadoop Kerberos cluster.

Parameters:
user - user/group information

Spring for Apache Hadoop