Search in sources :

Example 1 with ActivityInfo

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);
        }
    }
}
Also used : ActivityInfo(org.apache.airavata.gfac.bes.utils.ActivityInfo) GFacProviderException(org.apache.airavata.gfac.core.provider.GFacProviderException) GFacHandlerException(org.apache.airavata.gfac.core.handler.GFacHandlerException) GFacHandlerException(org.apache.airavata.gfac.core.handler.GFacHandlerException) GFacProviderException(org.apache.airavata.gfac.core.provider.GFacProviderException)

Aggregations

ActivityInfo (org.apache.airavata.gfac.bes.utils.ActivityInfo)1 GFacHandlerException (org.apache.airavata.gfac.core.handler.GFacHandlerException)1 GFacProviderException (org.apache.airavata.gfac.core.provider.GFacProviderException)1