diff --git a/minifi/minifi-assembly/pom.xml b/minifi/minifi-assembly/pom.xml index 2dec9d7a69..975b554645 100644 --- a/minifi/minifi-assembly/pom.xml +++ b/minifi/minifi-assembly/pom.xml @@ -105,6 +105,10 @@ limitations under the License. runtime zip + + org.apache.nifi + nifi-bootstrap-utils + org.apache.nifi.minifi minifi-bootstrap diff --git a/minifi/minifi-assembly/src/main/assembly/dependencies-windows-service.xml b/minifi/minifi-assembly/src/main/assembly/dependencies-windows-service.xml index 022beab372..8e28643fea 100644 --- a/minifi/minifi-assembly/src/main/assembly/dependencies-windows-service.xml +++ b/minifi/minifi-assembly/src/main/assembly/dependencies-windows-service.xml @@ -33,6 +33,7 @@ 0660 true + nifi-bootstrap-utils minifi-bootstrap minifi-resources @@ -61,6 +62,7 @@ 0660 true + nifi-bootstrap-utils minifi-bootstrap minifi-utils nifi-utils diff --git a/minifi/minifi-assembly/src/main/assembly/dependencies.xml b/minifi/minifi-assembly/src/main/assembly/dependencies.xml index 2f6b2f4c43..5bdb6da659 100644 --- a/minifi/minifi-assembly/src/main/assembly/dependencies.xml +++ b/minifi/minifi-assembly/src/main/assembly/dependencies.xml @@ -33,6 +33,7 @@ 0660 true + nifi-bootstrap-utils minifi-bootstrap minifi-resources @@ -61,6 +62,7 @@ 0660 true + nifi-bootstrap-utils minifi-bootstrap minifi-utils nifi-utils diff --git a/minifi/minifi-bootstrap/pom.xml b/minifi/minifi-bootstrap/pom.xml index 3c40efbada..7293486816 100644 --- a/minifi/minifi-bootstrap/pom.xml +++ b/minifi/minifi-bootstrap/pom.xml @@ -40,6 +40,10 @@ limitations under the License. nifi-api compile + + org.apache.nifi + nifi-bootstrap-utils + org.apache.nifi nifi-processor-utils diff --git a/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/RunMiNiFi.java b/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/RunMiNiFi.java index 5d0951ac44..e9931d9f9e 100644 --- a/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/RunMiNiFi.java +++ b/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/RunMiNiFi.java @@ -18,6 +18,7 @@ package org.apache.nifi.minifi.bootstrap; import org.apache.commons.io.input.TeeInputStream; import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.bootstrap.util.OSUtils; import org.apache.nifi.minifi.bootstrap.configuration.ConfigurationChangeCoordinator; import org.apache.nifi.minifi.bootstrap.configuration.ConfigurationChangeException; import org.apache.nifi.minifi.bootstrap.configuration.ConfigurationChangeListener; @@ -44,7 +45,6 @@ import java.io.InputStreamReader; import java.io.ObjectInputStream; import java.io.OutputStream; import java.io.Reader; -import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -1155,7 +1155,7 @@ public class RunMiNiFi implements QueryableStatusAggregator, ConfigurationFileHo Process process = builder.start(); handleLogging(process); - Long pid = getPid(process, cmdLogger); + Long pid = OSUtils.getProcessId(process, cmdLogger); if (pid != null) { minifiPid = pid; final Properties minifiProps = new Properties(); @@ -1293,7 +1293,7 @@ public class RunMiNiFi implements QueryableStatusAggregator, ConfigurationFileHo process = builder.start(); handleLogging(process); - Long pid = getPid(process, defaultLogger); + Long pid = OSUtils.getProcessId(process, defaultLogger); if (pid != null) { minifiPid = pid; final Properties minifiProps = new Properties(); @@ -1400,25 +1400,6 @@ public class RunMiNiFi implements QueryableStatusAggregator, ConfigurationFileHo this.loggingFutures = futures; } - private Long getPid(final Process process, final Logger logger) { - try { - final Class procClass = process.getClass(); - final Field pidField = procClass.getDeclaredField(PID_KEY); - pidField.setAccessible(true); - final Object pidObject = pidField.get(process); - - logger.debug("PID Object = {}", pidObject); - - if (pidObject instanceof Number) { - return ((Number) pidObject).longValue(); - } - return null; - } catch (final IllegalAccessException | NoSuchFieldException nsfe) { - logger.debug("Could not find PID for child process due to {}", nsfe); - return null; - } - } - private boolean isWindows() { final String osName = System.getProperty("os.name"); return osName != null && osName.toLowerCase().contains("win"); diff --git a/minifi/pom.xml b/minifi/pom.xml index bcc37b838f..6e3e2b04a4 100644 --- a/minifi/pom.xml +++ b/minifi/pom.xml @@ -118,6 +118,11 @@ limitations under the License. + + org.apache.nifi + nifi-bootstrap-utils + 1.14.0-SNAPSHOT + org.apache.nifi.minifi minifi-bootstrap diff --git a/nifi-assembly/pom.xml b/nifi-assembly/pom.xml index b88c6a1b4d..8c62dcbac2 100644 --- a/nifi-assembly/pom.xml +++ b/nifi-assembly/pom.xml @@ -116,6 +116,11 @@ language governing permissions and limitations under the License. --> nifi-bootstrap 1.14.0-SNAPSHOT + + org.apache.nifi + nifi-bootstrap-utils + 1.14.0-SNAPSHOT + org.apache.nifi nifi-resources @@ -1178,6 +1183,7 @@ language governing permissions and limitations under the License. --> javax.mail:mail org.apache.nifi:nifi-bootstrap + org.apache.nifi:nifi-bootstrap-utils org.apache.nifi:nifi-expression-language org.apache.nifi:nifi-parameter org.apache.nifi:nifi-processor-utils @@ -1237,6 +1243,7 @@ language governing permissions and limitations under the License. --> javax.mail:mail org.apache.nifi:nifi-api org.apache.nifi:nifi-bootstrap + org.apache.nifi:nifi-bootstrap-utils org.apache.nifi:nifi-expression-language org.apache.nifi:nifi-parameter org.apache.nifi:nifi-processor-utils diff --git a/nifi-assembly/src/main/assembly/common.xml b/nifi-assembly/src/main/assembly/common.xml index d62eac9f5f..45e3c933fb 100644 --- a/nifi-assembly/src/main/assembly/common.xml +++ b/nifi-assembly/src/main/assembly/common.xml @@ -24,6 +24,7 @@ 0664 true + nifi-bootstrap-utils nifi-bootstrap slf4j-api logback-classic diff --git a/nifi-assembly/src/main/assembly/dependencies.xml b/nifi-assembly/src/main/assembly/dependencies.xml index 3d8cfd92f0..6f48841e33 100644 --- a/nifi-assembly/src/main/assembly/dependencies.xml +++ b/nifi-assembly/src/main/assembly/dependencies.xml @@ -32,6 +32,7 @@ 0664 true + nifi-bootstrap-utils nifi-bootstrap nifi-resources nifi-docs diff --git a/nifi-assembly/src/main/assembly/ranger.xml b/nifi-assembly/src/main/assembly/ranger.xml index 8b28191039..531ca309ec 100644 --- a/nifi-assembly/src/main/assembly/ranger.xml +++ b/nifi-assembly/src/main/assembly/ranger.xml @@ -37,6 +37,7 @@ 0660 true + nifi-bootstrap-utils nifi-bootstrap nifi-resources nifi-docs diff --git a/nifi-bootstrap/pom.xml b/nifi-bootstrap/pom.xml index 68663855bd..6e282a545a 100644 --- a/nifi-bootstrap/pom.xml +++ b/nifi-bootstrap/pom.xml @@ -30,6 +30,11 @@ language governing permissions and limitations under the License. --> 1.14.0-SNAPSHOT compile + + org.apache.nifi + nifi-bootstrap-utils + 1.14.0-SNAPSHOT + org.apache.nifi nifi-utils @@ -74,11 +79,6 @@ language governing permissions and limitations under the License. --> nifi-properties-loader 1.14.0-SNAPSHOT - - net.java.dev.jna - jna-platform - 4.4.0 - ch.qos.logback logback-classic diff --git a/nifi-commons/nifi-bootstrap-utils/pom.xml b/nifi-commons/nifi-bootstrap-utils/pom.xml new file mode 100644 index 0000000000..8c7b2a333a --- /dev/null +++ b/nifi-commons/nifi-bootstrap-utils/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + + org.apache.nifi + nifi-commons + 1.14.0-SNAPSHOT + + nifi-bootstrap-utils + jar + + + + org.slf4j + slf4j-api + + + + net.java.dev.jna + jna-platform + 4.4.0 + + + + ch.qos.logback + logback-classic + test + + + diff --git a/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/util/OSUtils.java b/nifi-commons/nifi-bootstrap-utils/src/main/java/org/apache/nifi/bootstrap/util/OSUtils.java similarity index 100% rename from nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/util/OSUtils.java rename to nifi-commons/nifi-bootstrap-utils/src/main/java/org/apache/nifi/bootstrap/util/OSUtils.java diff --git a/nifi-bootstrap/src/test/java/org/apache/nifi/bootstrap/http/OSUtilsTest.java b/nifi-commons/nifi-bootstrap-utils/src/test/java/org/apache/nifi/bootstrap/util/OSUtilsTest.java similarity index 95% rename from nifi-bootstrap/src/test/java/org/apache/nifi/bootstrap/http/OSUtilsTest.java rename to nifi-commons/nifi-bootstrap-utils/src/test/java/org/apache/nifi/bootstrap/util/OSUtilsTest.java index 89a9dbc6ba..5a8abe957e 100644 --- a/nifi-bootstrap/src/test/java/org/apache/nifi/bootstrap/http/OSUtilsTest.java +++ b/nifi-commons/nifi-bootstrap-utils/src/test/java/org/apache/nifi/bootstrap/util/OSUtilsTest.java @@ -14,9 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.nifi.bootstrap.http; +package org.apache.nifi.bootstrap.util; -import org.apache.nifi.bootstrap.util.OSUtils; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/nifi-commons/pom.xml b/nifi-commons/pom.xml index c66973e854..7bda15b889 100644 --- a/nifi-commons/pom.xml +++ b/nifi-commons/pom.xml @@ -24,6 +24,7 @@ nifi-commons pom + nifi-bootstrap-utils nifi-data-provenance-utils nifi-expression-language nifi-flowfile-packager diff --git a/nifi-external/nifi-kafka-connect/nifi-kafka-connector-assembly/src/main/assembly/dependencies.xml b/nifi-external/nifi-kafka-connect/nifi-kafka-connector-assembly/src/main/assembly/dependencies.xml index 7207607952..1ce7f189b0 100644 --- a/nifi-external/nifi-kafka-connect/nifi-kafka-connector-assembly/src/main/assembly/dependencies.xml +++ b/nifi-external/nifi-kafka-connect/nifi-kafka-connector-assembly/src/main/assembly/dependencies.xml @@ -28,6 +28,7 @@ 0664 true + nifi-bootstrap-utils nifi-bootstrap nifi-resources nifi-docs diff --git a/nifi-external/nifi-kafka-connect/nifi-kafka-connector-tests/src/main/assembly/dependencies.xml b/nifi-external/nifi-kafka-connect/nifi-kafka-connector-tests/src/main/assembly/dependencies.xml index 00970f8083..b6312781b8 100644 --- a/nifi-external/nifi-kafka-connect/nifi-kafka-connector-tests/src/main/assembly/dependencies.xml +++ b/nifi-external/nifi-kafka-connect/nifi-kafka-connector-tests/src/main/assembly/dependencies.xml @@ -28,6 +28,7 @@ 0664 true + nifi-bootstrap-utils nifi-bootstrap nifi-resources nifi-docs diff --git a/nifi-system-tests/nifi-system-test-suite/pom.xml b/nifi-system-tests/nifi-system-test-suite/pom.xml index 50d478b64a..9fd0dde7ca 100644 --- a/nifi-system-tests/nifi-system-test-suite/pom.xml +++ b/nifi-system-tests/nifi-system-test-suite/pom.xml @@ -150,6 +150,11 @@ nifi-runtime 1.14.0-SNAPSHOT + + org.apache.nifi + nifi-bootstrap-utils + 1.14.0-SNAPSHOT + org.apache.nifi nifi-bootstrap diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/assembly/dependencies.xml b/nifi-system-tests/nifi-system-test-suite/src/test/assembly/dependencies.xml index 1c1b90a792..8f30238e67 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/assembly/dependencies.xml +++ b/nifi-system-tests/nifi-system-test-suite/src/test/assembly/dependencies.xml @@ -29,6 +29,7 @@ 0664 true + nifi-bootstrap-utils nifi-bootstrap slf4j-api nifi-api @@ -62,6 +63,7 @@ 0664 true + nifi-bootstrap-utils nifi-bootstrap nifi-resources nifi-docs