exceptionfactory commented on PR #9737:
URL: https://github.com/apache/nifi/pull/9737#issuecomment-2675170481

   Thanks for the reply!
   
   > > For example, should the Scheduler thread be created in the onScheduled 
method, but only started in onTrigger?
   > 
   > This is possible but has a downside. Scheduler needs a record processor 
which uses a `ProcessSessionFactory` that is available only in `onTrigger()`. 
The processor won't get called before the thread the Scheduler runs on is 
started, yet it would introduce additional state in the record processor which 
is definitely a downside.
   
   Good point regarding the `ProcessSessionFactory`. That actually highlights a 
larger concern in that having the Processor hold on to the Session Factory in 
this way is generally poor practice and should be revisited.
   
   > 
   > The question is: is the advantage bigger than the disadvantage? imho not 
given the creation is fairly infrequent
   > 
   > > It may also be more efficient to use an atomic variable, as opposed to 
the synchronized lock object approach.
   > 
   > I may lack experience with NiFi but it seems to me that start and stop 
events are fairly infrequent for processors — this indicates there will be 
little contention especially when the lock is inherent to a processor instance, 
no?
   > 
   > If so, having an AtomicBoolean or other Atomic* will only unnecessary 
complicate the code.
   
   Starting and stopping is less frequent, but the framework calls 
`onTrigger()` very frequently, thus inefficient nature of the synchronized 
block in a method that the framework calls repeatedly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to