if (hostgridFTP == null || hostgridFTP.length == 0) {
hostgridFTP = new String[] { host.getHostAddress() };
}
boolean success = false;
ProviderException pe = new ProviderException("");
for (String endpoint : host.getGridFTPEndPointArray()) {
try {
/*
* Stdout and Stderror
*/
URI stdoutURI = GfacUtils.createGsiftpURI(endpoint, app.getStandardOutput());
URI stderrURI = GfacUtils.createGsiftpURI(endpoint, app.getStandardError());
log.info("STDOUT:" + stdoutURI.toString());
log.info("STDERR:" + stderrURI.toString());
File logDir = new File("./service_logs");
if (!logDir.exists()) {
logDir.mkdir();
}
// Get the Stdouts and StdErrs
String timeStampedServiceName = GfacUtils.createUniqueNameForService(invocationContext
.getServiceName());
File localStdOutFile = File.createTempFile(timeStampedServiceName, "stdout");
File localStdErrFile = File.createTempFile(timeStampedServiceName, "stderr");
String stdout = ftp.readRemoteFile(stdoutURI, gssCred, localStdOutFile);
String stderr = ftp.readRemoteFile(stderrURI, gssCred, localStdErrFile);
return OutputUtils.fillOutputFromStdout(invocationContext.<ActualParameter> getOutput(), stdout);
} catch (ToolsException e) {
throw new ProviderException(e.getMessage(), e);
} catch (URISyntaxException e) {
throw new ProviderException("URI is malformatted:" + e.getMessage(), e);
}
}
/*
* If the execution reach here, all GridFTP Endpoint is failed.
*/
throw pe;
} catch (XmlException e) {
throw new ProviderException("Cannot read output:" + e.getMessage(), e);
} catch (IOException e) {
throw new ProviderException(e.getMessage(), e);
} catch (SecurityException e) {
throw new ProviderException(e.getMessage(), e);
}
}