com.cloudera.sqoop.mapreduce
Class JobBase

java.lang.Object
  extended by com.cloudera.sqoop.mapreduce.JobBase
Direct Known Subclasses:
ExportJobBase, ImportJobBase

public class JobBase
extends java.lang.Object

Base class for configuring and running a MapReduce job. Allows dependency injection, etc, for easy customization of import job types.


Field Summary
protected  java.lang.Class<? extends org.apache.hadoop.mapreduce.InputFormat> inputFormatClass
           
static org.apache.commons.logging.Log LOG
           
protected  java.lang.Class<? extends org.apache.hadoop.mapreduce.Mapper> mapperClass
           
protected  SqoopOptions options
           
protected  java.lang.Class<? extends org.apache.hadoop.mapreduce.OutputFormat> outputFormatClass
           
 
Constructor Summary
JobBase()
           
JobBase(SqoopOptions opts)
           
JobBase(SqoopOptions opts, java.lang.Class<? extends org.apache.hadoop.mapreduce.Mapper> mapperClass, java.lang.Class<? extends org.apache.hadoop.mapreduce.InputFormat> inputFormatClass, java.lang.Class<? extends org.apache.hadoop.mapreduce.OutputFormat> outputFormatClass)
           
 
Method Summary
protected  void configureInputFormat(org.apache.hadoop.mapreduce.Job job, java.lang.String tableName, java.lang.String tableClassName, java.lang.String splitByCol)
          Configure the inputformat to use for the job.
protected  void configureMapper(org.apache.hadoop.mapreduce.Job job, java.lang.String tableName, java.lang.String tableClassName)
          Set the mapper class implementation to use in the job, as well as any related configuration (e.g., map output types).
protected  int configureNumTasks(org.apache.hadoop.mapreduce.Job job)
          Configure the number of map/reduce tasks to use in the job.
protected  void configureOutputFormat(org.apache.hadoop.mapreduce.Job job, java.lang.String tableName, java.lang.String tableClassName)
          Configure the output format to use for the job.
protected  java.lang.Class<? extends org.apache.hadoop.mapreduce.InputFormat> getInputFormatClass()
           
protected  java.lang.Class<? extends org.apache.hadoop.mapreduce.Mapper> getMapperClass()
           
protected  java.lang.Class<? extends org.apache.hadoop.mapreduce.OutputFormat> getOutputFormatClass()
           
protected  void loadJars(org.apache.hadoop.conf.Configuration conf, java.lang.String ormJarFile, java.lang.String tableClassName)
          If jars must be loaded into the local environment, do so here.
protected  boolean runJob(org.apache.hadoop.mapreduce.Job job)
          Actually run the MapReduce job.
 void setInputFormatClass(java.lang.Class<? extends org.apache.hadoop.mapreduce.InputFormat> cls)
          Set the InputFormat class to use for this job.
 void setMapperClass(java.lang.Class<? extends org.apache.hadoop.mapreduce.Mapper> cls)
          Set the Mapper class to use for this job.
 void setOptions(SqoopOptions opts)
          Set the SqoopOptions configuring this job.
 void setOutputFormatClass(java.lang.Class<? extends org.apache.hadoop.mapreduce.OutputFormat> cls)
          Set the OutputFormat class to use for this job.
protected  void unloadJars()
          If any classloader was invoked by loadJars, free it here.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG

options

protected SqoopOptions options

mapperClass

protected java.lang.Class<? extends org.apache.hadoop.mapreduce.Mapper> mapperClass

inputFormatClass

protected java.lang.Class<? extends org.apache.hadoop.mapreduce.InputFormat> inputFormatClass

outputFormatClass

protected java.lang.Class<? extends org.apache.hadoop.mapreduce.OutputFormat> outputFormatClass
Constructor Detail

JobBase

public JobBase()

JobBase

public JobBase(SqoopOptions opts)

JobBase

