use of org.apache.airavata.gfac.bes.utils.ActivityInfo 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);
}
}
}
Aggregations