edu.umd.cloud9.util
Class HadoopTask

java.lang.Object
  extended by edu.umd.cloud9.util.HadoopTask
All Implemented Interfaces:
Configurable
Direct Known Subclasses:
ComputeCooccurrenceMatrixPairs, ComputeCooccurrenceMatrixStripes

public abstract class HadoopTask
extends Object
implements Configurable

An abstract class representing a generic Hadoop task. This class provides a way to package together one or more MapReduce job in a common parameter-passing interface. The standard way to invoke a HadoopTask is:

 Configuration config = new Configuration();
 config.set("param1", value1);
 config.set("param2", value2);
 ...            
 ConcreteHadoopTask task = new ConcreteHadoopTask(config);
 task.run();
 

To implement a concrete HadoopTask, extend this class and implement runTask() and getRequiredParameters():

 public static final String[] RequiredParameters = { "a", "b", "c" };
 
 public String[] getRequiredParameters() {
        return RequiredParameters;
 }
 
 public void runTask() throws Exception {
        // set up and run the MapReduce job
 }
 

Code in the abstract HadoopTask class will handle checking to make sure all required parameters are present.


Constructor Summary
HadoopTask(Configuration conf)
          Creates a HadoopTask.
 
Method Summary
 Configuration getConf()
          Returns the Configuration object associated with this HadoopTask.
abstract  String[] getRequiredParameters()
          Returns the required parameters for this HadoopTask.
 void run()
          Runs this HadoopTask
abstract  void runTask()
          Called by run() after verifying that required parameters are present.
 void setConf(Configuration conf)
          Sets the Configuration object associated with this HadoopTask.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HadoopTask

public HadoopTask(Configuration conf)
Creates a HadoopTask.

Parameters:
conf -
Method Detail

getConf

public Configuration getConf()
Returns the Configuration object associated with this HadoopTask.

Specified by:
getConf in interface Configurable
Returns:
the Configuration object associated with this HadoopTask

setConf

public void setConf(Configuration conf)
Sets the Configuration object associated with this HadoopTask.

Specified by:
setConf in interface Configurable
Parameters:
conf - the Configuration object associated with this HadoopTask

run

public void run()
         throws Exception
Runs this HadoopTask

Throws:
Exception

runTask

public abstract void runTask()
                      throws Exception
Called by run() after verifying that required parameters are present. This is an abstract method that must be implemented by the concrete class.

Throws:
Exception

getRequiredParameters

public abstract String[] getRequiredParameters()
Returns the required parameters for this HadoopTask. This is an abstract method that must be implemented by the concrete class.

Returns:
array of Strings containing the required parameters for this HadoopTask