Examples of GSISSHJobSubmissionListener


Examples of org.apache.airavata.gfac.notification.listeners.GSISSHJobSubmissionListener

            log.info(jobDescriptor.toXML());
            final String jobID = cluster.submitBatchJob(jobDescriptor);
            log.info("Job Submitted successfully and returned Job ID: " + jobID);
            jobExecutionContext.getNotifier().publish(new JobIDEvent(jobID));

            final JobSubmissionListener listener = new GSISSHJobSubmissionListener(jobExecutionContext);
            final Cluster finalCluster = cluster;
//            try {
//            // Wait 5 seconds to start the first poll, this is hard coded, user doesn't have
//            // to configure this.
//            Thread.sleep(5000);
//        } catch (InterruptedException e) {
//            log.error("Error during job status monitoring");
//            throw new SSHApiException("Error during job status monitoring", e);
//        }
//        // Get the job status first
            try {
//
                Thread t = new Thread() {
                    @Override
                    public void run() {
                        try {
                            JobStatus jobStatus = finalCluster.getJobStatus(jobID);
                            listener.statusChanged(jobStatus);
                            while (true) {
                                while (!jobStatus.equals(JobStatus.C)) {
                                    if (!jobStatus.equals(listener.getJobStatus().toString())) {
                                        listener.setJobStatus(jobStatus);
                                        listener.statusChanged(jobStatus);
                                    }
                                    Thread.sleep(60000);

                                    jobStatus = finalCluster.getJobStatus(jobID);
                                }
                                //Set the job status to Complete
                                listener.setJobStatus(JobStatus.C);
                                listener.statusChanged(jobStatus);
                                break;
                            }
                        } catch (InterruptedException e) {
                            log.error("Error listening to the submitted job", e);
                        } catch (SSHApiException e) {
                            log.error("Error listening to the submitted job", e);
                        }
                    }
                };
                //  This thread runs until the program termination, so that use can provide
//            // any action in onChange method of the listener, without worrying for waiting in the caller thread.
                t.setDaemon(false);
                t.start();
            } catch (Exception e) {
                String error = "Error during job status monitoring";
                log.error(error);
                throw new GFacProviderException(error, e);
            }
            while (!listener.isJobDone()) {
                Thread.sleep(10000);
            }
        } catch (SSHApiException e) {
            String error = "Error submitting the job to host " + host.getHostAddress() + e.getMessage();
            log.error(error);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.