You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "briansolo1985 (via GitHub)" <gi...@apache.org> on 2024/04/15 13:15:59 UTC
[PR] NIFI-13045 Provide an option to specify the bootstrap listen port [nifi]
briansolo1985 opened a new pull request, #8648:
URL: https://github.com/apache/nifi/pull/8648
<!-- 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-13045](https://issues.apache.org/jira/browse/NIFI-13045)
# Tracking
Please complete the following tracking steps prior to pull request creation.
### Issue Tracking
- [x] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
### Pull Request Tracking
- [x] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
- [x] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
### Pull Request Formatting
- [x] Pull Request based on current revision of the `main` branch
- [x] 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
- [x] Build completed using `mvn clean install -P contrib-check`
- [x] 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-13045 Provide an option to specify the bootstrap listen port [nifi]
Posted by "briansolo1985 (via GitHub)" <gi...@apache.org>.
briansolo1985 commented on code in PR #8648:
URL: https://github.com/apache/nifi/pull/8648#discussion_r1565821713
##########
pom.xml:
##########
@@ -40,7 +40,7 @@
<module>nifi-system-tests</module>
<module>minifi</module>
<module>nifi-stateless</module>
- <module>nifi-registry</module>
+<!-- <module>nifi-registry</module>-->
Review Comment:
Thanks @exceptionfactory. I incidentally pushed that. The reason behind this is that currently the NiFi project project does not build on the main branch due to nifi-registry-ui module failing at the npm ci step.
--
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-13045 Provide an option to specify the bootstrap listen port [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory closed pull request #8648: NIFI-13045 Provide an option to specify the bootstrap listen port
URL: https://github.com/apache/nifi/pull/8648
--
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-13045 Provide an option to specify the bootstrap listen port [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #8648:
URL: https://github.com/apache/nifi/pull/8648#discussion_r1567371606
##########
minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/command/StartRunner.java:
##########
@@ -279,15 +280,33 @@ private void regenerateFlowConfiguration(String flowConfigFileLocation) throws C
}
}
- private Process startMiNiFi() throws IOException {
+ private Process startMiNiFi(BootstrapProperties bootstrapProperties) throws IOException {
+ int bootstrapListenPort = parseBootstrapListenPort(bootstrapProperties);
+
MiNiFiListener listener = new MiNiFiListener();
- listenPort = listener.start(runMiNiFi, bootstrapFileProvider, configurationChangeListener);
+ listenPort = listener.start(runMiNiFi, bootstrapListenPort, bootstrapFileProvider, configurationChangeListener);
CMD_LOGGER.info("Starting Apache MiNiFi...");
return startMiNiFiProcess(getProcessBuilder());
}
+ private int parseBootstrapListenPort(BootstrapProperties bootstrapProperties) {
+ String bootstrapListenPort = bootstrapProperties.getProperty(NIFI_BOOTSTRAP_LISTEN_PORT);
+ if (bootstrapListenPort != null) {
+ try {
+ int port = Integer.parseInt(bootstrapListenPort.trim());
+ CMD_LOGGER.info("Using boostrap listen port {}", port);
+ return port;
+ } catch (Exception e) {
+ CMD_LOGGER.warn("Unable to parse bootstrap listen port, falling back to default (random) port");
+ return 0;
Review Comment:
Instead of logging a warning, it seems like this should throw an `IllegalArgumentException`. The configuration attempted to specify a port number, so starting on a random port is contrary to the configured behavior.
##########
minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/command/StartRunner.java:
##########
@@ -279,15 +280,33 @@ private void regenerateFlowConfiguration(String flowConfigFileLocation) throws C
}
}
- private Process startMiNiFi() throws IOException {
+ private Process startMiNiFi(BootstrapProperties bootstrapProperties) throws IOException {
+ int bootstrapListenPort = parseBootstrapListenPort(bootstrapProperties);
+
MiNiFiListener listener = new MiNiFiListener();
- listenPort = listener.start(runMiNiFi, bootstrapFileProvider, configurationChangeListener);
+ listenPort = listener.start(runMiNiFi, bootstrapListenPort, bootstrapFileProvider, configurationChangeListener);
CMD_LOGGER.info("Starting Apache MiNiFi...");
return startMiNiFiProcess(getProcessBuilder());
}
+ private int parseBootstrapListenPort(BootstrapProperties bootstrapProperties) {
+ String bootstrapListenPort = bootstrapProperties.getProperty(NIFI_BOOTSTRAP_LISTEN_PORT);
+ if (bootstrapListenPort != null) {
+ try {
+ int port = Integer.parseInt(bootstrapListenPort.trim());
+ CMD_LOGGER.info("Using boostrap listen port {}", port);
+ return port;
+ } catch (Exception e) {
+ CMD_LOGGER.warn("Unable to parse bootstrap listen port, falling back to default (random) port");
+ return 0;
+ }
+ }
+ CMD_LOGGER.info("Bootstrap listen port is not provided, falling back to default (random) port");
+ return 0;
Review Comment:
I recommend refactoring this method to have a single return statement.
##########
minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/command/StartRunner.java:
##########
@@ -279,15 +280,33 @@ private void regenerateFlowConfiguration(String flowConfigFileLocation) throws C
}
}
- private Process startMiNiFi() throws IOException {
+ private Process startMiNiFi(BootstrapProperties bootstrapProperties) throws IOException {
+ int bootstrapListenPort = parseBootstrapListenPort(bootstrapProperties);
+
MiNiFiListener listener = new MiNiFiListener();
- listenPort = listener.start(runMiNiFi, bootstrapFileProvider, configurationChangeListener);
+ listenPort = listener.start(runMiNiFi, bootstrapListenPort, bootstrapFileProvider, configurationChangeListener);
CMD_LOGGER.info("Starting Apache MiNiFi...");
return startMiNiFiProcess(getProcessBuilder());
}
+ private int parseBootstrapListenPort(BootstrapProperties bootstrapProperties) {
+ String bootstrapListenPort = bootstrapProperties.getProperty(NIFI_BOOTSTRAP_LISTEN_PORT);
+ if (bootstrapListenPort != null) {
+ try {
+ int port = Integer.parseInt(bootstrapListenPort.trim());
+ CMD_LOGGER.info("Using boostrap listen port {}", port);
+ return port;
+ } catch (Exception e) {
+ CMD_LOGGER.warn("Unable to parse bootstrap listen port, falling back to default (random) port");
+ return 0;
+ }
+ }
+ CMD_LOGGER.info("Bootstrap listen port is not provided, falling back to default (random) port");
Review Comment:
This log seems unnecessary. Perhaps a debug message is useful in some scenarios.
--
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-13045 Provide an option to specify the bootstrap listen port [nifi]
Posted by "briansolo1985 (via GitHub)" <gi...@apache.org>.
briansolo1985 commented on PR #8648:
URL: https://github.com/apache/nifi/pull/8648#issuecomment-2059235219
Incorporated all the review comments, please check the changes.
--
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-13045 Provide an option to specify the bootstrap listen port [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #8648:
URL: https://github.com/apache/nifi/pull/8648#discussion_r1565805911
##########
pom.xml:
##########
@@ -40,7 +40,7 @@
<module>nifi-system-tests</module>
<module>minifi</module>
<module>nifi-stateless</module>
- <module>nifi-registry</module>
+<!-- <module>nifi-registry</module>-->
Review Comment:
This change needs to be reverted.
--
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-13045 Provide an option to specify the bootstrap listen port [nifi]
Posted by "briansolo1985 (via GitHub)" <gi...@apache.org>.
briansolo1985 commented on code in PR #8648:
URL: https://github.com/apache/nifi/pull/8648#discussion_r1565821713
##########
pom.xml:
##########
@@ -40,7 +40,7 @@
<module>nifi-system-tests</module>
<module>minifi</module>
<module>nifi-stateless</module>
- <module>nifi-registry</module>
+<!-- <module>nifi-registry</module>-->
Review Comment:
Thanks @exceptionfactory. I incidentally pushed that. The reason behind this is that currently the NiFi project does not build on the main branch due to nifi-registry-ui module failing at the npm ci step.
--
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-13045 Provide an option to specify the bootstrap listen port [nifi]
Posted by "briansolo1985 (via GitHub)" <gi...@apache.org>.
briansolo1985 commented on PR #8648:
URL: https://github.com/apache/nifi/pull/8648#issuecomment-2061354090
Updated the PR, please check and merge if good to go
--
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-13045 Provide an option to specify the bootstrap listen port [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #8648:
URL: https://github.com/apache/nifi/pull/8648#discussion_r1568893275
##########
minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/command/StartRunner.java:
##########
@@ -279,15 +280,33 @@ private void regenerateFlowConfiguration(String flowConfigFileLocation) throws C
}
}
- private Process startMiNiFi() throws IOException {
+ private Process startMiNiFi(BootstrapProperties bootstrapProperties) throws IOException {
+ int bootstrapListenPort = parseBootstrapListenPort(bootstrapProperties);
+
MiNiFiListener listener = new MiNiFiListener();
- listenPort = listener.start(runMiNiFi, bootstrapFileProvider, configurationChangeListener);
+ listenPort = listener.start(runMiNiFi, bootstrapListenPort, bootstrapFileProvider, configurationChangeListener);
CMD_LOGGER.info("Starting Apache MiNiFi...");
return startMiNiFiProcess(getProcessBuilder());
}
+ private int parseBootstrapListenPort(BootstrapProperties bootstrapProperties) {
+ String bootstrapListenPort = bootstrapProperties.getProperty(NIFI_BOOTSTRAP_LISTEN_PORT);
+ int parsedBootstrapListenPort = Optional.ofNullable(bootstrapListenPort)
+ .map(String::trim)
+ .map(port -> {
+ try {
+ return Integer.parseInt(port);
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("Unable to parse bootstrap listen port, please provide a valid port for " + NIFI_BOOTSTRAP_LISTEN_PORT);
+ }
+ })
+ .orElse(0);
+ CMD_LOGGER.info("Using boostrap listen port {}", parsedBootstrapListenPort);
Review Comment:
Minor spelling correction, wording adjustment recommendation:
```suggestion
CMD_LOGGER.info("Bootstrap listen port {}", parsedBootstrapListenPort);
```
##########
minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/command/StartRunner.java:
##########
@@ -279,15 +280,33 @@ private void regenerateFlowConfiguration(String flowConfigFileLocation) throws C
}
}
- private Process startMiNiFi() throws IOException {
+ private Process startMiNiFi(BootstrapProperties bootstrapProperties) throws IOException {
+ int bootstrapListenPort = parseBootstrapListenPort(bootstrapProperties);
+
MiNiFiListener listener = new MiNiFiListener();
- listenPort = listener.start(runMiNiFi, bootstrapFileProvider, configurationChangeListener);
+ listenPort = listener.start(runMiNiFi, bootstrapListenPort, bootstrapFileProvider, configurationChangeListener);
CMD_LOGGER.info("Starting Apache MiNiFi...");
return startMiNiFiProcess(getProcessBuilder());
}
+ private int parseBootstrapListenPort(BootstrapProperties bootstrapProperties) {
+ String bootstrapListenPort = bootstrapProperties.getProperty(NIFI_BOOTSTRAP_LISTEN_PORT);
+ int parsedBootstrapListenPort = Optional.ofNullable(bootstrapListenPort)
+ .map(String::trim)
+ .map(port -> {
+ try {
+ return Integer.parseInt(port);
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("Unable to parse bootstrap listen port, please provide a valid port for " + NIFI_BOOTSTRAP_LISTEN_PORT);
Review Comment:
Minor adjustment, recommend capitalizing Bootstrap:
```suggestion
throw new IllegalArgumentException("Unable to parse Bootstrap listen port, please provide a valid port for " + NIFI_BOOTSTRAP_LISTEN_PORT);
```
--
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-13045 Provide an option to specify the bootstrap listen port [nifi]
Posted by "briansolo1985 (via GitHub)" <gi...@apache.org>.
briansolo1985 commented on code in PR #8648:
URL: https://github.com/apache/nifi/pull/8648#discussion_r1565821713
##########
pom.xml:
##########
@@ -40,7 +40,7 @@
<module>nifi-system-tests</module>
<module>minifi</module>
<module>nifi-stateless</module>
- <module>nifi-registry</module>
+<!-- <module>nifi-registry</module>-->
Review Comment:
Thanks @exceptionfactory. I accidentally pushed that. The reason behind this is that currently the NiFi project does not build on the main branch due to nifi-registry-ui module failing at the npm ci step.
--
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