agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/managers/launchers/CondorLauncher.java
/**
     * Submit job to the condor scheduler.
     *
     * @throws IOException when there is an issue parsing or locating the application template and deployment assets.
     * @throws JobException when an error occurs interacting with the remote system or updating the job details.
     * @throws SchedulerException when the scheduler on the {@link ExecutionSystem} rejects the job.
     * @throws SoftwareUnavailableException when the job software is disabled, or deployment assets are missing.
     * @throws SystemUnavailableException when one or more dependent systems is unavailable.
     * @throws SystemUnknownException when a dependent system (job execution, software deployment, etc) are no longer in the db.
     */
Submit job to the condor scheduler.
@throws IOException when there is an issue parsing or locating the application template and deployment assets.
@throws JobException when an error occurs interacting with the remote system or updating the job details.
@throws SchedulerException when the scheduler on the  ExecutionSystem rejects the job.
@throws SoftwareUnavailableException when the job software is disabled, or deployment assets are missing.
@throws SystemUnavailableException when one or more dependent systems is unavailable.
@throws SystemUnknownException when a dependent system (job execution, software deployment, etc) are no longer in the db.
Submit job to the condor scheduler . @throws IOException when there is an issue parsing or locating the application template and deployment assets . @throws JobException when an error occurs interacting with the remote system or updating the job details . @throws SchedulerException when the scheduler on the ExecutionSystem rejects the job . @throws SoftwareUnavailableException when the job software is disabled or deployment assets are missing . @throws SystemUnavailableException when one or more dependent systems is unavailable . @throws SystemUnknownException when a dependent system ( job execution software deployment etc ) are no longer in the db .
@Override
    public void launch() throws IOException, JobException, SoftwareUnavailableException, SchedulerException, SystemUnknownException, SystemUnavailableException
    {
        String condorSubmitCmdString = null;
        try 
        {
            try {
                if (getRemoteExecutionDataClient() == null) {
                    setRemoteExecutionDataClient(getExecutionSystem().getRemoteDataClient(getJob().getInternalUsername()));
                    getRemoteExecutionDataClient().authenticate();
                }
            } catch (IOException | RemoteDataException | RemoteCredentialException e) {
                String msg = "Failed to create a remote connection to " + getJob().getSystem() +
                        ". App assets cannot be staged to the job execution system.";
                throw new JobException(msg, e);
            }
            String remoteJobWorkPath = calculateRemoteJobPath();
            createJobRemoteWorkPath(getExecutionSystem(), getRemoteExecutionDataClient(), remoteJobWorkPath);
            getJob().setWorkPath(remoteJobWorkPath);
            setTimeMarker();
            checkStopped();
            createTempAppDir();
            checkStopped();
            copySoftwareToTempAppDir();
            checkStopped();
            String transferWrapperContent = createTransferWrapper();
            writeToRemoteJobDir("transfer_wrapper.sh", transferWrapperContent);
            checkStopped();
            String applicationWrapperContent = processApplicationWrapperTemplate();
            writeToRemoteJobDir(getSoftware().getExecutablePath(), applicationWrapperContent);
            checkStopped();
            String jobArchiveManifestContent = processJobArchiveManifest();
            writeToRemoteJobDir(ARCHIVE_FILENAME, jobArchiveManifestContent);
            checkStopped();
            String condorSubmitFileContent = createCondorSubmitFile(timeMark);
            writeToRemoteJobDir("condorSubmit", condorSubmitFileContent);
            checkStopped();
            stageSofwareApplication();
            checkStopped();
            addExecutionPermissionsToWrapper();
            checkStopped();
            createRemoteTransferPackage();
            checkStopped();
            String condorJobId = submitJobToQueue();
            getJob().setSubmitTime(new DateTime().toDate());   
            getJob().setLastUpdated(new DateTime().toDate());  
            getJob().setLocalJobId(condorJobId);
            getJob().setStatus(JobStatusType.QUEUED, "Condor job successfully placed into queue");
            JobDao.persist(getJob());
        }
        catch (JobException e) {
        	jobFailed = true;
        	log.error(step, e);
        	this.setJob(JobManager.updateStatus(this.getJob(), JobStatusType.FAILED, e.getMessage()));
        	throw e;
        } 
        catch (SystemUnavailableException e) {
        	jobFailed = true;
        	log.error(step, e);
        	throw e;
        } 
        catch (Exception e) {
            jobFailed = true;
            log.error(step, e);
            this.setJob(JobManager.updateStatus(this.getJob(), JobStatusType.FAILED, e.getMessage()));
            throw new JobException("Failed to invoke app: \"" + getSoftware().getUniqueName() + "\n\"   with command:  " + condorSubmitCmdString + "\n" + e.getMessage(), e);
        } 
        finally {
            if (getRemoteExecutionDataClient() != null) { getRemoteExecutionDataClient().disconnect(); }
            FileUtils.deleteQuietly(getTempAppDir());
        }
    }
