Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

SubmitScriptHandler Class Reference

List of all members.

Detailed Description

Handle the batch job submission stuff.

Author:
J.Butterworth
Version:
Date
2006-06-09 16:11:34 +0100 (Fri, 09 Jun 2006)
Revision
1182

Definition at line 26 of file SubmitScriptHandler.java.


Static Public Member Functions

int make (JobRequest request)
void setBatchFacility (String batchFacility)
String getTemplate ()
String getExecutable (Generator generator)

Static Public Attributes

final int OK = 0
final int INVALIDJOB = 2
final int CANTWRITESCRIPT = 3
final int CANTCHMOD = 4
final int CANTOPENPERMITSCRIPT = 5
final int NODEFINEDFACILITY = 6
final int UCLNQS = 1
final int MCRPBS = 2
final int GRID = 3
final int UCLPBS = 4
final int SHEFPBS = 5
int BATCHFACILITY = MCRPBS
Vector< Integer > batchNumbers = new Vector<Integer>()
Vector< String > batchNames = new Vector<String>()

Static Package Functions

 [static initializer]

Static Private Member Functions

int makeUCLNQS (JobRequest request)
int makeMCRPBS (JobRequest request)
int makeSHEFPBS (JobRequest request)
int makeGridPP (JobRequest request)
int setPermissions (JobRequest request)
void setScriptTemplates ()

Static Private Attributes

Hashtable< String, String > scriptTemplates = null
Hashtable< String, String > executableNames = null

Member Function Documentation

[static initializer]  )  [static, package]
 

String getExecutable Generator  generator  )  [static]
 

Returns executable filename for a specified generator and version.

Parameters:
generator 
version 
Returns:
the executable filename

Definition at line 310 of file SubmitScriptHandler.java.

00310                                                            {
00311 
00312     String exec = "jetweb-"+generator.getName()+generator.getVersion(); 
00313     System.out.println("SubmitScriptHandler: executable is "+exec);
00314     return exec;
00315 
00316     }

String getTemplate  )  [static]
 

Returns template filename for the currently set batch facility.

Returns:
the template filename

Definition at line 285 of file SubmitScriptHandler.java.

00285                                       {
00286     if (scriptTemplates==null) setScriptTemplates(); // On first call, fill Hashtable of script files.
00287     String template = "";
00288     String key = Integer.toString(SubmitScriptHandler.BATCHFACILITY);
00289     //System.out.println("attempt to get template " + key);
00290     try {
00291         template = (String)scriptTemplates.get(key);
00292         System.out.println(template);
00293         if (template.equals("null")){
00294         System.out.println("ScriptHandlerError: no template for "+key);
00295         return null;
00296         }
00297     } catch (Exception e){
00298         System.out.println("ScriptHandlerError: no template for "+key);
00299     }
00300     return template;
00301     }

int make JobRequest  request  )  [static]
 

Build the control script for the batch facility determined by BATCHFACILITY.

Parameters:
request representing the job request to be submitted.
Returns:
0 is Ok, 1 invalid jobrequest, 2 user does not have privilege >=3 means some other problem.

Definition at line 77 of file SubmitScriptHandler.java.

00077                                               {
00078 
00079     if (BATCHFACILITY==UCLNQS){ 
00080         System.out.println("Making a UCL NQS request");
00081         return makeUCLNQS(request);
00082     } else if (BATCHFACILITY==MCRPBS){ 
00083         System.out.println("Making a Manchester request");
00084         return makeMCRPBS(request);
00085     } else if (BATCHFACILITY==GRID){ 
00086         System.out.println("Making a GridPP request");
00087         return makeGridPP(request);
00088     } else if (BATCHFACILITY==UCLPBS){ 
00089         System.out.println("Making a UCL PBS request");
00090         return makeUCLNQS(request);   // OK since spool script is same for NQS/PBS
00091     } else if (BATCHFACILITY==SHEFPBS){ 
00092         System.out.println("Making a Sheffield PBS request");
00093         return makeSHEFPBS(request);
00094     } else {
00095         System.out.println("Error: "+NODEFINEDFACILITY);
00096         return NODEFINEDFACILITY;
00097     }
00098     }

int makeGridPP JobRequest  request  )  [static, private]
 

Definition at line 198 of file SubmitScriptHandler.java.

References JobRequest.getJobName(), and JobRequest.getSubmitScript().

00198                                                      {
00199 
00200     String line;
00201     try {
00202 
00203         System.out.println("submit script = "+request.getSubmitScript());
00204 
00205         BufferedWriter spoolscript = new BufferedWriter(new FileWriter(request.getSubmitScript()));
00206         
00207 
00208         System.out.println("spoolscript = "+spoolscript);
00209 
00210         line = "#!/bin/csh";
00211         spoolscript.write(line); spoolscript.newLine();
00212 
00213         line = "cd ${JETWEB_HOME}/run"+System.getProperty("runsubdir");
00214         spoolscript.write(line); spoolscript.newLine();
00215 
00216         line = "./"+request.getJobName();
00217         spoolscript.write(line); spoolscript.newLine();
00218 
00219         spoolscript.close();
00220 
00221     } catch ( IOException e ) {
00222         System.out.println("problem creating submit script:"+e);
00223         return CANTWRITESCRIPT;
00224     }
00225 
00226     // Now change the permissions.
00227     return setPermissions(request);
00228     }

int makeMCRPBS JobRequest  request  )  [static, private]
 

Definition at line 128 of file SubmitScriptHandler.java.

References JobRequest.getJobName(), and JobRequest.getSubmitScript().

00128                                                      {
00129 
00130     String line;
00131     try {
00132         BufferedWriter spoolscript = new BufferedWriter(new FileWriter(request.getSubmitScript()));
00133         
00134         line = "#!/bin/csh";
00135         spoolscript.write(line); spoolscript.newLine();
00136         
00137         line = "cd ${JETWEB_HOME}/run"+System.getProperty("runsubdir");
00138         spoolscript.write(line); spoolscript.newLine();
00139 
00140         line = "scp "+request.getJobName()
00141         +" mcuser@dfa.hep.man.ac.uk:/home2/mcuser/JetWeb/run";
00142         spoolscript.write(line); spoolscript.newLine();
00143 
00144         line = "scp "+request.getJobName()
00145         +".input mcuser@dfa.hep.man.ac.uk:/home2/mcuser/JetWeb/run";
00146         spoolscript.write(line); spoolscript.newLine();
00147         
00148         line = "ssh mcuser@dfa.hep.man.ac.uk \" cd /home2/mcuser/JetWeb/run ; qsub -q long \""
00149         +request.getJobName();      
00150         spoolscript.write(line); spoolscript.newLine();
00151         
00152         spoolscript.close();
00153         
00154     } catch ( IOException e ) {
00155         System.out.println("problem creating submit script:"+e);
00156         return CANTWRITESCRIPT;
00157     }
00158     
00159     // Now change the permissions.
00160     return setPermissions(request);
00161     }

int makeSHEFPBS JobRequest  request  )  [static, private]
 

Definition at line 163 of file SubmitScriptHandler.java.

References JobRequest.getJobName(), and JobRequest.getSubmitScript().

00163                                                       {
00164 
00165     String line;
00166     try {
00167         BufferedWriter spoolscript = new BufferedWriter(new FileWriter(request.getSubmitScript()));
00168         
00169         line = "#!/bin/csh";
00170         spoolscript.write(line); spoolscript.newLine();
00171         
00172         line = "cd ${JETWEB_HOME}/run"+System.getProperty("runsubdir");
00173         spoolscript.write(line); spoolscript.newLine();
00174 
00175         line = "scp "+request.getJobName()
00176         +" jetweb@hepgrid.shef.ac.uk:/home/jetweb/run";
00177         spoolscript.write(line); spoolscript.newLine();
00178 
00179         line = "scp "+request.getJobName()
00180         +".input jetweb@hepgrid.shef.ac.uk:/home/jetweb/run";
00181         spoolscript.write(line); spoolscript.newLine();
00182         
00183         line = "ssh jetweb@hepgrid.shef.ac.uk \" cd /home/jetweb/run ; qsub -q himem \""
00184         +request.getJobName();
00185         spoolscript.write(line); spoolscript.newLine();
00186         
00187         spoolscript.close();
00188         
00189     } catch ( IOException e ) {
00190         System.out.println("problem creating submit script:"+e);
00191         return CANTWRITESCRIPT;
00192     }
00193     
00194     // Now change the permissions.
00195     return setPermissions(request);
00196     }

int makeUCLNQS JobRequest  request  )  [static, private]
 

Definition at line 101 of file SubmitScriptHandler.java.

References JobRequest.getJobName(), and JobRequest.getSubmitScript().

00101                                                      {
00102 
00103     String line;
00104     try {
00105         BufferedWriter spoolscript = new BufferedWriter(new FileWriter(request.getSubmitScript()));
00106         
00107         line = "#!/bin/csh";
00108         spoolscript.write(line); spoolscript.newLine();
00109         
00110         line = "cd ${JETWEB_HOME}/run"+System.getProperty("runsubdir");
00111         spoolscript.write(line); spoolscript.newLine();
00112         
00113         line = "qsub -q bulk "+request.getJobName();
00114         spoolscript.write(line); spoolscript.newLine();
00115         
00116         spoolscript.close();
00117         
00118     } catch ( IOException e ) {
00119         System.out.println("problem creating submit script:"+e);
00120         return CANTWRITESCRIPT;
00121     }
00122     
00123     // Now change the permissions.
00124     return setPermissions(request);
00125     }

void setBatchFacility String  batchFacility  )  [static]
 

Set batch facility for job submission.

Parameters:
batchFacility The batch facility to which jobs will be submitted. Allowed values are "ucl_nqs", "manchester_pbs", "grid", "ucl_pbs", "sheffield_pbs".

