Search in sources :

Example 1 with PreconditionListener

use of com.thinkbiganalytics.nifi.core.api.precondition.PreconditionListener in project kylo by Teradata.

the class BeginFeed method ensurePreconditonListener.

private void ensurePreconditonListener(ProcessContext context, Feed feed, String[] dsNames) {
    if (this.preconditionListener == null) {
        MetadataProvider provider = getProviderService(context).getProvider();
        FeedPreconditionEventService precondService = getPreconditionService(context);
        PreconditionListener listener = new PreconditionListener() {

            @Override
            public void triggered(FeedPreconditionTriggerEvent event) {
                getLog().debug("Precondition event triggered: ", new Object[] { event });
                BeginFeed.this.pendingChanges.add(event);
            }
        };
        for (String dsName : dsNames) {
            getLog().debug("Adding precondition listener for datasoure name: " + dsName);
            precondService.addListener("", dsName, listener);
        }
        this.preconditionListener = listener;
    }
}
Also used : PreconditionListener(com.thinkbiganalytics.nifi.core.api.precondition.PreconditionListener) FeedPreconditionTriggerEvent(com.thinkbiganalytics.metadata.rest.model.event.FeedPreconditionTriggerEvent) MetadataProvider(com.thinkbiganalytics.nifi.core.api.metadata.MetadataProvider) FeedPreconditionEventService(com.thinkbiganalytics.nifi.core.api.precondition.FeedPreconditionEventService)

Example 2 with PreconditionListener

use of com.thinkbiganalytics.nifi.core.api.precondition.PreconditionListener in project kylo by Teradata.

the class TriggerFeed method createPreconditionListener.

private PreconditionListener createPreconditionListener() {
    PreconditionListener listener = new PreconditionListener() {

        @Override
        public void triggered(FeedPreconditionTriggerEvent event) {
            getLog().debug("Precondition event triggered: {}", new Object[] { event });
            TriggerFeed.this.triggerEventQueue.add(event);
        }
    };
    return listener;
}
Also used : PreconditionListener(com.thinkbiganalytics.nifi.core.api.precondition.PreconditionListener) FeedPreconditionTriggerEvent(com.thinkbiganalytics.metadata.rest.model.event.FeedPreconditionTriggerEvent)

Example 3 with PreconditionListener

use of com.thinkbiganalytics.nifi.core.api.precondition.PreconditionListener in project kylo by Teradata.

the class JmsPreconditionEventConsumer method receiveEvent.

@JmsListener(destination = MetadataQueues.PRECONDITION_TRIGGER, containerFactory = JmsConstants.QUEUE_LISTENER_CONTAINER_FACTORY)
public void receiveEvent(FeedPreconditionTriggerEvent event) {
    LOG.debug("{} Received JMS message - topic: {}, message: {}", this, MetadataQueues.PRECONDITION_TRIGGER, event);
    LOG.info("{} Received feed precondition trigger event: {}", this, event);
    String key = generateKey(event.getCategory(), event.getFeedName());
    LOG.debug("{} Looking up precondition listener for key '{}'", this, key);
    PreconditionListener listener = this.listeners.get(key);
    if (listener != null) {
        LOG.debug("{} Found precondition listener for key '{}'", this, key);
        listener.triggered(event);
    } else {
        LOG.debug("{} No precondition listeners found for key '{}'", this, key);
    }
}
Also used : PreconditionListener(com.thinkbiganalytics.nifi.core.api.precondition.PreconditionListener) JmsListener(org.springframework.jms.annotation.JmsListener)

Aggregations

PreconditionListener (com.thinkbiganalytics.nifi.core.api.precondition.PreconditionListener)3 FeedPreconditionTriggerEvent (com.thinkbiganalytics.metadata.rest.model.event.FeedPreconditionTriggerEvent)2 MetadataProvider (com.thinkbiganalytics.nifi.core.api.metadata.MetadataProvider)1 FeedPreconditionEventService (com.thinkbiganalytics.nifi.core.api.precondition.FeedPreconditionEventService)1 JmsListener (org.springframework.jms.annotation.JmsListener)1