use of org.apache.airavata.gfac.core.provider.GFacProviderException in project airavata by apache.
the class SMSByteIOOutHandler method invoke.
@Override
public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
super.invoke(jobExecutionContext);
ActivityInfo activityInfo = (ActivityInfo) jobExecutionContext.getProperty(PROP_ACTIVITY_INFO);
try {
if (activityInfo == null) {
log.error("No ActivityInfo instance found. The activity execution is ended due to an exception, see provider logs");
return;
}
if ((activityInfo.getActivityStatus().getState() == ActivityStateEnumeration.FAILED)) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
try {
dataTransferrer.downloadStdOuts();
} catch (GFacProviderException e) {
throw new GFacHandlerException("Cannot download stdout data", e);
}
} else if (activityInfo.getActivityStatus().getState() == ActivityStateEnumeration.FINISHED) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
try {
if (activityInfo.getActivityStatus().getExitCode() == 0) {
dataTransferrer.downloadRemoteFiles();
} else {
dataTransferrer.downloadStdOuts();
}
} catch (GFacProviderException e) {
throw new GFacHandlerException("Cannot download stdout data", e);
}
}
} finally {
try {
if (storageClient != null) {
storageClient.destroy();
}
} catch (Exception e) {
log.warn("Cannot destroy temporary SMS instance", e);
}
}
}
use of org.apache.airavata.gfac.core.provider.GFacProviderException in project airavata by apache.
the class UNICORESecurityContext method getDefaultConfiguration.
public DefaultClientConfiguration getDefaultConfiguration(Boolean enableMessageLogging, UserConfigurationData userData) throws GFacException, ApplicationSettingsException {
X509Credential cred = null;
try {
boolean genCert = userData.isGenerateCert();
if (genCert) {
String userDN = userData.getUserDN();
if (userDN == null && "".equals(userDN)) {
log.warn("Cannot generate cert, falling back to container configured MyProxy credentials");
return getDefaultConfiguration(enableMessageLogging);
} else {
log.info("Generating X.509 certificate for: " + userDN);
try {
String caCertPath = ServerSettings.getSetting(BESConstants.PROP_CA_CERT_PATH, "");
String caKeyPath = ServerSettings.getSetting(BESConstants.PROP_CA_KEY_PATH, "");
String caKeyPass = ServerSettings.getSetting(BESConstants.PROP_CA_KEY_PASS, "");
if (caCertPath.equals("") || caKeyPath.equals("")) {
throw new Exception("CA certificate or key file path missing in the properties file. " + "Please make sure " + BESConstants.PROP_CA_CERT_PATH + " or " + BESConstants.PROP_CA_KEY_PATH + " are not empty.");
}
if ("".equals(caKeyPass)) {
log.warn("Caution: CA key has no password. For security reasons it is highly recommended to set a CA key password");
}
cred = generateShortLivedCredential(userDN, caCertPath, caKeyPath, caKeyPass);
} catch (Exception e) {
throw new GFacProviderException("Error occured while generating a short lived credential for user:" + userDN, e);
}
}
} else {
return getDefaultConfiguration(enableMessageLogging);
}
secProperties = new DefaultClientConfiguration(dcValidator, cred);
setExtraSettings();
} catch (Exception e) {
throw new GFacException(e.getMessage(), e);
}
secProperties.getETDSettings().setExtendTrustDelegation(true);
if (enableMessageLogging)
secProperties.setMessageLogging(true);
// secProperties.setDoSignMessage(true);
secProperties.getETDSettings().setIssuerCertificateChain(secProperties.getCredential().getCertificateChain());
return secProperties;
}
use of org.apache.airavata.gfac.core.provider.GFacProviderException in project airavata by apache.
the class DataTransferrer method downloadRemoteFiles.
/**
* This method will download all the remote files specified in the output
* context of a job.
*/
public void downloadRemoteFiles() throws GFacProviderException {
String downloadLocation = getDownloadLocation();
File file = new File(downloadLocation);
if (!file.exists()) {
file.mkdirs();
}
Map<String, Object> output = jobContext.getOutMessageContext().getParameters();
Set<String> keys = output.keySet();
for (String outPrm : keys) {
OutputDataObjectType actualParameter = (OutputDataObjectType) output.get(outPrm);
if (DataType.STDERR == actualParameter.getType())
continue;
if (DataType.STDOUT == actualParameter.getType())
continue;
String value = actualParameter.getValue();
FileDownloader fileDownloader = new FileDownloader(value, downloadLocation, Mode.overwrite);
try {
fileDownloader.perform(storageClient);
String outputPath = downloadLocation + File.separator + value.substring(value.lastIndexOf('/') + 1);
actualParameter.setValue(outputPath);
actualParameter.setType(DataType.URI);
jobContext.addOutputFile(outputPath);
} catch (Exception e) {
throw new GFacProviderException(e.getLocalizedMessage(), e);
}
}
downloadStdOuts();
}
use of org.apache.airavata.gfac.core.provider.GFacProviderException in project airavata by apache.
the class DataTransferrer method downloadStdOuts.
public void downloadStdOuts() throws GFacProviderException {
String downloadLocation = getDownloadLocation();
File file = new File(downloadLocation);
if (!file.exists()) {
file.mkdirs();
}
String stdout = jobContext.getStandardOutput();
String stderr = jobContext.getStandardError();
if (stdout != null) {
stdout = stdout.substring(stdout.lastIndexOf('/') + 1);
}
if (stderr != null) {
stderr = stderr.substring(stderr.lastIndexOf('/') + 1);
}
String stdoutFileName = (stdout == null || stdout.equals("")) ? "stdout" : stdout;
String stderrFileName = (stdout == null || stderr.equals("")) ? "stderr" : stderr;
ApplicationDeploymentDescription application = jobContext.getApplicationContext().getApplicationDeploymentDescription();
String stdoutLocation = downloadLocation + File.separator + stdoutFileName;
FileDownloader f1 = new FileDownloader(stdoutFileName, stdoutLocation, Mode.overwrite);
try {
f1.perform(storageClient);
log.info("Downloading stdout and stderr..");
String stdoutput = readFile(stdoutLocation);
jobContext.addOutputFile(stdoutLocation);
jobContext.setStandardOutput(stdoutLocation);
log.info("Stdout downloaded to -> " + stdoutLocation);
if (UASDataStagingProcessor.isUnicoreEndpoint(jobContext)) {
String scriptExitCodeFName = "UNICORE_SCRIPT_EXIT_CODE";
String scriptCodeLocation = downloadLocation + File.separator + scriptExitCodeFName;
f1.setFrom(scriptExitCodeFName);
f1.setTo(scriptCodeLocation);
f1.perform(storageClient);
log.info("UNICORE_SCRIPT_EXIT_CODE downloaded to " + scriptCodeLocation);
}
String stderrLocation = downloadLocation + File.separator + stderrFileName;
f1.setFrom(stderrFileName);
f1.setTo(stderrLocation);
f1.perform(storageClient);
String stderror = readFile(stderrLocation);
jobContext.addOutputFile(stderrLocation);
jobContext.setStandardError(stderrLocation);
log.info("Stderr downloaded to -> " + stderrLocation);
} catch (Exception e) {
throw new GFacProviderException(e.getLocalizedMessage(), e);
}
}
use of org.apache.airavata.gfac.core.provider.GFacProviderException in project airavata by apache.
the class ResourceProcessor method generateResourceElements.
public static void generateResourceElements(JobDefinitionType value, JobExecutionContext context) throws Exception {
TaskDetails taskData = context.getTaskData();
if (taskData != null && taskData.isSetTaskScheduling()) {
try {
ComputationalResourceScheduling crs = taskData.getTaskScheduling();
if (crs.getTotalPhysicalMemory() > 0) {
RangeValueType rangeType = new RangeValueType();
rangeType.setLowerBound(Double.NaN);
rangeType.setUpperBound(Double.NaN);
rangeType.setExact(crs.getTotalPhysicalMemory());
JSDLUtils.setIndividualPhysicalMemoryRequirements(value, rangeType);
}
if (crs.getNodeCount() > 0) {
RangeValueType rangeType = new RangeValueType();
rangeType.setLowerBound(Double.NaN);
rangeType.setUpperBound(Double.NaN);
rangeType.setExact(crs.getNodeCount());
JSDLUtils.setTotalResourceCountRequirements(value, rangeType);
// set totalcpu count to -1 as we dont need that
crs.setTotalCPUCount(0);
}
if (crs.getWallTimeLimit() > 0) {
RangeValueType cpuTime = new RangeValueType();
cpuTime.setLowerBound(Double.NaN);
cpuTime.setUpperBound(Double.NaN);
long wallTime = crs.getWallTimeLimit() * 60;
cpuTime.setExact(wallTime);
JSDLUtils.setIndividualCPUTimeRequirements(value, cpuTime);
}
if (crs.getTotalCPUCount() > 0) {
RangeValueType rangeType = new RangeValueType();
rangeType.setLowerBound(Double.NaN);
rangeType.setUpperBound(Double.NaN);
rangeType.setExact(crs.getTotalCPUCount());
JSDLUtils.setTotalCPUCountRequirements(value, rangeType);
}
} catch (NullPointerException npe) {
new GFacProviderException("No value set for resource requirements.", npe);
}
}
}
Aggregations