use of org.apache.airavata.common.exception.AiravataException in project airavata by apache.
the class EmailBasedMonitor method populateAddressAndParserMap.
private void populateAddressAndParserMap(Map<ResourceJobManagerType, ResourceConfig> resourceConfigs) throws AiravataException {
for (Map.Entry<ResourceJobManagerType, ResourceConfig> resourceConfigEntry : resourceConfigs.entrySet()) {
ResourceJobManagerType type = resourceConfigEntry.getKey();
ResourceConfig config = resourceConfigEntry.getValue();
List<String> resourceEmailAddresses = config.getResourceEmailAddresses();
if (resourceEmailAddresses != null && !resourceEmailAddresses.isEmpty()) {
for (String resourceEmailAddress : resourceEmailAddresses) {
addressMap.put(resourceEmailAddress, type);
}
try {
Class<? extends EmailParser> emailParserClass = Class.forName(config.getEmailParser()).asSubclass(EmailParser.class);
EmailParser emailParser = emailParserClass.getConstructor().newInstance();
emailParserMap.put(type, emailParser);
} catch (Exception e) {
throw new AiravataException("Error while instantiation email parsers", e);
}
}
}
}
use of org.apache.airavata.common.exception.AiravataException in project airavata by apache.
the class UGEEmailParser method parseContent.
private void parseContent(Message message, JobStatusResult jobStatusResult) throws MessagingException, AiravataException {
String subject = message.getSubject();
// FIXME - HACK to handle Little Dog email issue from SIU
subject = subject.replace("Set in error state", "Failed");
Pattern pattern = Pattern.compile(REGEX);
Matcher matcher = pattern.matcher(subject);
try {
if (matcher.find()) {
jobStatusResult.setJobId(matcher.group(JOBID));
jobStatusResult.setJobName(matcher.group(JOBNAME));
String content = (String) message.getContent();
jobStatusResult.setState(getJobState(matcher.group(STATUS), content));
} else {
log.error("[EJM]: No matched found for subject => \n" + subject);
}
} catch (IOException e) {
throw new AiravataException("[EJM]: Error while reading content of the email message");
}
}
use of org.apache.airavata.common.exception.AiravataException in project airavata by apache.
the class WorkflowWSDL method setupParameterType.
/**
* @param name
* @param appinfo
* @param schema
* @return The sequence element.
*/
private XmlElement setupParameterType(String name, XmlElement appinfo, XmlElement schema) {
XmlElement element = schema.addElement(WSConstants.ELEMENT_TAG);
element.setAttributeValue(WSConstants.NAME_ATTRIBUTE, name);
String type = name + TYPE_SUFFIX;
element.setAttributeValue(WSConstants.TYPE_ATTRIBUTE, WSConstants.TYPE_NS_PREFIX + ":" + type);
// add metadata
if (appinfo != null) {
XmlElement annotation = element.addElement(WSConstants.ANNOTATION_TAG);
try {
annotation.addElement(XMLUtil.deepClone(appinfo));
} catch (AiravataException e) {
log.error(e.getMessage(), e);
}
}
XmlElement complex = schema.addElement(WSConstants.COMPLEX_TYPE_TAG);
complex.setAttributeValue(WSConstants.NAME_ATTRIBUTE, type);
XmlElement sequence = complex.addElement(WSConstants.SEQUENCE_TAG);
return sequence;
}
use of org.apache.airavata.common.exception.AiravataException in project airavata by apache.
the class OrchestratorUtils method getScratchLocation.
public static String getScratchLocation(OrchestratorContext context, ProcessModel processModel, String gatewayId) throws RegistryException, AiravataException {
try {
ComputeResourcePreference computeResourcePreference = getComputeResourcePreference(context, gatewayId, processModel.getComputeResourceId());
ComputationalResourceSchedulingModel processResourceSchedule = processModel.getProcessResourceSchedule();
if (processModel.isUseUserCRPref()) {
UsrResourceProfile userResourceProfile = getUserResourceProfile(context);
UserComputeResourcePreference userComputeResourcePreference = userResourceProfile.getUserComputeResourcePreference(processModel.getUserName(), gatewayId, processModel.getComputeResourceId());
if (isValid(userComputeResourcePreference.getScratchLocation())) {
return userComputeResourcePreference.getScratchLocation();
} else if (isValid(processResourceSchedule.getOverrideScratchLocation())) {
logger.warn("User computer resource preference doesn't have valid scratch location, using computer " + "resource scheduling scratch location " + processResourceSchedule.getOverrideScratchLocation());
return processResourceSchedule.getOverrideScratchLocation();
} else if (isValid(computeResourcePreference.getScratchLocation())) {
logger.warn("Either User computer resource preference or computer resource scheduling doesn't have " + "valid scratch location, using gateway computer resource preference scratch location" + computeResourcePreference.getScratchLocation());
return computeResourcePreference.getScratchLocation();
} else {
throw new AiravataException("Scratch location is not found");
}
} else {
if (isValid(processResourceSchedule.getOverrideScratchLocation())) {
return processResourceSchedule.getOverrideScratchLocation();
} else if (isValid(computeResourcePreference.getScratchLocation())) {
logger.warn("Process compute resource scheduling doesn't have valid scratch location, " + "using gateway computer resource preference scratch location" + computeResourcePreference.getScratchLocation());
return computeResourcePreference.getScratchLocation();
} else {
throw new AiravataException("Scratch location is not found");
}
}
} catch (AppCatalogException e) {
logger.error("Error occurred while initializing app catalog to fetch scratch location", e);
throw new RegistryException("Error occurred while initializing app catalog to fetch scratch location", e);
}
}
use of org.apache.airavata.common.exception.AiravataException in project airavata by apache.
the class RabbitMQPublisher method connect.
private void connect() throws AiravataException {
try {
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setUri(properties.getBrokerUrl());
connectionFactory.setAutomaticRecoveryEnabled(properties.isAutoRecoveryEnable());
connection = connectionFactory.newConnection();
connection.addShutdownListener(new ShutdownListener() {
public void shutdownCompleted(ShutdownSignalException cause) {
}
});
log.info("connected to rabbitmq: " + connection + " for " + properties.getExchangeName());
channel = connection.createChannel();
if (properties.getPrefetchCount() > 0) {
channel.basicQos(properties.getPrefetchCount());
}
if (properties.getExchangeName() != null) {
channel.exchangeDeclare(properties.getExchangeName(), properties.getExchangeType(), // durable
true);
}
} catch (Exception e) {
String msg = "RabbitMQ connection issue for exchange : " + properties.getExchangeName();
log.error(msg);
throw new AiravataException(msg, e);
}
}
Aggregations