Search in sources :

Example 21 with AiravataException

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);
            }
        }
    }
}
Also used : ResourceJobManagerType(org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerType) EmailParser(org.apache.airavata.gfac.core.monitor.EmailParser) ResourceConfig(org.apache.airavata.gfac.core.config.ResourceConfig) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MessagingException(javax.mail.MessagingException) AiravataException(org.apache.airavata.common.exception.AiravataException) GFacException(org.apache.airavata.gfac.core.GFacException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 22 with AiravataException

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");
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) IOException(java.io.IOException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 23 with AiravataException

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;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 24 with AiravataException

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);
    }
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 25 with AiravataException

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);
    }
}
Also used : ShutdownListener(com.rabbitmq.client.ShutdownListener) ConnectionFactory(com.rabbitmq.client.ConnectionFactory) ShutdownSignalException(com.rabbitmq.client.ShutdownSignalException) TException(org.apache.thrift.TException) IOException(java.io.IOException) ShutdownSignalException(com.rabbitmq.client.ShutdownSignalException) AiravataException(org.apache.airavata.common.exception.AiravataException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Aggregations

AiravataException (org.apache.airavata.common.exception.AiravataException)40 IOException (java.io.IOException)10 TException (org.apache.thrift.TException)8 GFacException (org.apache.airavata.gfac.core.GFacException)6 RegistryException (org.apache.airavata.registry.cpi.RegistryException)6 XmlElement (org.xmlpull.infoset.XmlElement)5 ShutdownSignalException (com.rabbitmq.client.ShutdownSignalException)4 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)4 MessagingException (javax.mail.MessagingException)3 MessageContext (org.apache.airavata.messaging.core.MessageContext)3 Session (com.jcraft.jsch.Session)2 ConnectionFactory (com.rabbitmq.client.ConnectionFactory)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 Flags (javax.mail.Flags)2 Message (javax.mail.Message)2 EmailParser (org.apache.airavata.gfac.core.monitor.EmailParser)2