markap14 commented on PR #11993:
URL: https://github.com/apache/nifi/pull/11993#issuecomment-7413957020

   Thanks @exceptionfactory. I think inspecting the yield duration and decided 
"if it's a short yield i'll do it, else I won't" is kind of an odd behavior as 
well, if I'm understanding the proposal. Rather than that I'd probably prefer a 
slightly different approach. I think in this case a short yield such as 10 
milliseconds would probably be okay. The issue is that if we set the default 
yield duration to 10 milliseconds, existing processors would already have their 
value set to 1 second (assuming the user didn't change it) and those processors 
would drastically drop in performance.
   
   One option is that we could instead use a `Thread.sleep(10L);` to just sleep 
for a very short duration. Or, alternatively, we could introduce a use 
`ProcessContext.yield(Duration duration)` method so that the processor could 
use `context.yield(Duration.ofMillis(10));` - or maybe 
`context.yield(Duration.ofMillis( Math.min(10, 
context.getYieldDuration().toMillis() ));` to yield the minimum of the 
configured duration and 10 milliseconds.
   
   Introducing a new `yield` override that allows explicitly passing a duration 
is reasonable. And in fact, it would be helpful in a handful of scenarios where 
a Processor makes a web request and gets back a rate-limiting 429 with a 
Retry-After header. The only caveat here is that many years ago, we did have a 
`yield` override that allowed explicitly passing a duration - and that duration 
was a required argument. At the time, there was no "Yield Duration" configured 
in settings/scheduling. As a result, what happened was every processor that 
wanted to yield had a property for configuring how long to yield. Not bad. But 
then there were 2 scenarios where it wanted to yield. So then 2 properties. And 
then 3 and 4. It became way too cumbersome. So we'd need to be diligent that we 
don't let that type of configuration creep in again.


-- 
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