@ Override public void launch ( ) throws IOException , JobException , SoftwareUnavailableException , SchedulerException , SystemUnknownException , SystemUnavailableException { String condorSubmitCmdString = null ; try { try { if ( getRemoteExecutionDataClient ( ) == null ) { setRemoteExecutionDataClient ( getExecutionSystem ( ) . getRemoteDataClient ( getJob ( ) . getInternalUsername ( ) ) ) ; getRemoteExecutionDataClient ( ) . authenticate ( ) ; } } catch ( IOException | RemoteDataException | RemoteCredentialException e ) { String msg = "Failed to create a remote connection to " + getJob ( ) . getSystem ( ) + ". App assets cannot be staged to the job execution system." ; throw new JobException ( msg , e ) ; } String remoteJobWorkPath = calculateRemoteJobPath ( ) ; createJobRemoteWorkPath ( getExecutionSystem ( ) , getRemoteExecutionDataClient ( ) , remoteJobWorkPath ) ; getJob ( ) . setWorkPath ( remoteJobWorkPath ) ; setTimeMarker ( ) ; checkStopped ( ) ; createTempAppDir ( ) ; checkStopped ( ) ; copySoftwareToTempAppDir ( ) ; checkStopped ( ) ; String transferWrapperContent = createTransferWrapper ( ) ; writeToRemoteJobDir ( "transfer_wrapper.sh" , transferWrapperContent ) ; checkStopped ( ) ; String applicationWrapperContent = processApplicationWrapperTemplate ( ) ; writeToRemoteJobDir ( getSoftware ( ) . getExecutablePath ( ) , applicationWrapperContent ) ; checkStopped ( ) ; String jobArchiveManifestContent = processJobArchiveManifest ( ) ; writeToRemoteJobDir ( ARCHIVE_FILENAME , jobArchiveManifestContent ) ; checkStopped ( ) ; String condorSubmitFileContent = createCondorSubmitFile ( timeMark ) ; writeToRemoteJobDir ( "condorSubmit" , condorSubmitFileContent ) ; checkStopped ( ) ; stageSofwareApplication ( ) ; checkStopped ( ) ; addExecutionPermissionsToWrapper ( ) ; checkStopped ( ) ; createRemoteTransferPackage ( ) ; checkStopped ( ) ; String condorJobId = submitJobToQueue ( ) ; getJob ( ) . setSubmitTime ( new DateTime ( ) . toDate ( ) ) ; getJob ( ) . setLastUpdated ( new DateTime ( ) . toDate ( ) ) ; getJob ( ) . setLocalJobId ( condorJobId ) ; getJob ( ) . setStatus ( JobStatusType . QUEUED , "Condor job successfully placed into queue" ) ; JobDao . persist ( getJob ( ) ) ; } catch ( JobException e ) { jobFailed = true ; log . error ( step , e ) ; this . setJob ( JobManager . updateStatus ( this . getJob ( ) , JobStatusType . FAILED , e . getMessage ( ) ) ) ; throw e ; } catch ( SystemUnavailableException e ) { jobFailed = true ; log . error ( step , e ) ; throw e ; } catch ( Exception e ) { jobFailed = true ; log . error ( step , e ) ; this . setJob ( JobManager . updateStatus ( this . getJob ( ) , JobStatusType . FAILED , e . getMessage ( ) ) ) ; throw new JobException ( "Failed to invoke app: \"" + getSoftware ( ) . getUniqueName ( ) + "\n\"   with command:  " + condorSubmitCmdString + "\n" + e . getMessage ( ) , e ) ; } finally { if ( getRemoteExecutionDataClient ( ) != null ) { getRemoteExecutionDataClient ( ) . disconnect ( ) ; } FileUtils . deleteQuietly ( getTempAppDir ( ) ) ; } }
Submit job to the condor scheduler.
Submit job to the condor scheduler .
// Calculate and sets the remote job path if not already set. This folder could not exist at this // point if the job had no inputs to stage in. We create the directory here just to ensure it's // present when we write the wrapper template // this is used to set the tempAppDir identifier so that we can come back // later to find the directory when the job is done (Failed for cleanup or Successful for archiving) // sets up the application directory to execute this job launch; see comments in method // copy our application package from the software.deploymentPath to our tempAppDir // create the generic transfer wrapper that condor_submit will use to un-tar the execution // package after the files have been transferred to OSG // prepend the application template with call back to let the Job service know the job has started // parse the application template and replace tokens with the inputs, parameters and outputs. // create the shadow file containing the exclusion files for archiving // create the Condor submit file should include the path to executable, the transfer.tar.gz and input(s) // default classAds for Linux // move the local temp directory to the remote system // change permissions to executable for wrapper.sh and transfer_wrapper.sh // remotely tar up the entire executable with input data on the execution system // run condor_submit // Date job submitted to Condor // Date job started by Condor // do we always clean up, or just on success so we have the cache available for retry?