public JobBase(SqoopOptions opts,
               java.lang.Class<? extends org.apache.hadoop.mapreduce.Mapper> mapperClass,
               java.lang.Class<? extends org.apache.hadoop.mapreduce.InputFormat> inputFormatClass,
               java.lang.Class<? extends org.apache.hadoop.mapreduce.OutputFormat> outputFormatClass)
Method Detail

getMapperClass

protected java.lang.Class<? extends org.apache.hadoop.mapreduce.Mapper> getMapperClass()
                                                                                throws java.lang.ClassNotFoundException
Returns:
the mapper class to use for the job.
Throws:
java.lang.ClassNotFoundException

getInputFormatClass

protected java.lang.Class<? extends org.apache.hadoop.mapreduce.InputFormat> getInputFormatClass()
                                                                                          throws java.lang.ClassNotFoundException
Returns:
the inputformat class to use for the job.
Throws:
java.lang.ClassNotFoundException

getOutputFormatClass

protected java.lang.Class<? extends org.apache.hadoop.mapreduce.OutputFormat> getOutputFormatClass()
                                                                                            throws java.lang.ClassNotFoundException
Returns:
the outputformat class to use for the job.
Throws:
java.lang.ClassNotFoundException

setOutputFormatClass

public void setOutputFormatClass(java.lang.Class<? extends org.apache.hadoop.mapreduce.OutputFormat> cls)
Set the OutputFormat class to use for this job.


setInputFormatClass

public void setInputFormatClass(java.lang.Class<? extends org.apache.hadoop.mapreduce.InputFormat> cls)
Set the InputFormat class to use for this job.


setMapperClass

public void setMapperClass(java.lang.Class<? extends org.apache.hadoop.mapreduce.Mapper> cls)
Set the Mapper class to use for this job.


setOptions

public void setOptions(SqoopOptions opts)
Set the SqoopOptions configuring this job.


loadJars

protected void loadJars(org.apache.hadoop.conf.Configuration conf,
                        java.lang.String ormJarFile,
                        java.lang.String tableClassName)
                 throws java.io.IOException
If jars must be loaded into the local environment, do so here.

Throws:
java.io.IOException

unloadJars

protected void unloadJars()
If any classloader was invoked by loadJars, free it here.


configureInputFormat

protected void configureInputFormat(org.apache.hadoop.mapreduce.Job job,
                                    java.lang.String tableName,
                                    java.lang.String tableClassName,
                                    java.lang.String splitByCol)
                             throws java.lang.ClassNotFoundException,
                                    java.io.IOException
Configure the inputformat to use for the job.

Throws:
java.lang.ClassNotFoundException
java.io.IOException

configureOutputFormat

protected void configureOutputFormat(org.apache.hadoop.mapreduce.Job job,
                                     java.lang.String tableName,
                                     java.lang.String tableClassName)
                              throws java.lang.ClassNotFoundException,
                                     java.io.IOException
Configure the output format to use for the job.

Throws:
java.lang.ClassNotFoundException
java.io.IOException

configureMapper

protected void configureMapper(org.apache.hadoop.mapreduce.Job job,
                               java.lang.String tableName,
                               java.lang.String tableClassName)
                        throws java.lang.ClassNotFoundException,
                               java.io.IOException
Set the mapper class implementation to use in the job, as well as any related configuration (e.g., map output types).

Throws:
java.lang.ClassNotFoundException
java.io.IOException

configureNumTasks

protected int configureNumTasks(org.apache.hadoop.mapreduce.Job job)
                         throws java.io.IOException
Configure the number of map/reduce tasks to use in the job.

Throws:
java.io.IOException

runJob

protected boolean runJob(org.apache.hadoop.mapreduce.Job job)
                  throws java.lang.ClassNotFoundException,
                         java.io.IOException,
                         java.lang.InterruptedException
Actually run the MapReduce job.

Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.lang.InterruptedException


Copyright © 2010 Cloudera, Inc.