public boolean performFinish() {
/*
* Create a new location or get an existing one
*/
AbstractHadoopCluster location = null;
if (mainPage.createNew.getSelection()) {
location = createNewPage.performFinish();
} else if (mainPage.table.getSelection().length == 1) {
location = (AbstractHadoopCluster) mainPage.table.getSelection()[0].getData();
}
if (location == null)
return false;
/*
* Get the base directory of the plug-in for storing configurations and
* JARs
*/
File baseDir = Activator.getDefault().getStateLocation().toFile();
// Package the Job into a JAR
File jarFile = JarModule.createJarPackage(resource);
if (jarFile == null) {
ErrorMessageDialog.display("Run on Hadoop", "Unable to create or locate the JAR file for the Job");
return false;
}
/*
* Generate a temporary Hadoop configuration directory and add it to the
* classpath of the launch configuration
*/
File confDir;
try {
confDir = File.createTempFile("hadoop-conf-", "", baseDir);
confDir.delete();
confDir.mkdirs();
if (!confDir.isDirectory()) {
ErrorMessageDialog.display("Run on Hadoop", "Cannot create temporary directory: " + confDir);
return false;
}
} catch (IOException ioe) {
ioe.printStackTrace();
return false;
}
try {
location.saveConfiguration(confDir, jarFile.getAbsolutePath());
} catch (IOException ioe) {
ioe.printStackTrace();
return false;
}
// Setup the Launch class path