-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NIFI-12335 Fix MiNiFi startup issue #7998
NIFI-12335 Fix MiNiFi startup issue #7998
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good thanks for the change I had 2 quick questions.
@@ -90,6 +91,9 @@ public byte[] enrichFlow(byte[] flowCandidate) { | |||
} | |||
|
|||
VersionedDataflow versionedDataflow = parseVersionedDataflow(flowCandidate); | |||
versionedDataflow.setReportingTasks(ofNullable(versionedDataflow.getReportingTasks()).orElseGet(ArrayList::new)); | |||
versionedDataflow.setRegistries(ofNullable(versionedDataflow.getRegistries()).orElseGet(ArrayList::new)); | |||
versionedDataflow.setControllerServices(ofNullable(versionedDataflow.getControllerServices()).orElseGet(ArrayList::new)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to do this for the others (e.g.: parameters) as well or only these are needed to be initialised on case of an empty flow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For ParameterProviders and FlowAnalysisRules it is handled in the VersionedFlowSynchronizer
@@ -103,10 +107,12 @@ public byte[] enrichFlow(byte[] flowCandidate) { | |||
rootGroup.setInstanceIdentifier(randomUUID().toString()); | |||
} | |||
|
|||
rootGroup.getControllerServices().forEach(cs -> cs.setScheduledState(ENABLED)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unrelated to the startup issue, is this specific to NiFi 2.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also caused issues because the controller services were not enabled automatically so I got validation errors. I forgot to mention this in the ticket. Because it makes no sense to disable separate components in the context of MiNiFi, I think it's safe to always enable everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Ferenc, thank you for this change. The approach looks good, and will make this part of the code more fault tolerant.
Wrote some comments please take a look when you'll have the time.
@@ -103,10 +107,12 @@ public byte[] enrichFlow(byte[] flowCandidate) { | |||
rootGroup.setInstanceIdentifier(randomUUID().toString()); | |||
} | |||
|
|||
rootGroup.getControllerServices().forEach(cs -> cs.setScheduledState(ENABLED)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor, but in my opinion lamdbas are more expresseive if meaningiful parameter names are used, in this case I would use controllerService, but leave it you.
Optional<VersionedControllerService> commonSslControllerService = createCommonSslControllerService(); | ||
commonSslControllerService | ||
.ifPresent(sslControllerService -> { | ||
List<VersionedControllerService> currentControllerServices = ofNullable(versionedDataflow.getControllerServices()).orElseGet(ArrayList::new); | ||
List<VersionedControllerService> currentControllerServices = new ArrayList<>(versionedDataflow.getControllerServices()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the initialization was moved outside now it is guaranteed that we will get a non-null list object here.
Is it necessary to recreate the list object for some reasons?
If not we could simplify the ifPresent block by reducing it to
commonSslControllerService.ifPresent(versionedDataflow.getControllerServices()::add);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to avoid passing the reference for the original list, but maybe you are right. As this object doesn't exist outside of this class we can safely use the value directly. I'm going to update this and the other as well.
@@ -118,7 +124,7 @@ public byte[] enrichFlow(byte[] flowCandidate) { | |||
|
|||
createProvenanceReportingTask(commonSslControllerService.map(VersionedComponent::getInstanceIdentifier).orElse(EMPTY)) | |||
.ifPresent(provenanceReportingTask -> { | |||
List<VersionedReportingTask> currentReportingTasks = ofNullable(versionedDataflow.getReportingTasks()).orElseGet(ArrayList::new); | |||
List<VersionedReportingTask> currentReportingTasks = new ArrayList<>(versionedDataflow.getReportingTasks()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one also could be simplified
createProvenanceReportingTask(commonSslControllerService.map(VersionedComponent::getInstanceIdentifier).orElse(EMPTY))
.ifPresent(versionedDataflow.getReportingTasks()::add);
@@ -26,6 +26,7 @@ | |||
import static java.util.UUID.randomUUID; | |||
import static java.util.stream.Collectors.toMap; | |||
import static org.apache.commons.lang3.StringUtils.EMPTY; | |||
import static org.apache.nifi.flow.ScheduledState.ENABLED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use the static import in line 159 as well?
Thanks for the details and the changes will merge as soon as the workflows conclude. +1 from my side |
Summary
NIFI-12335
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000
NIFI-00000
Pull Request Formatting
main
branchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-check
Licensing
LICENSE
andNOTICE
filesDocumentation