Definition at line 265 of file SubmitScriptHandler.java.

00265                                                               {
00266     if (batchFacility.equalsIgnoreCase("ucl_nqs")){
00267         BATCHFACILITY = UCLNQS;}
00268     else if (batchFacility.equalsIgnoreCase("manchester_pbs")){
00269         BATCHFACILITY = MCRPBS;}
00270     else if (batchFacility.equalsIgnoreCase("grid")){
00271         BATCHFACILITY = GRID;}
00272     else if (batchFacility.equalsIgnoreCase("ucl_pbs")){
00273         BATCHFACILITY = UCLPBS;}
00274     else if (batchFacility.equalsIgnoreCase("sheffield_pbs")){
00275         BATCHFACILITY = SHEFPBS;
00276     }
00277     }

int setPermissions JobRequest  request  )  [static, private]
 

Change permissions to make spool script executable. Currently disabled. Should be reimplemented (somehow?) without using a shell script, or this task should handed off from the server to the program that submits jobs from the spool.

Definition at line 237 of file SubmitScriptHandler.java.

00237                                                           {
00238     /*
00239     try{
00240         Process chmod = Runtime.getRuntime().exec( JetWebConfig.getScriptDirName()
00241                                +"/permit "
00242                                +request.getSubmitScript().getPath());
00243         try {
00244         chmod.waitFor();
00245         } catch (InterruptedException e1) {
00246         System.out.println("oof "+e1);  
00247         return CANTCHMOD;
00248         }
00249     } catch (IOException e2) {
00250         System.out.println("Problem submitting job."+e2);   
00251         return CANTOPENPERMITSCRIPT;
00252     }
00253     */
00254     return OK;
00255     }

void setScriptTemplates  )  [static, private]
 

populates an array of template names should only be run once, on first call to getTemplate().

Definition at line 324 of file SubmitScriptHandler.java.

00324                                             {
00325     scriptTemplates = new Hashtable<String,String>();
00326 
00327     scriptTemplates.put(Integer.toString(SubmitScriptHandler.UCLNQS),
00328                JetWebConfig.templateDirName+"/uclnqs.script"); 
00329     scriptTemplates.put(Integer.toString(SubmitScriptHandler.MCRPBS),
00330                JetWebConfig.templateDirName+"/mcrpbs.script"); 
00331     scriptTemplates.put(Integer.toString(SubmitScriptHandler.GRID),
00332                JetWebConfig.templateDirName+"/gridpp.script"); 
00333     scriptTemplates.put(Integer.toString(SubmitScriptHandler.UCLPBS),
00334                JetWebConfig.templateDirName+"/uclpbs.script"); 
00335     scriptTemplates.put(Integer.toString(SubmitScriptHandler.SHEFPBS),
00336                JetWebConfig.templateDirName+"/shefpbs.script"); 
00337     }


Member Data Documentation

int BATCHFACILITY = MCRPBS [static]
 

Constant determining which batch facility is being used.

To be set in JetWebConfig init method.

Definition at line 54 of file SubmitScriptHandler.java.

Vector<String> batchNames = new Vector<String>() [static]
 

Definition at line 58 of file SubmitScriptHandler.java.

Vector<Integer> batchNumbers = new Vector<Integer>() [static]
 

Definition at line 57 of file SubmitScriptHandler.java.

final int CANTCHMOD = 4 [static]
 

Definition at line 39 of file SubmitScriptHandler.java.

final int CANTOPENPERMITSCRIPT = 5 [static]
 

Definition at line 40 of file SubmitScriptHandler.java.

final int CANTWRITESCRIPT = 3 [static]
 

Definition at line 38 of file SubmitScriptHandler.java.

Hashtable<String,String> executableNames = null [static, private]
 

Names of executables

Definition at line 32 of file SubmitScriptHandler.java.

final int GRID = 3 [static]
 

Definition at line 45 of file SubmitScriptHandler.java.

final int INVALIDJOB = 2 [static]
 

Definition at line 37 of file SubmitScriptHandler.java.

final int MCRPBS = 2 [static]
 

Definition at line 44 of file SubmitScriptHandler.java.

final int NODEFINEDFACILITY = 6 [static]
 

Definition at line 41 of file SubmitScriptHandler.java.

final int OK = 0 [static]
 

Definition at line 36 of file SubmitScriptHandler.java.

Hashtable<String,String> scriptTemplates = null [static, private]
 

Templates for run scripts

Definition at line 29 of file SubmitScriptHandler.java.

final int SHEFPBS = 5 [static]
 

Definition at line 47 of file SubmitScriptHandler.java.

final int UCLNQS = 1 [static]
 

Definition at line 43 of file SubmitScriptHandler.java.

final int UCLPBS = 4 [static]
 

Definition at line 46 of file SubmitScriptHandler.java.


The documentation for this class was generated from the following file:

Generated Wed Jan 17 09:14:27 GMT 2007