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();
}
}
}
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();
}
}
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;
}
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);
}
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));
}
Aggregations