Search in sources :

Example 26 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class LocalRemoteCluster method copyFrom.

@Override
public void copyFrom(String remoteFile, String localFile) throws GFacException {
    Path sourcePath = Paths.get(remoteFile);
    Path targetPath = Paths.get(localFile);
    try {
        Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
    } catch (IOException e) {
        throw new GFacException("Error while copying sourceFile: " + sourcePath.toString() + ", to destinationFile: " + targetPath.toString(), e);
    }
}
Also used : Path(java.nio.file.Path) GFacException(org.apache.airavata.gfac.core.GFacException) IOException(java.io.IOException)

Example 27 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class HPCRemoteCluster method copyTo.

@Override
public void copyTo(String localFile, String remoteFile) throws GFacException {
    int retry = 3;
    while (retry > 0) {
        try {
            log.info("Transferring localhost:" + localFile + " to " + serverInfo.getHost() + ":" + remoteFile);
            SSHUtils.scpTo(localFile, remoteFile, getSshSession());
            retry = 0;
        } catch (Exception e) {
            retry--;
            if (retry == 0) {
                throw new GFacException("Failed to scp localhost:" + localFile + " to " + serverInfo.getHost() + ":" + remoteFile, e);
            } else {
                log.info("Retry transfer localhost:" + localFile + " to " + serverInfo.getHost() + ":" + remoteFile);
            }
        }
    }
}
Also used : GFacException(org.apache.airavata.gfac.core.GFacException) AiravataException(org.apache.airavata.common.exception.AiravataException) GFacException(org.apache.airavata.gfac.core.GFacException) IOException(java.io.IOException) JSchException(com.jcraft.jsch.JSchException)

Example 28 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class HPCRemoteCluster method copyFrom.

@Override
public void copyFrom(String remoteFile, String localFile) throws GFacException {
    int retry = 3;
    while (retry > 0) {
        try {
            log.info("Transferring " + serverInfo.getHost() + ":" + remoteFile + " To localhost:" + localFile);
            SSHUtils.scpFrom(remoteFile, localFile, getSession());
            retry = 0;
        } catch (Exception e) {
            retry--;
            if (retry == 0) {
                throw new GFacException("Failed to scp " + serverInfo.getHost() + ":" + remoteFile + " to " + "localhost:" + localFile, e);
            } else {
                log.info("Retry transfer " + serverInfo.getHost() + ":" + remoteFile + "  to localhost:" + localFile);
            }
        }
    }
}
Also used : GFacException(org.apache.airavata.gfac.core.GFacException) AiravataException(org.apache.airavata.common.exception.AiravataException) GFacException(org.apache.airavata.gfac.core.GFacException) IOException(java.io.IOException) JSchException(com.jcraft.jsch.JSchException)

Example 29 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class HPCRemoteCluster method scpThirdParty.

@Override
public void scpThirdParty(String sourceFile, Session srcSession, String destinationFile, Session destSession, DIRECTION direction, boolean ignoreEmptyFile) throws GFacException {
    int retryCount = 0;
    try {
        while (retryCount < MAX_RETRY_COUNT) {
            retryCount++;
            log.info("Transferring from:" + sourceFile + " To: " + destinationFile);
            try {
                SSHUtils.scpThirdParty(sourceFile, srcSession, destinationFile, destSession, ignoreEmptyFile);
                // exit while loop
                break;
            } catch (JSchException e) {
                if (retryCount == MAX_RETRY_COUNT) {
                    log.error("Retry count " + MAX_RETRY_COUNT + " exceeded for  transferring from:" + sourceFile + " To: " + destinationFile, e);
                    throw e;
                }
                log.error("Issue with jsch, Retry transferring from:" + sourceFile + " To: " + destinationFile, e);
            }
        }
    } catch (IOException | JSchException e) {
        throw new GFacException("Failed scp file:" + sourceFile + " to remote file " + destinationFile, e);
    }
}
Also used : JSchException(com.jcraft.jsch.JSchException) GFacException(org.apache.airavata.gfac.core.GFacException) IOException(java.io.IOException)

Example 30 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class HPCRemoteCluster method throwExceptionOnError.

/**
 * This method return <code>true</code> if there is an error in standard output. If not return <code>false</code>
 *
 * @param reader        - command output reader
 * @param submitCommand - command which executed in remote machine.
 * @return command has return error or not.
 */
private void throwExceptionOnError(StandardOutReader reader, RawCommandInfo submitCommand) throws GFacException {
    String stdErrorString = reader.getStdErrorString();
    String command = submitCommand.getCommand().substring(submitCommand.getCommand().lastIndexOf(File.separator) + 1);
    if (stdErrorString == null) {
    // noting to do
    } else if ((stdErrorString.contains(command.trim()) && !stdErrorString.contains("Warning")) || stdErrorString.contains("error")) {
        log.error("Command {} , Standard Error output {}", command, stdErrorString);
        throw new GFacException("Error running command " + command + "  on remote cluster. StandardError: " + stdErrorString);
    }
}
Also used : GFacException(org.apache.airavata.gfac.core.GFacException)

Aggregations

GFacException (org.apache.airavata.gfac.core.GFacException)73 IOException (java.io.IOException)24 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)19 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)16 JSchException (com.jcraft.jsch.JSchException)15 RegistryException (org.apache.airavata.registry.cpi.RegistryException)15 AiravataException (org.apache.airavata.common.exception.AiravataException)14 TaskStatus (org.apache.airavata.model.status.TaskStatus)13 URISyntaxException (java.net.URISyntaxException)12 ErrorModel (org.apache.airavata.model.commons.ErrorModel)11 CredentialStoreException (org.apache.airavata.credential.store.store.CredentialStoreException)10 TException (org.apache.thrift.TException)9 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)8 DefaultClientConfiguration (eu.unicore.util.httpclient.DefaultClientConfiguration)7 URI (java.net.URI)7 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)7 Session (com.jcraft.jsch.Session)6 InvalidKeyException (java.security.InvalidKeyException)6 RemoteCluster (org.apache.airavata.gfac.core.cluster.RemoteCluster)6 JobModel (org.apache.airavata.model.job.JobModel)6