Search in sources :

Example 1 with EmailParser

use of org.apache.airavata.gfac.core.monitor.EmailParser in project airavata by apache.

the class EmailBasedMonitor method parse.

private JobStatusResult parse(Message message) throws MessagingException, AiravataException {
    Address fromAddress = message.getFrom()[0];
    String addressStr = fromAddress.toString();
    ResourceJobManagerType jobMonitorType = getJobMonitorType(addressStr);
    EmailParser emailParser = emailParserMap.get(jobMonitorType);
    if (emailParser == null) {
        throw new AiravataException("[EJM]: Un-handle resource job manager type: " + jobMonitorType.toString() + " for email monitoring -->  " + addressStr);
    }
    return emailParser.parseEmail(message);
}
Also used : ResourceJobManagerType(org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerType) Address(javax.mail.Address) EmailParser(org.apache.airavata.gfac.core.monitor.EmailParser) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 2 with EmailParser

use of org.apache.airavata.gfac.core.monitor.EmailParser 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)

Aggregations

AiravataException (org.apache.airavata.common.exception.AiravataException)2 EmailParser (org.apache.airavata.gfac.core.monitor.EmailParser)2 ResourceJobManagerType (org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerType)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Address (javax.mail.Address)1 MessagingException (javax.mail.MessagingException)1 GFacException (org.apache.airavata.gfac.core.GFacException)1 ResourceConfig (org.apache.airavata.gfac.core.config.ResourceConfig)1