this.hadoopConfigDir = hadoopConfigDir;
}
}
public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException {
HadoopApplicationDeploymentDescriptionType hadoopAppDesc =
(HadoopApplicationDeploymentDescriptionType)jobExecutionContext
.getApplicationContext().getApplicationDeploymentDescription().getType();
MessageContext inMessageContext = jobExecutionContext.getInMessageContext();
HadoopApplicationDeploymentDescriptionType.HadoopJobConfiguration jobConf = hadoopAppDesc.getHadoopJobConfiguration();
try{
// Preparing Hadoop configuration
Configuration hadoopConf = HadoopUtils.createHadoopConfiguration(
jobExecutionContext, isWhirrBasedDeployment, hadoopConfigDir);
// Load jar containing map-reduce job implementation
ArrayList<URL> mapRedJars = new ArrayList<URL>();
mapRedJars.add(new File(jobConf.getJarLocation()).toURL());
URLClassLoader childClassLoader = new URLClassLoader(mapRedJars.toArray(new URL[mapRedJars.size()]),
this.getClass().getClassLoader());
Job job = new Job(hadoopConf);
job.setJobName(jobConf.getJobName());
job.setOutputKeyClass(Class.forName(jobConf.getOutputKeyClass(), true, childClassLoader));
job.setOutputValueClass(Class.forName(jobConf.getOutputValueClass(), true, childClassLoader));
job.setMapperClass((Class<? extends Mapper>)Class.forName(jobConf.getMapperClass(), true, childClassLoader));
job.setCombinerClass((Class<? extends Reducer>) Class.forName(jobConf.getCombinerClass(), true, childClassLoader));
job.setReducerClass((Class<? extends Reducer>) Class.forName(jobConf.getCombinerClass(), true, childClassLoader));
job.setInputFormatClass((Class<? extends InputFormat>)Class.forName(jobConf.getInputFormatClass(), true, childClassLoader));
job.setOutputFormatClass((Class<? extends OutputFormat>) Class.forName(jobConf.getOutputFormatClass(), true, childClassLoader));
FileInputFormat.setInputPaths(job, new Path(hadoopAppDesc.getInputDataDirectory()));
FileOutputFormat.setOutputPath(job, new Path(hadoopAppDesc.getOutputDataDirectory()));
job.waitForCompletion(true);
System.out.println(job.getTrackingURL());
if(jobExecutionContext.getOutMessageContext() == null){
jobExecutionContext.setOutMessageContext(new MessageContext());