agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/managers/JobManager.java
/**
     * Removes the job work directory in the event staging fails too many times.
     *
     * @param job the job whose staged data will be deleted
     * @throws JobException if unable to update the job or delete the data
     * @throws SystemUnavailableException if the job's {@link ExecutionSystem} is not available
     */
Removes the job work directory in the event staging fails too many times.
@param job the job whose staged data will be deleted
@throws JobException if unable to update the job or delete the data
@throws SystemUnavailableException if the job's  ExecutionSystem is not available
Removes the job work directory in the event staging fails too many times . @param job the job whose staged data will be deleted @throws JobException if unable to update the job or delete the data @throws SystemUnavailableException if the job ' s ExecutionSystem is not available
public Job deleteStagedData(Job job) throws JobException, SystemUnavailableException {
        ExecutionSystem system = new JobManager().getJobExecutionSystem(job);
        log.debug("Cleaning up staging directory for failed job " + job.getUuid());
        job = JobManager.updateStatus(job, JobStatusType.STAGING_INPUTS, "Cleaning up remote work directory.");
        ExecutionSystem remoteExecutionSystem = null;
        RemoteDataClient remoteExecutionDataClient = null;
        String remoteWorkPath = job.getWorkPath();
        try {
            remoteExecutionSystem = getJobExecutionSystem(job);
            remoteExecutionDataClient = remoteExecutionSystem.getRemoteDataClient(job.getInternalUsername());
            remoteExecutionDataClient.authenticate();
            if (StringUtils.isBlank(remoteWorkPath)) {
                remoteWorkPath = calculateJobRemoteWorkPath(job, remoteExecutionSystem);
            }
            if (remoteExecutionDataClient.doesExist(remoteWorkPath)) {
                remoteExecutionDataClient.delete(remoteWorkPath);
                log.debug("Successfully deleted remote work directory " + remoteWorkPath + " for failed job " + job.getUuid());
                job = JobManager.updateStatus(job, JobStatusType.STAGING_INPUTS, "Completed cleaning up remote work directory.");
            } else {
                log.debug("Skipping deleting remote work directory " + remoteWorkPath + " for failed job " + job.getUuid() + ". Directory not present.");
                job = JobManager.updateStatus(job, JobStatusType.STAGING_INPUTS, "Completed cleaning up remote work directory.");
            }
            return job;
        } catch (RemoteDataException | IOException | RemoteCredentialException e) {
            throw new JobException(e);
        } finally {
            try {
                if (remoteExecutionDataClient != null) remoteExecutionDataClient.disconnect();
            } catch (Exception ignored) {}
        }
    }
public Job deleteStagedData ( Job job ) throws JobException , SystemUnavailableException { ExecutionSystem system = new JobManager ( ) . getJobExecutionSystem ( job ) ; log . debug ( "Cleaning up staging directory for failed job " + job . getUuid ( ) ) ; job = JobManager . updateStatus ( job , JobStatusType . STAGING_INPUTS , "Cleaning up remote work directory." ) ; ExecutionSystem remoteExecutionSystem = null ; RemoteDataClient remoteExecutionDataClient = null ; String remoteWorkPath = job . getWorkPath ( ) ; try { remoteExecutionSystem = getJobExecutionSystem ( job ) ; remoteExecutionDataClient = remoteExecutionSystem . getRemoteDataClient ( job . getInternalUsername ( ) ) ; remoteExecutionDataClient . authenticate ( ) ; if ( StringUtils . isBlank ( remoteWorkPath ) ) { remoteWorkPath = calculateJobRemoteWorkPath ( job , remoteExecutionSystem ) ; } if ( remoteExecutionDataClient . doesExist ( remoteWorkPath ) ) { remoteExecutionDataClient . delete ( remoteWorkPath ) ; log . debug ( "Successfully deleted remote work directory " + remoteWorkPath + " for failed job " + job . getUuid ( ) ) ; job = JobManager . updateStatus ( job , JobStatusType . STAGING_INPUTS , "Completed cleaning up remote work directory." ) ; } else { log . debug ( "Skipping deleting remote work directory " + remoteWorkPath + " for failed job " + job . getUuid ( ) + ". Directory not present." ) ; job = JobManager . updateStatus ( job , JobStatusType . STAGING_INPUTS , "Completed cleaning up remote work directory." ) ; } return job ; } catch ( RemoteDataException | IOException | RemoteCredentialException e ) { throw new JobException ( e ) ; } finally { try { if ( remoteExecutionDataClient != null ) remoteExecutionDataClient . disconnect ( ) ; } catch ( Exception ignored ) { } } }
Removes the job work directory in the event staging fails too many times.
Removes the job work directory in the event staging fails too many times .
// copy to remote execution work directory // if the job work directory has not been saved yet, calculate it manually. This shouldn't be // an issue given the directory should have been created prior to staging, but we do this in // the event the directory was created, but an error happened during staging that prevented the // db from being updated. This guarantees the directory will be properly defined and removed.