edu.stolaf.cs.wmrserver
Class TransformProcessor

java.lang.Object
  extended by edu.stolaf.cs.wmrserver.TransformProcessor

public class TransformProcessor
extends java.lang.Object

Provides methods to prepare and package transform (map or reduce) executables from users' code. Applies library code, compiles, and generates scripts as necessary for the desired language.


Constructor Summary
TransformProcessor(org.apache.commons.configuration.HierarchicalConfiguration wmrConfig, java.io.File languageConfDir, java.io.File tempDir, java.lang.String jobName)
          Constructs a new TransformProcessor that will reference the given language configuration and use the given temp directory.
 
Method Summary
 java.io.File getPackageDir()
           
 java.io.File prepareMapperPackage(java.lang.String mapperSource, java.lang.String language)
          Prepares and writes a mapper script to the local filesystem, returning its path.
 java.io.File prepareReducerPackage(java.lang.String reducerSource, java.lang.String language)
          Prepares and writes a reducer script to the local filesystem, returning its path.
protected  java.io.File prepareTransformPackage(edu.stolaf.cs.wmrserver.TransformType transformType, java.lang.String transformSource, java.lang.String language)
          Internal implementation of #prepareMapperPackage() and #prepareReducerPackage() that works for either, determined by the transformType argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformProcessor

public TransformProcessor(org.apache.commons.configuration.HierarchicalConfiguration wmrConfig,
                          java.io.File languageConfDir,
                          java.io.File tempDir,
                          java.lang.String jobName)
Constructs a new TransformProcessor that will reference the given language configuration and use the given temp directory.

Parameters:
wmrConfig - The language configuration for WebMapReduce
langConfDir - The directory containing language support files
tempDir - The directory in which to store processed files
jobName - The name of the job, used in the script's filename
Method Detail

prepareMapperPackage

public java.io.File prepareMapperPackage(java.lang.String mapperSource,
                                         java.lang.String language)
                                  throws java.io.IOException,
                                         ValidationException,
                                         CompilationException
Prepares and writes a mapper script to the local filesystem, returning its path. Adds a shebang (#!) and wrapper code appropriate for the script language to the provided reducer source to produce the script.

Parameters:
mapperSource - The mapper code provided by the user
language - The language of the mapper, one specified in the WebMapReduce language configuration
Returns:
The path to the script
Throws:
java.io.IOException
ValidationException
CompilationException

prepareReducerPackage

public java.io.File prepareReducerPackage(java.lang.String reducerSource,
                                          java.lang.String language)
                                   throws java.io.IOException,
                                          ValidationException,
                                          CompilationException
Prepares and writes a reducer script to the local filesystem, returning its path. Adds a shebang (#!) and wrapper code appropriate for the script language to the provided reducer source to produce the script.

Parameters:
reducerSource - The reducer code provided by the user
language - The language of the reducer, one specified in the WebMapReduce language configuration
Returns:
The path to the script
Throws:
java.io.IOException
ValidationException
CompilationException

getPackageDir

public java.io.File getPackageDir()
                           throws java.io.IOException
Throws:
java.io.IOException

prepareTransformPackage

protected java.io.File prepareTransformPackage(edu.stolaf.cs.wmrserver.TransformType transformType,
                                               java.lang.String transformSource,
                                               java.lang.String language)
                                        throws java.io.IOException,
                                               ValidationException,
                                               CompilationException
Internal implementation of #prepareMapperPackage() and #prepareReducerPackage() that works for either, determined by the transformType argument.

Throws:
java.io.IOException
ValidationException
CompilationException