agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/managers/launchers/AbstractJobLauncher.java
/**
     * Downloads the {@link Software#getDeploymentPath()} from the {@link Software#getStorageSystem()} for the current
     * {@link Job}. Proper {@link JobEvent} and {@link TransferTask} are created and saved with the job history.
     *
     * @return path to the downloaded software deployment directory
     * @throws ClosedByInterruptException
     * @throws JobException
     */
Downloads the  Software#getDeploymentPath() from the  Software#getStorageSystem() for the current
Job. Proper  JobEvent and  TransferTask are created and saved with the job history.

@return path to the downloaded software deployment directory
@throws ClosedByInterruptException
@throws JobException
Downloads the Software#getDeploymentPath () from the Software#getStorageSystem () for the current Job . Proper JobEvent and TransferTask are created and saved with the job history . @return path to the downloaded software deployment directory @throws ClosedByInterruptException @throws JobException
protected Path fetchSoftwareDeploymentDirectory() throws ClosedByInterruptException, JobException, SystemUnknownException, SystemUnavailableException, SoftwareUnavailableException {
        Path result;
        TransferTask transferTask;
        RemoteDataClient remoteSoftwareDataClient = null;
        StorageSystem storageSystem = null;
        try {
            storageSystem = (StorageSystem) getJobManager().getAvailableSystem(getSoftware().getStorageSystem().getSystemId());
            remoteSoftwareDataClient = storageSystem.getRemoteDataClient();
            remoteSoftwareDataClient.authenticate();
            checkStopped();
            transferTask = createJobSoftwareDeploymentDirectoryTransferTask();
            try {
                RemoteFileInfo deploymentPathFileInfo = remoteSoftwareDataClient.getFileInfo(getSoftware().getDeploymentPath());
                checkStopped();
                if (deploymentPathFileInfo.isDirectory()) {
                    transferTask.setStatus(TransferStatusType.TRANSFERRING);
                    updateTransferTask(transferTask);
                    for (RemoteFileInfo child : remoteSoftwareDataClient.ls(getSoftware().getDeploymentPath())) {
                        checkStopped();
                        TransferTask childTransferTask = new TransferTask(
                                transferTask.getSource() + "/" + child.getName(),
                                transferTask.getDest() + "/" + child.getName(),
                                getJob().getOwner(), transferTask, transferTask);
                        RemoteTransferListener remoteListener = new RemoteTransferListener(childTransferTask);
                        Path childPath = Paths.get(getSoftware().getDeploymentPath()).resolve(child.getName());
                        if (child.isFile()) {
                            childTransferTask.setTotalSize(child.getSize());
                            childTransferTask.setTotalFiles(1);
                            File localChild = new File(getTempAppDir(), child.getName());
                            if (localChild.exists() && localChild.length() != child.getSize()) {
                                childTransferTask.setTotalSkippedFiles(1);
                            }
                        }
                        try {
                            updateTransferTask(childTransferTask);
                        } catch (TransferException e) {
                            childTransferTask.setStatus(TransferStatusType.CANCELLED);
                            try {
                                transferTask.updateSummaryStats(childTransferTask);
                            } catch (Throwable ignored) {
                            }
                            throw new JobException("Unable to save child transfer task during staging of software deployment directory", e);
                        }
                        try {
                            if (childTransferTask.getTotalSkippedFiles() == 0) {
                                remoteSoftwareDataClient.get(childPath.toString(), getTempAppDir().getPath(), remoteListener);
                            } else {
                                remoteListener.skipped(childTransferTask.getTotalSize(), childPath.toString());
                            }
                        } catch (IOException | RemoteDataException e) {
                            try {
                                if (remoteListener.getTransferTask().getStatus() != TransferStatusType.FAILED) {
                                    remoteListener.failed();
                                }
                                transferTask.updateSummaryStats(remoteListener.getTransferTask());
                                updateTransferTask(transferTask);
                            } catch (Throwable ignored) {
                                log.error("Failed to update parent transfer task " + transferTask.getUuid() +
                                        " after failing to fetch " + childTransferTask.getSource() +
                                        " while staging deployment directory of " + getSoftware().getUniqueName() +
                                        " for job " + getJob().getUuid());
                            }
                            throw new RemoteDataException("Failed to fetch " + childTransferTask.getSource() +
                                    " while staging deployment directory of " + getSoftware().getUniqueName(), e);
                        }
                        transferTask.updateSummaryStats(remoteListener.getTransferTask());
                        updateTransferTask(transferTask);
                    }
                    transferTask.setStatus(TransferStatusType.COMPLETED);
                    updateTransferTask(transferTask);
                } else {
                    remoteSoftwareDataClient.get(getSoftware().getDeploymentPath(), getTempAppDir().getPath(), new RemoteTransferListener(transferTask));
                }
            } catch (FileNotFoundException e) {
                throw new SoftwareUnavailableException("Deployment path " + getSoftware().getDeploymentPath() +
                        " does not exist on the deployment system, " + storageSystem.getSystemId());
            }
            result = getTempAppDir().toPath();
        } catch (ClosedByInterruptException e) {
            throw e;
        } catch (SystemUnknownException e) {
            throw new SystemUnknownException("No system found matching id of app deployment system, " +
                    getSoftware().getStorageSystem().getSystemId() + ".");
        } catch (SystemUnavailableException e) {
            throw new SystemUnavailableException("App deployment system " + getSoftware().getStorageSystem().getSystemId() +
                    " is currently unavailable.");
        } catch (IOException | TransferException | RemoteDataException | RemoteCredentialException e) {
            throw new JobException("Unable to fetch deployment path for app " + getSoftware().getUniqueName() +
                    " from " + getSoftware().getStorageSystem().getSystemId(), e);
        } finally {
            if (remoteSoftwareDataClient != null) {
                remoteSoftwareDataClient.disconnect();
            }
        }
        return result;
    }
