Search in sources :

Example 1 with EngineConfiguration

use of org.opennms.netmgt.correlation.drools.config.EngineConfiguration in project opennms by OpenNMS.

the class DroolsCorrelationEngine method reloadConfig.

@Override
public void reloadConfig() {
    EventBuilder ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, getName());
    ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "DroolsCorrelationEngine-" + m_name);
    try {
        LOG.info("Reloading configuration for engine {}", m_name);
        EngineConfiguration cfg = JaxbUtils.unmarshal(EngineConfiguration.class, m_configPath);
        Optional<RuleSet> opt = cfg.getRuleSetCollection().stream().filter(rs -> rs.getName().equals(getName())).findFirst();
        if (opt.isPresent()) {
            marshallStateToDisk(true);
            opt.get().updateEngine(this);
            initialize();
        } else {
            ebldr.setUei(EventConstants.RELOAD_DAEMON_CONFIG_FAILED_UEI);
            ebldr.addParam(EventConstants.PARM_REASON, "RuleSet not found on " + m_configPath);
        }
    } catch (Exception e) {
        ebldr.setUei(EventConstants.RELOAD_DAEMON_CONFIG_FAILED_UEI);
        ebldr.addParam(EventConstants.PARM_REASON, e.getMessage());
    } finally {
        sendEvent(ebldr.getEvent());
    }
}
Also used : EngineConfiguration(org.opennms.netmgt.correlation.drools.config.EngineConfiguration) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) EventConstants(org.opennms.netmgt.events.api.EventConstants) AbstractCorrelationEngine(org.opennms.netmgt.correlation.AbstractCorrelationEngine) Meter(com.codahale.metrics.Meter) Level(org.kie.api.builder.Message.Level) Event(org.opennms.netmgt.xml.event.Event) Map(java.util.Map) RuleBaseConfiguration(org.drools.core.RuleBaseConfiguration) KieServices(org.kie.api.KieServices) JaxbUtils(org.opennms.core.xml.JaxbUtils) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) Path(java.nio.file.Path) KieMarshallers(org.kie.api.marshalling.KieMarshallers) AssertBehaviour(org.drools.core.RuleBaseConfiguration.AssertBehaviour) Resource(org.springframework.core.io.Resource) KieFileSystem(org.kie.api.builder.KieFileSystem) KieBuilder(org.kie.api.builder.KieBuilder) Logger(org.slf4j.Logger) MetricRegistry(com.codahale.metrics.MetricRegistry) EventProcessingOption(org.kie.api.conf.EventProcessingOption) Collection(java.util.Collection) Logging(org.opennms.core.logging.Logging) FileOutputStream(java.io.FileOutputStream) KieContainer(org.kie.api.runtime.KieContainer) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) EventBuilder(org.opennms.netmgt.model.events.EventBuilder) ApplicationContext(org.springframework.context.ApplicationContext) File(java.io.File) DroolsParserException(org.drools.compiler.compiler.DroolsParserException) List(java.util.List) Paths(java.nio.file.Paths) RuleSet(org.opennms.netmgt.correlation.drools.config.RuleSet) ByteStreams(com.google.common.io.ByteStreams) Optional(java.util.Optional) Marshaller(org.kie.api.marshalling.Marshaller) ObjectMarshallingStrategy(org.kie.api.marshalling.ObjectMarshallingStrategy) Gauge(com.codahale.metrics.Gauge) InputStream(java.io.InputStream) RuleSet(org.opennms.netmgt.correlation.drools.config.RuleSet) EventBuilder(org.opennms.netmgt.model.events.EventBuilder) EngineConfiguration(org.opennms.netmgt.correlation.drools.config.EngineConfiguration) IOException(java.io.IOException) DroolsParserException(org.drools.compiler.compiler.DroolsParserException)

Aggregations

Gauge (com.codahale.metrics.Gauge)1 Meter (com.codahale.metrics.Meter)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 ByteStreams (com.google.common.io.ByteStreams)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 DroolsParserException (org.drools.compiler.compiler.DroolsParserException)1 RuleBaseConfiguration (org.drools.core.RuleBaseConfiguration)1 AssertBehaviour (org.drools.core.RuleBaseConfiguration.AssertBehaviour)1 KieBase (org.kie.api.KieBase)1