NIFI-11471: Define new stateless configuration points#7242
NIFI-11471: Define new stateless configuration points#7242ohnoitsyou wants to merge 4 commits intoapache:mainfrom
Conversation
|
Thanks for the contribution @ohnoitsyou. All of the automated checks failed, so please run the local |
|
I think I've got it figured out, just dealing with the intermittent test failures |
markap14
left a comment
There was a problem hiding this comment.
Thanks for the update @ohnoitsyou. I do think that it introduces a good bit of complexity that is unnecessary, though, and does not adhere to standard practices such as using time periods like 10 secs for properties. See comments inline. Thanks!
.../src/main/java/org/apache/nifi/stateless/config/PropertiesFileEngineConfigurationParser.java
Show resolved
Hide resolved
| final long processorStartTimeout = TimeUnit.SECONDS.toMillis(Long.parseLong(properties.getProperty(PROCESSOR_START_TIMEOUT, "10"))); | ||
| final long componentEnableTimeout = TimeUnit.SECONDS.toMillis(Long.parseLong(properties.getProperty(COMPONENT_ENABLE_TIMEOUT, "10"))); |
There was a problem hiding this comment.
Timeout properties should never be integer values - they need to always be time periods. So "10 secs" is a reasonable default, but we need to parse the property value using FormatUtils.getTimeDuration
There was a problem hiding this comment.
@markap14 After a quick chat with David H. I brought up that FormatUtils is located within nifi-utils which is something stateless doesn't already import. What would be your opinion on including this? If the answer is "don't", how would you recommend converting from strings to Duration?
There was a problem hiding this comment.
So it's okay to bring nifi-utils into nifi-stateless-engine. Definitely not ok to bring it into nifi-stateless-api though. So we should probably have the StatelessEngineConfiguration return a String representation instead of a Duration. Then, do the conversion in the nifi-stateless-engine module where it'll be used.
It probably actually makes sense to move the FormatUtils functionality into nifi-api because there have been other places where it'd be nice to have it available, such as directly in NiFiProperties. But that's beyond the scope of this Jira :) But something to consider for NiFi 2.0
There was a problem hiding this comment.
Thanks for the summary @markap14, the FormatUtils has some deprecated methods that need to be removed for NiFi 2.0, and I could see value in pulling it out of nifi-utils and into nifi-api. In the meantime, it sounds like having the Configuration method return a String value and doing the conversion elsewhere is the best option.
| } | ||
|
|
||
| @Override | ||
| public long getProcessorStartTimeout() { |
There was a problem hiding this comment.
Should take an argument for the TimeUnit to use
| * @return a String representing the number of milliseconds that the process scheduler should wait for a process to start | ||
| * Defaults to 10 seconds or 10_000 milliseconds | ||
| */ | ||
| default long getProcessorStartTimeout() { |
There was a problem hiding this comment.
Should take an argument for the TimeUnit to use
There was a problem hiding this comment.
Using java.time.Duration could provide another more flexible approach that avoids confusion related to time units.
There was a problem hiding this comment.
I would definitely be okay with that as well @exceptionfactory
| * @return a String representing the number of milliseconds that the StatelessEngine should wait for a component to enable | ||
| * Defaults to 10 seconds or 10_000 milliseconds | ||
| */ | ||
| default long getComponentEnableTimeout() { |
There was a problem hiding this comment.
Should take an argument for the TimeUnit to use
| public Builder statelessEngineConfiguration(final StatelessEngineConfiguration statelessEngineConfiguration) { | ||
| this.statelessEngineConfiguration = statelessEngineConfiguration; | ||
| return this; | ||
| } |
There was a problem hiding this comment.
The only thing that we need to pass in here is the timeout - we should avoid passing in the entire StatelessEngineConfiguration and just take in the timeout
|
|
||
| package org.apache.nifi.stateless.flow; | ||
|
|
||
| public class StatelessFlowConfiguration { |
There was a problem hiding this comment.
I don't think this class is necessary. It's simply a wrapper around a long. But a StatelessFlowConfiguration would imply a great deal more configuration. We should instead just provide the timeout to the Stateless Flow
There was a problem hiding this comment.
To justify this and for me to understand the future development strategy, if there were more properties that would/could be configurable, if not this pattern, how would you suggest passing these additional config points?
There was a problem hiding this comment.
Additional config elements can be passed in the constructor as well. Or we could use a Builder. Typically I'd recommend a Builder pattern after about 4-5 constructor args. We could also potentially provide a Configuration type of class like this in the future, if necessary. If this were a public API I think a "config" type of property might make more sense - but we would either want to rename it, or truly encapsulate all of the configuration elements for a Stateless Flow in it. But in this case, it's not a public API, so we can change it any time.
|
|
||
| Duration getStatusTaskInterval(); | ||
|
|
||
| StatelessEngineConfiguration getStatelessEngineConfiguration(); |
There was a problem hiding this comment.
This is unnecessary. It's not used anywhere.
| @Override | ||
| public StatelessEngineConfiguration getStatelessEngineConfiguration() { | ||
| return statelessEngineConfiguration; | ||
| } |
There was a problem hiding this comment.
Method is unnecessary and can be removed.
|
|
||
| package org.apache.nifi.controller; | ||
|
|
||
| public class ProcessSchedulerConfig { |
There was a problem hiding this comment.
Not sure that this class really provides any benefit over providing the timeout directly to the scheduler.
There was a problem hiding this comment.
To justify this and for me to understand the future development strategy, if there were more properties that would/could be configurable, if not this pattern, how would you suggest passing these additional config points?
Add two new properties: nifi.stateless.component.enableTimeout nifi.stateless.processor.startTimeout to allow configuring the StatelessEngine and ProcessScheduler. This allows an operator to configure what kind of startup time the flow can tolerate. Previously these values were hard coded.
Expanding out a getter to 3 lines Removing an extra import
…eTimeout StatelessEngineConfiguration is used in several places and in these additional contexts getProcessorStartTimeout and getComponentEnableTimeout don't really mean anything so adding a default implementation works.
…tainers Directly provide new config parameters to the relevant places instead of wrapping them in extra config containers. At the current level of complexity, they are unnecessary. The builder pattern would be more appropriate and inline with current development. Store the parameter values as strings and convert them to `Duration` values and then finally to the appropriate time scale when required.
|
@markap14 @exceptionfactory I have rebased this branch on the current main and made what I believe are the requested fixes. It appears to build on my end. If you could approve the workflow, I think it'll build successfully here in CI. LMK if you think I've captured what you've asked for. |
|
Thanks @ohnoitsyou changes look good to me. Was able to verify behavior and added and additional system test to verify. +1 merged to both |
NIFI-11471:
Add two new properties:
nifi.stateless.component.enableTimeout
nifi.stateless.processor.startTimeout
to allow configuring the StatelessEngine and ProcessScheduler.
This allows an operator to configure what kind of startup time the flow can tolerate.
Previously these values were hard coded.
Summary
NIFI-11471
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000Pull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation