You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "ferencerdei (via GitHub)" <gi...@apache.org> on 2023/11/08 14:19:31 UTC

[PR] NIFI-12335 Fix MiNiFi startup issue [nifi]

ferencerdei opened a new pull request, #7998:
URL: https://github.com/apache/nifi/pull/7998

   <!-- Licensed to the Apache Software Foundation (ASF) under one or more -->
   <!-- contributor license agreements.  See the NOTICE file distributed with -->
   <!-- this work for additional information regarding copyright ownership. -->
   <!-- The ASF licenses this file to You under the Apache License, Version 2.0 -->
   <!-- (the "License"); you may not use this file except in compliance with -->
   <!-- the License.  You may obtain a copy of the License at -->
   <!--     http://www.apache.org/licenses/LICENSE-2.0 -->
   <!-- Unless required by applicable law or agreed to in writing, software -->
   <!-- distributed under the License is distributed on an "AS IS" BASIS, -->
   <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
   <!-- See the License for the specific language governing permissions and -->
   <!-- limitations under the License. -->
   
   # Summary
   
   [NIFI-12335](https://issues.apache.org/jira/browse/NIFI-12335)
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [ ] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### Pull Request Tracking
   
   - [ ] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
   - [ ] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
   
   ### Pull Request Formatting
   
   - [ ] Pull Request based on current revision of the `main` branch
   - [ ] Pull Request refers to a feature branch with one commit containing changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request creation.
   
   ### Build
   
   - [ ] Build completed using `mvn clean install -P contrib-check`
     - [ ] JDK 21
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-12335 Fix MiNiFi startup issue [nifi]

Posted by "ferencerdei (via GitHub)" <gi...@apache.org>.
ferencerdei commented on code in PR #7998:
URL: https://github.com/apache/nifi/pull/7998#discussion_r1386754850


##########
minifi/minifi-commons/minifi-commons-framework/src/main/java/org/apache/nifi/minifi/commons/service/FlowEnrichService.java:
##########
@@ -103,10 +107,12 @@ public byte[] enrichFlow(byte[] flowCandidate) {
             rootGroup.setInstanceIdentifier(randomUUID().toString());
         }
 
+        rootGroup.getControllerServices().forEach(cs -> cs.setScheduledState(ENABLED));
+
         Optional<VersionedControllerService> commonSslControllerService = createCommonSslControllerService();
         commonSslControllerService
             .ifPresent(sslControllerService -> {
-                List<VersionedControllerService> currentControllerServices = ofNullable(versionedDataflow.getControllerServices()).orElseGet(ArrayList::new);
+                List<VersionedControllerService> currentControllerServices = new ArrayList<>(versionedDataflow.getControllerServices());

Review Comment:
   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.



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-12335 Fix MiNiFi startup issue [nifi]

Posted by "bejancsaba (via GitHub)" <gi...@apache.org>.
bejancsaba closed pull request #7998: NIFI-12335 Fix MiNiFi startup issue
URL: https://github.com/apache/nifi/pull/7998


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-12335 Fix MiNiFi startup issue [nifi]

Posted by "ferencerdei (via GitHub)" <gi...@apache.org>.
ferencerdei commented on code in PR #7998:
URL: https://github.com/apache/nifi/pull/7998#discussion_r1386724790


##########
minifi/minifi-commons/minifi-commons-framework/src/main/java/org/apache/nifi/minifi/commons/service/FlowEnrichService.java:
##########
@@ -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));

Review Comment:
   For ParameterProviders and FlowAnalysisRules it is handled in the VersionedFlowSynchronizer



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-12335 Fix MiNiFi startup issue [nifi]

Posted by "bejancsaba (via GitHub)" <gi...@apache.org>.
bejancsaba commented on code in PR #7998:
URL: https://github.com/apache/nifi/pull/7998#discussion_r1386713417


##########
minifi/minifi-commons/minifi-commons-framework/src/main/java/org/apache/nifi/minifi/commons/service/FlowEnrichService.java:
##########
@@ -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));

