Search in sources :

Example 1 with OnStopped

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

the class AbstractPutEventProcessor method closeSenders.

@OnStopped
public void closeSenders() {
    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 2 with OnStopped

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

the class PutJMS method cleanupResources.

@OnStopped
public void cleanupResources() {
    WrappedMessageProducer wrappedProducer = producerQueue.poll();
    while (wrappedProducer != null) {
        wrappedProducer.close(getLogger());
        wrappedProducer = producerQueue.poll();
    }
}
Also used : WrappedMessageProducer(org.apache.nifi.processors.standard.util.WrappedMessageProducer) OnStopped(org.apache.nifi.annotation.lifecycle.OnStopped)

Example 3 with OnStopped

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

the class PutHiveStreaming method cleanup.

@OnStopped
public void cleanup() {
    // trigger re-validation of resources
    validationResourceHolder.set(null);
    ComponentLog log = getLogger();
    sendHeartBeat.set(false);
    for (Map<HiveEndPoint, HiveWriter> allWriters : threadWriterList) {
        for (Map.Entry<HiveEndPoint, HiveWriter> entry : allWriters.entrySet()) {
            try {
                HiveWriter w = entry.getValue();
                w.flushAndClose();
            } catch (Exception ex) {
                log.warn("Error while closing writer to " + entry.getKey() + ". Exception follows.", ex);
                if (ex instanceof InterruptedException) {
                    Thread.currentThread().interrupt();
                }
            }
        }
        allWriters.clear();
    }
    if (callTimeoutPool != null) {
        callTimeoutPool.shutdown();
        try {
            while (!callTimeoutPool.isTerminated()) {
                callTimeoutPool.awaitTermination(callTimeout, TimeUnit.MILLISECONDS);
            }
        } catch (Throwable t) {
            log.warn("shutdown interrupted on " + callTimeoutPool, t);
        }
        callTimeoutPool = null;
    }
    ugi = null;
}
Also used : HiveWriter(org.apache.nifi.util.hive.HiveWriter) HiveEndPoint(org.apache.hive.hcatalog.streaming.HiveEndPoint) ComponentLog(org.apache.nifi.logging.ComponentLog) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StreamingException(org.apache.hive.hcatalog.streaming.StreamingException) DiscontinuedException(org.apache.nifi.processor.util.pattern.DiscontinuedException) AuthenticationFailedException(org.apache.nifi.util.hive.AuthenticationFailedException) ProcessException(org.apache.nifi.processor.exception.ProcessException) IOException(java.io.IOException) OnStopped(org.apache.nifi.annotation.lifecycle.OnStopped)

Example 4 with OnStopped

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

the class ExecuteFlumeSource method stopped.

@OnStopped
public void stopped() {
    if (source instanceof PollableSource) {
        source.stop();
    } else {
        EventDrivenSourceRunner runner = runnerRef.get();
        if (runner != null) {
            runner.stop();
            runnerRef.compareAndSet(runner, null);
        }
        NifiSessionFactoryChannel eventDrivenSourceChannel = eventDrivenSourceChannelRef.get();
        if (eventDrivenSourceChannel != null) {
            eventDrivenSourceChannel.stop();
            eventDrivenSourceChannelRef.compareAndSet(eventDrivenSourceChannel, null);
        }
    }
    sessionFactoryRef.set(null);
}
Also used : EventDrivenSourceRunner(org.apache.flume.source.EventDrivenSourceRunner) PollableSource(org.apache.flume.PollableSource) OnStopped(org.apache.nifi.annotation.lifecycle.OnStopped)

Example 5 with OnStopped

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

the class AbstractHadoopProcessor method abstractOnStopped.

@OnStopped
public final void abstractOnStopped() {
    HdfsResources hdfs = hdfsResources.get();
    if (hdfs != null) {
        FileSystem fs = hdfsResources.get().getFileSystem();
        if (fs != null) {
            try {
                getLog().info("Processor Stop in progress. Will release HDFS resources.");
                fs.close();
            } catch (IOException e) {
                getLog().error("Received IOException when attempting to close HDFS FileSystem handle");
            }
        }
    }
    hdfsResources.set(new HdfsResources(null, null, null));
}
Also used : FileSystem(org.apache.hadoop.fs.FileSystem) IOException(java.io.IOException) 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