Search in sources :

Example 11 with OnStopped

use of org.apache.nifi.annotation.lifecycle.OnStopped in project nifi by apache.

the class MergeRecord method resetState.

@OnStopped
public final void resetState() {
    final RecordBinManager manager = binManager.get();
    if (manager != null) {
        manager.purge();
    }
    binManager.set(null);
}
Also used : RecordBinManager(org.apache.nifi.processors.standard.merge.RecordBinManager) OnStopped(org.apache.nifi.annotation.lifecycle.OnStopped)

Example 12 with OnStopped

use of org.apache.nifi.annotation.lifecycle.OnStopped in project nifi by apache.

the class PostHTTP method onStopped.

@OnStopped
public void onStopped() {
    this.acceptsRef.set(null);
    for (final Map.Entry<String, Config> entry : configMap.entrySet()) {
        final Config config = entry.getValue();
        config.getConnectionManager().shutdown();
    }
    configMap.clear();
    final StreamThrottler throttler = throttlerRef.getAndSet(null);
    if (throttler != null) {
        try {
            throttler.close();
        } catch (IOException e) {
            getLogger().error("Failed to close StreamThrottler", e);
        }
    }
}
Also used : RequestConfig(org.apache.http.client.config.RequestConfig) IOException(java.io.IOException) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) LeakyBucketStreamThrottler(org.apache.nifi.stream.io.LeakyBucketStreamThrottler) StreamThrottler(org.apache.nifi.stream.io.StreamThrottler) OnStopped(org.apache.nifi.annotation.lifecycle.OnStopped)

Example 13 with OnStopped

use of org.apache.nifi.annotation.lifecycle.OnStopped in project nifi by apache.

the class ConsumeMQTT method onStopped.

@OnStopped
public void onStopped(final ProcessContext context) throws IOException {
    if (mqttQueue != null && !mqttQueue.isEmpty() && processSessionFactory != null) {
        logger.info("Finishing processing leftover messages");
        ProcessSession session = processSessionFactory.createSession();
        transferQueue(session);
    } else {
        if (mqttQueue != null && !mqttQueue.isEmpty()) {
            throw new ProcessException("Stopping the processor but there is no ProcessSessionFactory stored and there are messages in the MQTT internal queue. Removing the processor now will " + "clear the queue but will result in DATA LOSS. This is normally due to starting the processor, receiving messages and stopping before the onTrigger happens. The messages " + "in the MQTT internal queue cannot finish processing until until the processor is triggered to run.");
        }
    }
}
Also used : ProcessSession(org.apache.nifi.processor.ProcessSession) ProcessException(org.apache.nifi.processor.exception.ProcessException) OnStopped(org.apache.nifi.annotation.lifecycle.OnStopped)

Example 14 with OnStopped

use of org.apache.nifi.annotation.lifecycle.OnStopped in project nifi by apache.

the class PutSyslog method onStopped.

@OnStopped
public void onStopped() {
    if (senderPool != null) {
        ChannelSender sender = senderPool.poll();
        while (sender != null) {
            sender.close();
            sender = senderPool.poll();
        }
    }
}
Also used : DatagramChannelSender(org.apache.nifi.processor.util.put.sender.DatagramChannelSender) SSLSocketChannelSender(org.apache.nifi.processor.util.put.sender.SSLSocketChannelSender) ChannelSender(org.apache.nifi.processor.util.put.sender.ChannelSender) SocketChannelSender(org.apache.nifi.processor.util.put.sender.SocketChannelSender) OnStopped(org.apache.nifi.annotation.lifecycle.OnStopped)

Example 15 with OnStopped

use of org.apache.nifi.annotation.lifecycle.OnStopped in project nifi by apache.

the class ConsumeWindowsEventLog method stop.

/**
 * Cleanup
 */
@OnStopped
public void stop() {
    if (isSubscribed()) {
        wEvtApi.EvtClose(subscriptionHandle);
    }
    subscriptionHandle = null;
    evtSubscribeCallback = null;
    if (!renderedXMLs.isEmpty()) {
        if (sessionFactory != null) {
            getLogger().info("Finishing processing leftover events");
            ProcessSession session = sessionFactory.createSession();
            processQueue(session);
        } else {
            throw new ProcessException("Stopping the processor but there is no ProcessSessionFactory stored and there are messages in the internal queue. Removing the processor now will " + "clear the queue but will result in DATA LOSS. This is normally due to starting the processor, receiving events and stopping before the onTrigger happens. The messages " + "in the internal queue cannot finish processing until until the processor is triggered to run.");
        }
    }
    sessionFactory = null;
    provenanceUri = null;
    renderedXMLs = null;
}
Also used : ProcessSession(org.apache.nifi.processor.ProcessSession) ProcessException(org.apache.nifi.processor.exception.ProcessException) OnStopped(org.apache.nifi.annotation.lifecycle.OnStopped)

Aggregations

OnStopped (org.apache.nifi.annotation.lifecycle.OnStopped)15 IOException (java.io.IOException)4 ProcessException (org.apache.nifi.processor.exception.ProcessException)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ProcessSession (org.apache.nifi.processor.ProcessSession)2 ChannelSender (org.apache.nifi.processor.util.put.sender.ChannelSender)2 DatagramChannelSender (org.apache.nifi.processor.util.put.sender.DatagramChannelSender)2 SSLSocketChannelSender (org.apache.nifi.processor.util.put.sender.SSLSocketChannelSender)2 SocketChannelSender (org.apache.nifi.processor.util.put.sender.SocketChannelSender)2 WrappedMessageConsumer (org.apache.nifi.processors.standard.util.WrappedMessageConsumer)2 LeakyBucketStreamThrottler (org.apache.nifi.stream.io.LeakyBucketStreamThrottler)2 StreamThrottler (org.apache.nifi.stream.io.StreamThrottler)2 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 PollableSource (org.apache.flume.PollableSource)1 EventDrivenSourceRunner (org.apache.flume.source.EventDrivenSourceRunner)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 HiveEndPoint (org.apache.hive.hcatalog.streaming.HiveEndPoint)1