[ 
https://issues.apache.org/jira/browse/NIFI-241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14275468#comment-14275468
 ] 

Mark Payne commented on NIFI-241:
---------------------------------

Mike,

You can definitely use the @OnAdded, @OnRemoved, @OnShutdown annotations, but 
their uses should be quite rare. @OnAdded is used when the Processor is added 
to the graph and never again, including on restart of NiFi, so establishing a 
connection pool should not be done in @OnAdded. @OnRemoved is a good time to 
remove a state file, for example. @OnShutdown is used only in order to be a 
good steward and clean up open connections, etc., as it is not guaranteed to be 
called on shutdown (kill -9 for instance doesn't allow this to happen).

> Framework FingerprintFactory begins processor life cycle but does not finish
> ----------------------------------------------------------------------------
>
>                 Key: NIFI-241
>                 URL: https://issues.apache.org/jira/browse/NIFI-241
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>            Reporter: Michael Moser
>            Assignee: Mark Payne
>             Fix For: 0.0.1
>
>
> The FingerprintFactory will create Processor objects and invoke their 
> initialize() and @OnAdded methods.  If a Processor uses system resources, 
> these methods are where those resources are allocated.  But, those processors 
> are never disposed by calling their @OnRemoved or @OnShutdown methods.  This 
> may result in system resource leaks, depending on how processors are 
> implemented.
> To reproduce, add a processor to the NiFi graph and restart NiFi.  Note that 
> initialize() and @OnAdded is called at least twice (I observed 3 times) as 
> NiFi starts.  The getIdentifier() is different for each invocation.  Shutdown 
> NiFi and observe that @OnShutdown is called once.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to