Review Comment:
   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



##########
minifi/minifi-commons/minifi-commons-framework/src/main/java/org/apache/nifi/minifi/commons/service/FlowEnrichService.java:
##########
@@ -103,10 +107,12 @@ public byte[] enrichFlow(byte[] flowCandidate) {
             rootGroup.setInstanceIdentifier(randomUUID().toString());
         }
 
+        rootGroup.getControllerServices().forEach(cs -> cs.setScheduledState(ENABLED));

Review Comment:
   This seems unrelated to the startup issue, is this specific to NiFi 2.0?



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-12335 Fix MiNiFi startup issue [nifi]

Posted by "briansolo1985 (via GitHub)" <gi...@apache.org>.
briansolo1985 commented on code in PR #7998:
URL: https://github.com/apache/nifi/pull/7998#discussion_r1386715480


##########
minifi/minifi-commons/minifi-commons-framework/src/main/java/org/apache/nifi/minifi/commons/service/FlowEnrichService.java:
##########
@@ -103,10 +107,12 @@ public byte[] enrichFlow(byte[] flowCandidate) {
             rootGroup.setInstanceIdentifier(randomUUID().toString());
         }
 
+        rootGroup.getControllerServices().forEach(cs -> cs.setScheduledState(ENABLED));

Review Comment:
   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.



##########
minifi/minifi-commons/minifi-commons-framework/src/main/java/org/apache/nifi/minifi/commons/service/FlowEnrichService.java:
##########
@@ -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());

Review Comment:
   And this one also could be simplified
   ```
   createProvenanceReportingTask(commonSslControllerService.map(VersionedComponent::getInstanceIdentifier).orElse(EMPTY))
               .ifPresent(versionedDataflow.getReportingTasks()::add);
   ```



##########
minifi/minifi-commons/minifi-commons-framework/src/main/java/org/apache/nifi/minifi/commons/service/FlowEnrichService.java:
##########
@@ -103,10 +107,12 @@ public byte[] enrichFlow(byte[] flowCandidate) {
             rootGroup.setInstanceIdentifier(randomUUID().toString());
         }
 
+        rootGroup.getControllerServices().forEach(cs -> cs.setScheduledState(ENABLED));
+
         Optional<VersionedControllerService> commonSslControllerService = createCommonSslControllerService();
         commonSslControllerService
             .ifPresent(sslControllerService -> {
-                List<VersionedControllerService> currentControllerServices = ofNullable(versionedDataflow.getControllerServices()).orElseGet(ArrayList::new);
+                List<VersionedControllerService> currentControllerServices = new ArrayList<>(versionedDataflow.getControllerServices());

Review Comment:
   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);
   ```



##########
minifi/minifi-commons/minifi-commons-framework/src/main/java/org/apache/nifi/minifi/commons/service/FlowEnrichService.java:
##########
@@ -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;

Review Comment:
   Could we use the static import in line 159 as well?



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-12335 Fix MiNiFi startup issue [nifi]

Posted by "ferencerdei (via GitHub)" <gi...@apache.org>.
ferencerdei commented on code in PR #7998:
URL: https://github.com/apache/nifi/pull/7998#discussion_r1386728669


##########
minifi/minifi-commons/minifi-commons-framework/src/main/java/org/apache/nifi/minifi/commons/service/FlowEnrichService.java:
##########
@@ -103,10 +107,12 @@ public byte[] enrichFlow(byte[] flowCandidate) {
             rootGroup.setInstanceIdentifier(randomUUID().toString());
         }
 
+        rootGroup.getControllerServices().forEach(cs -> cs.setScheduledState(ENABLED));

Review Comment:
   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.



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-12335 Fix MiNiFi startup issue [nifi]

Posted by "bejancsaba (via GitHub)" <gi...@apache.org>.
bejancsaba commented on PR #7998:
URL: https://github.com/apache/nifi/pull/7998#issuecomment-1802233628

   Thanks for the details and the changes will merge as soon as the workflows conclude. +1 from my side


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org