protected Path fetchSoftwareDeploymentDirectory ( ) throws ClosedByInterruptException , JobException , SystemUnknownException , SystemUnavailableException , SoftwareUnavailableException { Path result ; TransferTask transferTask ; RemoteDataClient remoteSoftwareDataClient = null ; StorageSystem storageSystem = null ; try { storageSystem = ( StorageSystem ) getJobManager ( ) . getAvailableSystem ( getSoftware ( ) . getStorageSystem ( ) . getSystemId ( ) ) ; remoteSoftwareDataClient = storageSystem . getRemoteDataClient ( ) ; remoteSoftwareDataClient . authenticate ( ) ; checkStopped ( ) ; transferTask = createJobSoftwareDeploymentDirectoryTransferTask ( ) ; try { RemoteFileInfo deploymentPathFileInfo = remoteSoftwareDataClient . getFileInfo ( getSoftware ( ) . getDeploymentPath ( ) ) ; checkStopped ( ) ; if ( deploymentPathFileInfo . isDirectory ( ) ) { transferTask . setStatus ( TransferStatusType . TRANSFERRING ) ; updateTransferTask ( transferTask ) ; for ( RemoteFileInfo child : remoteSoftwareDataClient . ls ( getSoftware ( ) . getDeploymentPath ( ) ) ) { checkStopped ( ) ; TransferTask childTransferTask = new TransferTask ( transferTask . getSource ( ) + "/" + child . getName ( ) , transferTask . getDest ( ) + "/" + child . getName ( ) , getJob ( ) . getOwner ( ) , transferTask , transferTask ) ; RemoteTransferListener remoteListener = new RemoteTransferListener ( childTransferTask ) ; Path childPath = Paths . get ( getSoftware ( ) . getDeploymentPath ( ) ) . resolve ( child . getName ( ) ) ; if ( child . isFile ( ) ) { childTransferTask . setTotalSize ( child . getSize ( ) ) ; childTransferTask . setTotalFiles ( 1 ) ; File localChild = new File ( getTempAppDir ( ) , child . getName ( ) ) ; if ( localChild . exists ( ) && localChild . length ( ) != child . getSize ( ) ) { childTransferTask . setTotalSkippedFiles ( 1 ) ; } } try { updateTransferTask ( childTransferTask ) ; } catch ( TransferException e ) { childTransferTask . setStatus ( TransferStatusType . CANCELLED ) ; try { transferTask . updateSummaryStats ( childTransferTask ) ; } catch ( Throwable ignored ) { } throw new JobException ( "Unable to save child transfer task during staging of software deployment directory" , e ) ; } try { if ( childTransferTask . getTotalSkippedFiles ( ) == 0 ) { remoteSoftwareDataClient . get ( childPath . toString ( ) , getTempAppDir ( ) . getPath ( ) , remoteListener ) ; } else { remoteListener . skipped ( childTransferTask . getTotalSize ( ) , childPath . toString ( ) ) ; } } catch ( IOException | RemoteDataException e ) { try { if ( remoteListener . getTransferTask ( ) . getStatus ( ) != TransferStatusType . FAILED ) { remoteListener . failed ( ) ; } transferTask . updateSummaryStats ( remoteListener . getTransferTask ( ) ) ; updateTransferTask ( transferTask ) ; } catch ( Throwable ignored ) { log . error ( "Failed to update parent transfer task " + transferTask . getUuid ( ) + " after failing to fetch " + childTransferTask . getSource ( ) + " while staging deployment directory of " + getSoftware ( ) . getUniqueName ( ) + " for job " + getJob ( ) . getUuid ( ) ) ; } throw new RemoteDataException ( "Failed to fetch " + childTransferTask . getSource ( ) + " while staging deployment directory of " + getSoftware ( ) . getUniqueName ( ) , e ) ; } transferTask . updateSummaryStats ( remoteListener . getTransferTask ( ) ) ; updateTransferTask ( transferTask ) ; } transferTask . setStatus ( TransferStatusType . COMPLETED ) ; updateTransferTask ( transferTask ) ; } else { remoteSoftwareDataClient . get ( getSoftware ( ) . getDeploymentPath ( ) , getTempAppDir ( ) . getPath ( ) , new RemoteTransferListener ( transferTask ) ) ; } } catch ( FileNotFoundException e ) { throw new SoftwareUnavailableException ( "Deployment path " + getSoftware ( ) . getDeploymentPath ( ) + " does not exist on the deployment system, " + storageSystem . getSystemId ( ) ) ; } result = getTempAppDir ( ) . toPath ( ) ; } catch ( ClosedByInterruptException e ) { throw e ; } catch ( SystemUnknownException e ) { throw new SystemUnknownException ( "No system found matching id of app deployment system, " + getSoftware ( ) . getStorageSystem ( ) . getSystemId ( ) + "." ) ; } catch ( SystemUnavailableException e ) { throw new SystemUnavailableException ( "App deployment system " + getSoftware ( ) . getStorageSystem ( ) . getSystemId ( ) + " is currently unavailable." ) ; } catch ( IOException | TransferException | RemoteDataException | RemoteCredentialException e ) { throw new JobException ( "Unable to fetch deployment path for app " + getSoftware ( ) . getUniqueName ( ) + " from " + getSoftware ( ) . getStorageSystem ( ) . getSystemId ( ) , e ) ; } finally { if ( remoteSoftwareDataClient != null ) { remoteSoftwareDataClient . disconnect ( ) ; } } return result ; }
Downloads the {@link Software#getDeploymentPath()} from the {@link Software#getStorageSystem()} for the current
 {@link Job}.
Downloads the { @link Software#getDeploymentPath () } from the { @link Software#getStorageSystem () } for the current { @link Job } .
// stat the remote deployment directory. This gives us file info an an existence check. // if the remote is a directory, we copy its contents to this host. Because the RDC classes always // include the parent directory in a get/put operation, we iterate through the remote directory and // copy each value to the tempAppDirectory so we can skip existing file items on retries. // update the parent task to show progress // iterate over remote directory contents, copying each child in turn // break if interrupt received // create a transfer task to track the child // skip existing files already present in the local tempAppDir // only copy if the file is missing and size differs duplicate copies // skip existing, unchanged file // save the transfer task regardless // have to fail the entire directory copy if this fails since we can't record progress // fetch the data // we have a valid task, make the copy unless we're skipping due to prior success // ensure the child task has been properly terminated and recorded, then tidy up the // parent transfertask and exit // update parent task with results of child transfer task // once everything completes, complete the parent task // otherwise it's a file and we can can just copy the file. This is usually because the software is // public. // if the deployment path does not exist, we can't run the software, so we report it as unavailble // to the calling method.