Index: modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/common/AbstractQueuePoller.java =================================================================== --- modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/common/AbstractQueuePoller.java (revision 3329) +++ modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/common/AbstractQueuePoller.java (working copy) @@ -18,6 +18,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Map; +import java.util.StringTokenizer; import org.apache.log4j.Logger; @@ -51,7 +52,7 @@ public void start() { if (logger.isDebugEnabled()) { - logger.debug("Starring " + name + " poll thread."); + logger.debug("Starting " + name + " poll thread."); } Thread t = new Thread(this); t.setName(name); @@ -239,4 +240,28 @@ } return null; } + + protected int getTokenIndex(String s, String token) { + int currentToken = -1; + StringTokenizer st = new StringTokenizer(s); + while(st.hasMoreTokens()) { + currentToken++; + if(st.nextToken().equals(token)) + return currentToken; + } + return -1; + } + + protected String getToken(String s, int tokenIndex) { + int currentToken = -1; + String token = ""; + StringTokenizer st = new StringTokenizer(s); + while(currentToken != tokenIndex) { + if(st.hasMoreTokens()) { + token = st.nextToken(); + currentToken++; + } + } + return token; + } } Index: modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/sge/QueuePoller.java =================================================================== --- modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/sge/QueuePoller.java (revision 3329) +++ modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/sge/QueuePoller.java (working copy) @@ -51,16 +51,17 @@ String header = br.readLine(); // sge qstat outputs nothing when there are no jobs if (header != null) { - int jobIDIndex = header.indexOf("job-ID"); - int stateIndex = header.indexOf("state"); + int jobIDIndex = getTokenIndex(header,"job-ID"); + int stateIndex = getTokenIndex(header,"state"); // skip the ----- br.readLine(); processed.clear(); do { line = br.readLine(); if (line != null) { - String jobid = parseToWhitespace(line, jobIDIndex); - String state = parseToWhitespace(line, stateIndex); + String jobid = getToken(line, jobIDIndex); + String state = getToken(line, stateIndex); + if (jobid == null || jobid.equals("") || state == null || state.equals("")) { throw new IOException("Failed to parse qstat line: " Index: modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/sge/SGEExecutor.java =================================================================== --- modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/sge/SGEExecutor.java (revision 3329) +++ modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/sge/SGEExecutor.java (working copy) @@ -205,7 +205,7 @@ } line = br.readLine(); } - throw new IOException("None of the qsub lines matches the required patten: " + JOB_ID_LINE); + throw new IOException("None of the qsub lines matches the required pattern: " + JOB_ID_LINE); } private static final String[] QSUB_PARAMS = new String[] {};