[GE users] Question regarding SGE submission methods (scheduling timeouts)

Sreenath Nampally sreenath at tigr.ORG
Thu Jun 22 18:18:45 BST 2006


Hello all,

I am trying to submit the attached script (Generated dynamically by a 
java class)
using DRMAA but for some reason the directives ( lines starting with 
#SGE_DIRECTIVES)
in the script are not honored even though the job runs on the grid.

If I submit the same script at the command line using
'qsub -b n -C "#SGE_DIRECTIVE" sge_job' , it works fine

Following is the java code that submits the job using DRMAA. Is 
'setNativeSpecification'
the right method to specify the directive string or is there another way 
of doing it?

Thanks for the help.
Sree

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 


//Create a Session factory object
SessionFactory factory = SessionFactory.getFactory();
Session session = factory.getSession();
String id = null;
try {
session.init(null);
String sgeSubmitFile = "sge_job.sh";
JobTemplate jobTemplate = session.createJobTemplate();

System.out.println("The DRMAA submission file name is " + 
sgeSubmitFile.getName());
jobTemplate.setRemoteCommand(sgeSubmitFile.getAbsolutePath());
jobTemplate.setNativeSpecification("-b n -C \"#SGE_DIRECTIVE\"");
// I tried the following ways also
//jobTemplate.setNativeSpecification("-b n -C #SGE_DIRECTIVE");
//jobTemplate.setNativeSpecification("-b n -C '#SGE_DIRECTIVE'");

System.out.println("Submitting job " + jobTemplate.toString());
id = session.runJob(jobTemplate);
System.out.println("Waiting for job " + id + " job finish");
JobInfo jobInfo = session.wait(id, 300);
System.out.println("Job " + id + " finished with exit value " + 
jobInfo.getExitStatus());
// Set job template to null
jobTemplate = null;
// Exit session
session.exit();
} catch (DrmaaException dre) {
// TODO: handle exception
dre.printStackTrace();
System.out.println(dre.getMessage());
throw dre;
}



    [ Part 2: "Attached Text" ]

#!/bin/bash
#
# generated SGE submit file for HTC command 1234
# submitted for user null
# There are four sections to this file
# 1. SGE Configuration settings
# 2. Environment settings
# 3. Running outside of SGE
# 4. Run Command
############
# Section 1: SGE Configuration
############

# SGE Interpret this script with the Bourne shell
#SGE_DIRECTIVE -S /usr/local/bin/bash

# NOTE: you need to 'cd' to the intial dir before submitting
#SGE_DIRECTIVE -cwd

# stdout goes to 
#SGE_DIRECTIVE -o /usr/local/scratch/sree/drmaa.stdout
# stderr goes to 
#SGE_DIRECTIVE -e /usr/local/scratch/sree/drmaa.stderr


# config variables
#SGE_DIRECTIVE -l fast
#SGE_DIRECTIVE -p 10
#SGE_DIRECTIVE -N sleeper.pl

############
# Section 2: Environment Setup Configuration
############
# copy current environment
#SGE_DIRECTIVE -V 

############
# Section 3: Uncomment to run outside of sge 
############
export CKPT_DIR=/home/sgetest/pre-prodn-htc/server/working/resched
cd /local/scratch/sree

############
# Section 4: Run Command
############
trap "sig 1" USR1
trap "sig 2" USR2
sig() {
  SIGNAL=$1
  MARATHON=false
  # Apparently, SGE notifies the script multiple times about the 
  # pending KILL signal, but only reschedule it on the 1st notification
  sigcounter=`echo $(($sigcounter + 1))`
  if [ "$sigcounter" -eq 1 ]; then
     # Call trap.sh, which alters the job and reschedules it
/home/sgetest/pre-prodn-htc/server/bin/trap.sh $JOB_ID $SIGNAL $CKPT_DIR ""
     trap_ret=$?
  fi
}
/usr/local/scratch/sree/sleeper.pl 
sge_ret_val=$?
sdate=$(date)
if [ -e "${CKPT_DIR}/${JOB_ID}.resched" ]; then
    rm -f ${CKPT_DIR}/${JOB_ID}.resched
fi
# end of submit file 



    [ Part 3: "Attached Text" ]

    [ The following text is in the "iso-8859-1" character set. ]
    [ Your display is set for the "ISO-8859-10" character set.  ]
    [ Some special characters may be displayed incorrectly. ]

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at gridengine.sunsource.net
For additional commands, e-mail: users-help at gridengine.sunsource.net



More information about the gridengine-users mailing list