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);
}
}
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);
}
}
}
}
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);
}
}
}
}
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);
}
}
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);
}
}
Aggregations