use of org.apache.airavata.gfac.core.handler.GFacHandlerException 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.handler.GFacHandlerException in project airavata by apache.
the class AbstractSMSHandler method invoke.
@Override
public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
try {
initSecurityProperties(jobExecutionContext);
JobSubmissionInterface preferredJobSubmissionInterface = jobExecutionContext.getPreferredJobSubmissionInterface();
JobSubmissionProtocol protocol = preferredJobSubmissionInterface.getJobSubmissionProtocol();
String interfaceId = preferredJobSubmissionInterface.getJobSubmissionInterfaceId();
String factoryUrl = null;
if (protocol.equals(JobSubmissionProtocol.UNICORE)) {
UnicoreJobSubmission unicoreJobSubmission = GFacUtils.getUnicoreJobSubmission(interfaceId);
factoryUrl = unicoreJobSubmission.getUnicoreEndPointURL();
}
storageClient = null;
if (!isSMSInstanceExisting(jobExecutionContext)) {
EndpointReferenceType eprt = EndpointReferenceType.Factory.newInstance();
eprt.addNewAddress().setStringValue(factoryUrl);
StorageCreator storageCreator = new StorageCreator(secProperties, factoryUrl, 5, null);
try {
storageClient = storageCreator.createStorage();
} catch (Exception e2) {
log.error("Cannot create storage..");
throw new GFacHandlerException("Cannot create storage..", e2);
}
jobExecutionContext.setProperty(PROP_SMS_EPR, storageClient.getEPR());
} else {
EndpointReferenceType eprt = (EndpointReferenceType) jobExecutionContext.getProperty(PROP_SMS_EPR);
try {
storageClient = new StorageClient(eprt, secProperties);
} catch (Exception e) {
throw new GFacHandlerException("Cannot create storage..", e);
}
}
dataTransferrer = new DataTransferrer(jobExecutionContext, storageClient);
} catch (AppCatalogException e) {
throw new GFacHandlerException("Error occurred while retrieving unicore job submission interface..", e);
}
}
use of org.apache.airavata.gfac.core.handler.GFacHandlerException in project airavata by apache.
the class AbstractSMSHandler method initSecurityProperties.
protected void initSecurityProperties(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
log.debug("Initializing SMSInHandler security properties ..");
if (secProperties != null) {
secProperties = secProperties.clone();
return;
}
UNICORESecurityContext unicoreContext;
try {
if (jobExecutionContext.getSecurityContext(X509SecurityContext.X509_SECURITY_CONTEXT) == null) {
SecurityUtils.addSecurityContext(jobExecutionContext);
log.info("Successfully added the UNICORE Security Context");
}
} catch (Exception e) {
log.error(e.getMessage());
try {
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
GFacUtils.saveErrorDetails(jobExecutionContext, errors.toString(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
} catch (GFacException e1) {
log.error(e1.getLocalizedMessage());
}
throw new GFacHandlerException("Error while creating UNICORESecurityContext", e, e.getLocalizedMessage());
}
try {
unicoreContext = (UNICORESecurityContext) jobExecutionContext.getSecurityContext(X509SecurityContext.X509_SECURITY_CONTEXT);
log.info("Successfully retrieved the UNICORE Security Context");
} catch (GFacException e) {
throw new GFacHandlerException(e);
}
if (log.isDebugEnabled()) {
log.debug("Generating client's default security configuration..");
}
// TODO: check what kind of credential (server signed or myproxy) should be used
try {
secProperties = unicoreContext.getDefaultConfiguration(false);
} catch (Exception e) {
throw new GFacHandlerException(e);
}
if (log.isDebugEnabled()) {
log.debug("Security properties are initialized.");
}
jobExecutionContext.setProperty(PROP_CLIENT_CONF, secProperties);
}
Aggregations