airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject svn commit: r1407723 [2/2] - in /airavata/sandbox/grid-tools/gram-client: ./ src/main/java/org/apache/airavata/jobsubmission/ src/main/java/org/apache/airavata/jobsubmission/context/ src/main/java/org/apache/airavata/jobsubmission/gram/ src/main/java/o...
Date Sat, 10 Nov 2012 03:25:45 GMT
Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmission.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmission.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmission.java
(original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmission.java
Sat Nov 10 03:25:44 2012
@@ -1,3 +1,24 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
 package org.apache.airavata.jobsubmission.gram;
 
 import org.apache.log4j.Logger;
@@ -9,133 +30,133 @@ import org.ietf.jgss.GSSException;
 
 public class GramJobSubmission {
 
-	private static final String MULTIPLE = "multiple";
+    private static final String MULTIPLE = "multiple";
 
-	private static final String MPI = "mpi";
+    private static final String MPI = "mpi";
 
-	private static final String SINGLE = "single";
+    private static final String SINGLE = "single";
 
-	private static final String CONDOR = "CONDOR";	
+    private static final String CONDOR = "CONDOR";
 
-	private static final Logger log = Logger.getLogger(GramJobSubmission.class);
-
-	public void executeJob(GSSCredential gssCred, ExectionContext appExecContext, StringBuffer
buffer) throws Exception {
-
-		try{
-			log.setLevel(org.apache.log4j.Level.INFO);
-			String contact = appExecContext.getHost();
-			GramAttributes jobAttr = configureRemoteJob(appExecContext);
-			String rsl = jobAttr.toRSL();
-			GramJob job = new GramJob(rsl);
-			
-			log.info("RSL = " + rsl);
-			JobSubmissionListener listener = new JobSubmissionListener(job, buffer);
-			job.setCredentials(gssCred);
-			job.addListener(listener);
-			log.info("Request to contact:" + contact);			
-			job.request(contact);
-
-			log.info("JobID = " + job.getIDAsString());
-			
-			listener.waitFor();
-			job.removeListener(listener);
-		}catch(GramException ge){
-			ge.printStackTrace();
-			log.error(ge, ge.getCause());
-			buffer.append(System.currentTimeMillis()+ "#id#FAILED#" + ge.getMessage());
-		}catch(GSSException gss){
-			gss.printStackTrace();
-			log.error(gss, gss.getCause());
-			buffer.append(System.currentTimeMillis()+ "#id#FAILED#" + gss.getMessage());
-		}catch(Exception e){
-			e.printStackTrace();
-			log.error(e, e.getCause());
-			buffer.append(System.currentTimeMillis()+ "#id#FAILED#" + e.getMessage());
-		}		
-	}
-
-	protected GramAttributes configureRemoteJob(ExectionContext appExecContext) throws Exception
{
-		GramAttributes jobAttr = new GramAttributes();
-		jobAttr.setExecutable(appExecContext.getExecutable());
-		if (appExecContext.getWorkingDir() != null) {
-			jobAttr.setDirectory(appExecContext.getWorkingDir());
-			jobAttr.setStdout(appExecContext.getStdOut());
-			jobAttr.setStderr(appExecContext.getStderr());
-		}
-		// The env here contains the env of the host and the application. i.e
-		// ArrayList<String[]> nv = appExecContext.getEnv();
-		//
-		// for (int i = 0; i < nv.size(); ++i) {
-		// String[] nvPair = (String[]) nv.get(i);
-		// jobAttr.addEnvVariable(nvPair[0], nvPair[1]);
-		// }
-
-		// jobAttr.addEnvVariable(GFacConstants.INPUT_DATA_DIR,
-		// appExecContext.getInputDataDir());
-		// jobAttr.addEnvVariable(GFacConstants.OUTPUT_DATA_DIR,
-		// appExecContext.getOutputDataDir());
-
-		if (appExecContext.getMaxWallTime() != null && appExecContext.getMaxWallTime()
> 0) {
-			log.info("Setting max wall clock time to " + appExecContext.getMaxWallTime());
-			jobAttr.setMaxWallTime(appExecContext.getMaxWallTime());
-			jobAttr.set("proxy_timeout", "1");
-		}
-		if (appExecContext.getPcount() != null && appExecContext.getPcount() > 1) {
-			log.info("Setting number of procs to " + appExecContext.getPcount());
-			jobAttr.setNumProcs(appExecContext.getPcount());
-		}
-
-		if (appExecContext.getHostCount() != null && appExecContext.getHostCount() >
1) {
-			jobAttr.set("hostCount", String.valueOf(appExecContext.getHostCount()));
-		}
-
-		if (appExecContext.getProjectName() != null) {
-			log.info("Setting project to " + appExecContext.getProjectName());
-			jobAttr.setProject(appExecContext.getProjectName());
-		}
-
-		if (appExecContext.getQueue() != null) {
-			jobAttr.setQueue(appExecContext.getQueue());
-		}
-		if (appExecContext.getArguments() != null) {
-			jobAttr.set("arguments", appExecContext.getArguments());
-		}
-		String jobType = SINGLE;
-
-		if (appExecContext.getJobType() != null) {
-			jobType = appExecContext.getJobType();
-		}
-		if (jobType.equals(SINGLE)) {
-			log.info("Setting job type to single");
-			jobAttr.setJobType(GramAttributes.JOBTYPE_SINGLE);
-		} else if (jobType.equals(MPI)) {
-			log.info("Setting job type to mpi");
-			jobAttr.setJobType(GramAttributes.JOBTYPE_MPI);
-		} else if (jobType.equals(MULTIPLE)) {
-			log.info("Setting job type to multiple");
-			jobAttr.setJobType(GramAttributes.JOBTYPE_MULTIPLE);
-		} else if (jobType.equals(CONDOR)) {
-			log.info("Setting job type to condor");
-			jobAttr.setJobType(GramAttributes.JOBTYPE_CONDOR);
-		}
-
-		// Support to add the Additional RSL parameters
-		// RSLParmType[] rslParams = app.getRslparmArray();
-		// if (rslParams.length > 0) {
-		// for (RSLParmType rslType : rslParams) {
-		// log.info("Adding rsl param of [" + rslType.getName() + ","
-		// + rslType.getStringValue() + "]");
-		// if(rslType.getName()!= ""){
-		// jobAttr.set(rslType.getName(), rslType.getStringValue());
-		// }
-		// }
-		// }
-
-		// support urgency/SPRUCE case
-		// only add spruce rsl parameter if this host has a spruce jobmanager
-		// configured
-		// jobAttr.set("urgency", appExecContext.getLeadHeader().getUrgency());
+    private static final Logger log = Logger.getLogger(GramJobSubmission.class);
+
+    public void executeJob(GSSCredential gssCred, ExectionContext appExecContext, StringBuffer
buffer) throws Exception {
+
+        try {
+            log.setLevel(org.apache.log4j.Level.INFO);
+            String contact = appExecContext.getHost();
+            GramAttributes jobAttr = configureRemoteJob(appExecContext);
+            String rsl = jobAttr.toRSL();
+            GramJob job = new GramJob(rsl);
+
+            log.info("RSL = " + rsl);
+            JobSubmissionListener listener = new JobSubmissionListener(job, buffer);
+            job.setCredentials(gssCred);
+            job.addListener(listener);
+            log.info("Request to contact:" + contact);
+            job.request(contact);
+
+            log.info("JobID = " + job.getIDAsString());
+
+            listener.waitFor();
+            job.removeListener(listener);
+        } catch (GramException ge) {
+            ge.printStackTrace();
+            log.error(ge, ge.getCause());
+            buffer.append(System.currentTimeMillis() + "#id#FAILED#" + ge.getMessage());
+        } catch (GSSException gss) {
+            gss.printStackTrace();
+            log.error(gss, gss.getCause());
+            buffer.append(System.currentTimeMillis() + "#id#FAILED#" + gss.getMessage());
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e, e.getCause());
+            buffer.append(System.currentTimeMillis() + "#id#FAILED#" + e.getMessage());
+        }
+    }
+
+    protected GramAttributes configureRemoteJob(ExectionContext appExecContext) throws Exception
{
+        GramAttributes jobAttr = new GramAttributes();
+        jobAttr.setExecutable(appExecContext.getExecutable());
+        if (appExecContext.getWorkingDir() != null) {
+            jobAttr.setDirectory(appExecContext.getWorkingDir());
+            jobAttr.setStdout(appExecContext.getStdOut());
+            jobAttr.setStderr(appExecContext.getStderr());
+        }
+        // The env here contains the env of the host and the application. i.e
+        // ArrayList<String[]> nv = appExecContext.getEnv();
+        //
+        // for (int i = 0; i < nv.size(); ++i) {
+        // String[] nvPair = (String[]) nv.get(i);
+        // jobAttr.addEnvVariable(nvPair[0], nvPair[1]);
+        // }
+
+        // jobAttr.addEnvVariable(GFacConstants.INPUT_DATA_DIR,
+        // appExecContext.getInputDataDir());
+        // jobAttr.addEnvVariable(GFacConstants.OUTPUT_DATA_DIR,
+        // appExecContext.getOutputDataDir());
+
+        if (appExecContext.getMaxWallTime() != null && appExecContext.getMaxWallTime()
> 0) {
+            log.info("Setting max wall clock time to " + appExecContext.getMaxWallTime());
+            jobAttr.setMaxWallTime(appExecContext.getMaxWallTime());
+            jobAttr.set("proxy_timeout", "1");
+        }
+        if (appExecContext.getPcount() != null && appExecContext.getPcount() >
1) {
+            log.info("Setting number of procs to " + appExecContext.getPcount());
+            jobAttr.setNumProcs(appExecContext.getPcount());
+        }
+
+        if (appExecContext.getHostCount() != null && appExecContext.getHostCount()
> 1) {
+            jobAttr.set("hostCount", String.valueOf(appExecContext.getHostCount()));
+        }
+
+        if (appExecContext.getProjectName() != null) {
+            log.info("Setting project to " + appExecContext.getProjectName());
+            jobAttr.setProject(appExecContext.getProjectName());
+        }
+
+        if (appExecContext.getQueue() != null) {
+            jobAttr.setQueue(appExecContext.getQueue());
+        }
+        if (appExecContext.getArguments() != null) {
+            jobAttr.set("arguments", appExecContext.getArguments());
+        }
+        String jobType = SINGLE;
+
+        if (appExecContext.getJobType() != null) {
+            jobType = appExecContext.getJobType();
+        }
+        if (jobType.equals(SINGLE)) {
+            log.info("Setting job type to single");
+            jobAttr.setJobType(GramAttributes.JOBTYPE_SINGLE);
+        } else if (jobType.equals(MPI)) {
+            log.info("Setting job type to mpi");
+            jobAttr.setJobType(GramAttributes.JOBTYPE_MPI);
+        } else if (jobType.equals(MULTIPLE)) {
+            log.info("Setting job type to multiple");
+            jobAttr.setJobType(GramAttributes.JOBTYPE_MULTIPLE);
+        } else if (jobType.equals(CONDOR)) {
+            log.info("Setting job type to condor");
+            jobAttr.setJobType(GramAttributes.JOBTYPE_CONDOR);
+        }
+
+        // Support to add the Additional RSL parameters
+        // RSLParmType[] rslParams = app.getRslparmArray();
+        // if (rslParams.length > 0) {
+        // for (RSLParmType rslType : rslParams) {
+        // log.info("Adding rsl param of [" + rslType.getName() + ","
+        // + rslType.getStringValue() + "]");
+        // if(rslType.getName()!= ""){
+        // jobAttr.set(rslType.getName(), rslType.getStringValue());
+        // }
+        // }
+        // }
+
+        // support urgency/SPRUCE case
+        // only add spruce rsl parameter if this host has a spruce jobmanager
+        // configured
+        // jobAttr.set("urgency", appExecContext.getLeadHeader().getUrgency());
 
-		return jobAttr;
-	}
+        return jobAttr;
+    }
 }

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmissionListener.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmissionListener.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmissionListener.java
(original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmissionListener.java
Sat Nov 10 03:25:44 2012
@@ -1,3 +1,24 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
 package org.apache.airavata.jobsubmission.gram;
 
 import org.apache.log4j.Logger;
@@ -6,86 +27,86 @@ import org.globus.gram.GramJobListener;
 
 public class JobSubmissionListener implements GramJobListener {
 
-	private static final String DELIMITER = "#";
-	private boolean finished;
-	private int error;
-	private int status;
-	private StringBuffer buffer;
-
-	private GramJob job;
-
-	private static final Logger log = Logger.getLogger(JobSubmissionListener.class);
-
-	public JobSubmissionListener(GramJob job, StringBuffer buffer) {
-		this.buffer = buffer;
-		this.job = job;
-	}
-
-	// waits for DONE or FAILED status
-	public void waitFor() throws InterruptedException {
-		while (!finished) {
-			
-			// job status is changed but method isn't invoked
-			if (status != 0) {
-				if (job.getStatus() != status) {
-					log.info("invoke method manually");
-					statusChanged(job);
-				} else {
-					log.info("job " + job.getIDAsString() + " have same status: " + GramJob.getStatusAsString(status));
-				}
-			} else {
-				log.info("Status is zero");
-			}
-			
-			synchronized (this) {
-				wait(60 * 1000l);
-			}			
-		}
-	}
-
-	public synchronized void statusChanged(GramJob job) {
-		log.debug("Listener: statusChanged triggered");
-		int jobStatus = job.getStatus();
-		String jobId = job.getIDAsString();
-		String statusString = job.getStatusAsString();
-		log.info("Job Status: " + statusString + "(" + jobStatus + ")");
-		buffer.append(formatJobStatus(jobId, statusString));
-		log.debug(formatJobStatus(jobId, statusString));
-
-		status = jobStatus;
-		if (jobStatus == GramJob.STATUS_DONE) {
-			finished = true;
-		} else if (jobStatus == GramJob.STATUS_FAILED) {
-			finished = true;
-			error = job.getError();
-			log.info("Job Error Code: " + error);
-			buffer.append(DELIMITER + error);
-		}
-		buffer.append("\n");
-
-		// notify wait thread to wake up if done		
-		if (finished) {
-			notify();
-		}
-	}
-
-	public static String formatJobStatus(String jobid, String jobstatus) {
-		return System.currentTimeMillis() + DELIMITER + jobid + DELIMITER + jobstatus;
-	}
-
-	public int getError() {
-		return error;
-	}
-
-	public int getStatus() {
-		return status;
-	}
-
-	public void wakeup() {
-		try {
-			notify();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
+    private static final String DELIMITER = "#";
+    private boolean finished;
+    private int error;
+    private int status;
+    private StringBuffer buffer;
+
+    private GramJob job;
+
+    private static final Logger log = Logger.getLogger(JobSubmissionListener.class);
+
+    public JobSubmissionListener(GramJob job, StringBuffer buffer) {
+        this.buffer = buffer;
+        this.job = job;
+    }
+
+    // waits for DONE or FAILED status
+    public void waitFor() throws InterruptedException {
+        while (!finished) {
+
+            // job status is changed but method isn't invoked
+            if (status != 0) {
+                if (job.getStatus() != status) {
+                    log.info("invoke method manually");
+                    statusChanged(job);
+                } else {
+                    log.info("job " + job.getIDAsString() + " have same status: " + GramJob.getStatusAsString(status));
+                }
+            } else {
+                log.info("Status is zero");
+            }
+
+            synchronized (this) {
+                wait(60 * 1000l);
+            }
+        }
+    }
+
+    public synchronized void statusChanged(GramJob job) {
+        log.debug("Listener: statusChanged triggered");
+        int jobStatus = job.getStatus();
+        String jobId = job.getIDAsString();
+        String statusString = job.getStatusAsString();
+        log.info("Job Status: " + statusString + "(" + jobStatus + ")");
+        buffer.append(formatJobStatus(jobId, statusString));
+        log.debug(formatJobStatus(jobId, statusString));
+
+        status = jobStatus;
+        if (jobStatus == GramJob.STATUS_DONE) {
+            finished = true;
+        } else if (jobStatus == GramJob.STATUS_FAILED) {
+            finished = true;
+            error = job.getError();
+            log.info("Job Error Code: " + error);
+            buffer.append(DELIMITER + error);
+        }
+        buffer.append("\n");
+
+        // notify wait thread to wake up if done
+        if (finished) {
+            notify();
+        }
+    }
+
+    public static String formatJobStatus(String jobid, String jobstatus) {
+        return System.currentTimeMillis() + DELIMITER + jobid + DELIMITER + jobstatus;
+    }
+
+    public int getError() {
+        return error;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void wakeup() {
+        try {
+            notify();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 }

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmittionListener.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmittionListener.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmittionListener.java
(original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmittionListener.java
Sat Nov 10 03:25:44 2012
@@ -1,3 +1,24 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
 package org.apache.airavata.jobsubmission.gram;
 
 import org.apache.log4j.Logger;
@@ -6,86 +27,86 @@ import org.globus.gram.GramJobListener;
 
 public class JobSubmittionListener implements GramJobListener {
 
-	private static final String DELIMITER = "#";
-	private boolean finished;
-	private int error;
-	private int status;
-	private StringBuffer buffer;
-
-	private GramJob job;
-
-	private static final Logger log = Logger.getLogger(JobSubmittionListener.class);
-
-	public JobSubmittionListener(GramJob job, StringBuffer buffer) {
-		this.buffer = buffer;
-		this.job = job;
-	}
-
-	// waits for DONE or FAILED status
-	public void waitFor() throws InterruptedException {
-		while (!finished) {
-			
-			// job status is changed but method isn't invoked
-			if (status != 0) {
-				if (job.getStatus() != status) {
-					log.info("invoke method manually");
-					statusChanged(job);
-				} else {
-					log.info("job " + job.getIDAsString() + " have same status: " + GramJob.getStatusAsString(status));
-				}
-			} else {
-				log.info("Status is zero");
-			}
-			
-			synchronized (this) {
-				wait(60 * 1000l);
-			}			
-		}
-	}
-
-	public synchronized void statusChanged(GramJob job) {
-		log.debug("Listener: statusChanged triggered");
-		int jobStatus = job.getStatus();
-		String jobId = job.getIDAsString();
-		String statusString = job.getStatusAsString();
-		log.info("Job Status: " + statusString + "(" + jobStatus + ")");
-		buffer.append(formatJobStatus(jobId, statusString));
-		log.debug(formatJobStatus(jobId, statusString));
-
-		status = jobStatus;
-		if (jobStatus == GramJob.STATUS_DONE) {
-			finished = true;
-		} else if (jobStatus == GramJob.STATUS_FAILED) {
-			finished = true;
-			error = job.getError();
-			log.info("Job Error Code: " + error);
-			buffer.append(DELIMITER + error);
-		}
-		buffer.append("\n");
-
-		// notify wait thread to wake up if done		
-		if (finished) {
-			notify();
-		}
-	}
-
-	public static String formatJobStatus(String jobid, String jobstatus) {
-		return System.currentTimeMillis() + DELIMITER + jobid + DELIMITER + jobstatus;
-	}
-
-	public int getError() {
-		return error;
-	}
-
-	public int getStatus() {
-		return status;
-	}
-
-	public void wakeup() {
-		try {
-			notify();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
+    private static final String DELIMITER = "#";
+    private boolean finished;
+    private int error;
+    private int status;
+    private StringBuffer buffer;
+
+    private GramJob job;
+
+    private static final Logger log = Logger.getLogger(JobSubmittionListener.class);
+
+    public JobSubmittionListener(GramJob job, StringBuffer buffer) {
+        this.buffer = buffer;
+        this.job = job;
+    }
+
+    // waits for DONE or FAILED status
+    public void waitFor() throws InterruptedException {
+        while (!finished) {
+
+            // job status is changed but method isn't invoked
+            if (status != 0) {
+                if (job.getStatus() != status) {
+                    log.info("invoke method manually");
+                    statusChanged(job);
+                } else {
+                    log.info("job " + job.getIDAsString() + " have same status: " + GramJob.getStatusAsString(status));
+                }
+            } else {
+                log.info("Status is zero");
+            }
+
+            synchronized (this) {
+                wait(60 * 1000l);
+            }
+        }
+    }
+
+    public synchronized void statusChanged(GramJob job) {
+        log.debug("Listener: statusChanged triggered");
+        int jobStatus = job.getStatus();
+        String jobId = job.getIDAsString();
+        String statusString = job.getStatusAsString();
+        log.info("Job Status: " + statusString + "(" + jobStatus + ")");
+        buffer.append(formatJobStatus(jobId, statusString));
+        log.debug(formatJobStatus(jobId, statusString));
+
+        status = jobStatus;
+        if (jobStatus == GramJob.STATUS_DONE) {
+            finished = true;
+        } else if (jobStatus == GramJob.STATUS_FAILED) {
+            finished = true;
+            error = job.getError();
+            log.info("Job Error Code: " + error);
+            buffer.append(DELIMITER + error);
+        }
+        buffer.append("\n");
+
+        // notify wait thread to wake up if done
+        if (finished) {
+            notify();
+        }
+    }
+
+    public static String formatJobStatus(String jobid, String jobstatus) {
+        return System.currentTimeMillis() + DELIMITER + jobid + DELIMITER + jobstatus;
+    }
+
+    public int getError() {
+        return error;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void wakeup() {
+        try {
+            notify();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 }

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/GridFTPContactInfo.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/GridFTPContactInfo.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/GridFTPContactInfo.java
(original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/GridFTPContactInfo.java
Sat Nov 10 03:25:44 2012
@@ -21,14 +21,12 @@
 
 package org.apache.airavata.jobsubmission.utils;
 
-
-
 /**
  * Class represents GridFTP Endpoint
  * 
  */
 public class GridFTPContactInfo {
-	 public static final int DEFAULT_GSI_FTP_PORT = 2811;
+    public static final int DEFAULT_GSI_FTP_PORT = 2811;
     public String hostName;
     public int port;
 

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/GridFtp.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/GridFtp.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/GridFtp.java
(original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/GridFtp.java
Sat Nov 10 03:25:44 2012
@@ -43,14 +43,13 @@ import org.globus.ftp.exception.ServerEx
 import org.globus.gsi.gssapi.auth.HostAuthorization;
 import org.ietf.jgss.GSSCredential;
 
-
 /**
  * GridFTP tools
  */
 public class GridFtp {
 
-      public static final String GSIFTP_SCHEME = "gsiftp";
-      private static final Logger log = Logger.getLogger(GridFtp.class);
+    public static final String GSIFTP_SCHEME = "gsiftp";
+    private static final Logger log = Logger.getLogger(GridFtp.class);
 
     /**
      * Make directory at remote location
@@ -156,7 +155,7 @@ public class GridFtp {
                 try {
                     ftpClient.close();
                 } catch (Exception e) {
-                	log.info("Cannot close GridFTP client connection");
+                    log.info("Cannot close GridFTP client connection");
                 }
             }
         }
@@ -204,7 +203,7 @@ public class GridFtp {
                 try {
                     ftpClient.close();
                 } catch (Exception e) {
-                	log.info("Cannot close GridFTP client connection");
+                    log.info("Cannot close GridFTP client connection");
                 }
             }
         }
@@ -381,6 +380,7 @@ public class GridFtp {
             }
         }
     }
+
     public static URI createGsiftpURI(String host, String localPath) throws URISyntaxException
{
         StringBuffer buf = new StringBuffer();
         if (!host.startsWith("gsiftp://"))

Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/ServiceConstants.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/ServiceConstants.java?rev=1407723&r1=1407722&r2=1407723&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/ServiceConstants.java
(original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/ServiceConstants.java
Sat Nov 10 03:25:44 2012
@@ -1,3 +1,24 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
 package org.apache.airavata.jobsubmission.utils;
 
 public class ServiceConstants {



Mime
View raw message