*
* @param appInput AppInput instance storing the jobSubmission data
*/
void __submitJob(AppInput appInput) {
// GridEngine' MultiInfrastructure job submission object
MultiInfrastructureJobSubmission miJobSubmission=null;
//
// Initialize the GridEngine Multi Infrastructure Job Submission object
//
// GridEngine uses two different kind of constructors. The constructor
// taking void type as argument is used for production environments, while
// the constructor taking SciGwyUserTrackingDB parameters is normally used
// for development purposes. In order to switch-on the production constructor
// just set to empty strings the following portlet init parameters:
// sciGwyUserTrackingDB_Hostname
// sciGwyUserTrackingDB_Username
// sciGwyUserTrackingDB_Password
// sciGwyUserTrackingDB_Database
//
if(null != appPreferences.getSciGwyUserTrackingDB_Hostname()
&& !appPreferences.getSciGwyUserTrackingDB_Hostname().equals("")
&& null != appPreferences.getSciGwyUserTrackingDB_Username()
&& !appPreferences.getSciGwyUserTrackingDB_Username().equals("")
&& null != appPreferences.getSciGwyUserTrackingDB_Password()
&& !appPreferences.getSciGwyUserTrackingDB_Password().equals("")
&& null != appPreferences.getSciGwyUserTrackingDB_Database()
&& !appPreferences.getSciGwyUserTrackingDB_Database().equals("")
) {
String arg1="jdbc:mysql://" + appPreferences.getSciGwyUserTrackingDB_Hostname() +
"/" + appPreferences.getSciGwyUserTrackingDB_Database();
String arg2=appPreferences.getSciGwyUserTrackingDB_Username();
String arg3=appPreferences.getSciGwyUserTrackingDB_Password();
miJobSubmission = new MultiInfrastructureJobSubmission(arg1,arg2,arg3);
_log.info("MultiInfrastructureJobSubmission [DEVEL]\n"
+LS+" Arg1: '" + arg1 + "'"
+LS+" Arg2: '" + arg2 + "'"
+LS+" Arg3: '" + arg3 + "'"
);
}
else {
miJobSubmission = new MultiInfrastructureJobSubmission();
_log.info("MultiInfrastructureJobSubmission [PROD]");
}
// Assigns all enabled infrastructures
InfrastructureInfo[] infrastructuresInfo=appPreferences.getEnabledInfrastructures();
for(int i=0; i<infrastructuresInfo.length; i++) {
_log.info("Adding infrastructure #"+(i+1)
+" - Name: '"+infrastructuresInfo[i].getName()+"'"+LS);
miJobSubmission.addInfrastructure(infrastructuresInfo[i]);
}
// Check the enabled infrastructures
if(infrastructuresInfo.length > 0) {
// Application Id
int applicationId=Integer.parseInt(appPreferences.getGridOperationId());
// Grid Engine' UserTraking needs the portal IP address
String portalIPAddress="";
try {
InetAddress addr = InetAddress.getLocalHost();
byte[] ipAddr=addr.getAddress();
portalIPAddress= ""+(short)(ipAddr[0]&0xff)
+":"+(short)(ipAddr[1]&0xff)
+":"+(short)(ipAddr[2]&0xff)
+":"+(short)(ipAddr[3]&0xff);
}
catch(Exception e) {
_log.error("Unable to get the portal IP address");
}
// Job details
String executable="/bin/sh"; // Application executable
String arguments =appPreferences.getPilotScript(); // executable' arguments
String outputPath="/tmp/"; // Output Path
String outputFile="mi-admixture-Output.txt"; // Distributed application standard output
String errorFile ="mi-admixture-Error.txt"; // Distrubuted application standard error
String appFile ="mi-admixture-Files.tar.gz"; // Hostname output files (created by the pilot script)
// InputSandbox (string with comma separated list of file names)
String inputSandbox=appServerPath+"WEB-INF/job/" //
+appPreferences.getPilotScript() // pilot script
+","+appInput.inputSandbox_inputFile // input file
;
// OutputSandbox (string with comma separated list of file names)
String outputSandbox=appFile; // Output file
// Take care of job requirements
// More requirements can be specified in the preference value 'jobRequirements'
// separating each requirement by the ';' character
String jdlRequirements[] = appPreferences.getJobRequirements().split(";");
int numRequirements=0;
for(int i=0; i<jdlRequirements.length; i++) {
if(!jdlRequirements[i].equals("")) {
jdlRequirements[numRequirements] = "JDLRequirements=("+jdlRequirements[i]+")";
numRequirements++;
_log.info("Requirement["+i+"]='"+jdlRequirements[i]+"'");
}
} // for each jobRequirement
// Other job initialization settings
miJobSubmission.setExecutable ( executable); // Specify the executeable
miJobSubmission.setArguments ( arguments); // Specify the application' arguments
miJobSubmission.setOutputPath ( outputPath); // Specify the output directory
miJobSubmission.setOutputFiles(outputSandbox); // Setup output files (OutputSandbox)
miJobSubmission.setJobOutput ( outputFile); // Specify the std-outputr file
miJobSubmission.setJobError ( errorFile); // Specify the std-error file
if( null != inputSandbox // Setup input files (InputSandbox) avoiding empty inputSandboxes
&& inputSandbox.length() > 0)
miJobSubmission.setInputFiles(inputSandbox);
if(numRequirements>0) // Setup the JDL requirements
miJobSubmission.setJDLRequirements(jdlRequirements);
// Submit Job
miJobSubmission.submitJobAsync(appInput.username, portalIPAddress, applicationId, appInput.jobIdentifier);
// Show log
// View jobSubmission details in the log
_log.info(
LS+"JobSent"