You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ex...@apache.org on 2021/05/10 13:39:40 UTC

[nifi] branch main updated: MINIFI-554: Move OSUtils to nifi-bootstrap-utils for MiNiFi and NiFi

This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 284322f  MINIFI-554: Move OSUtils to nifi-bootstrap-utils for MiNiFi and NiFi
284322f is described below

commit 284322feede8387b3a05038ef61fffb7ce54a176
Author: Matthew Burgess <ma...@apache.org>
AuthorDate: Fri May 7 14:35:41 2021 -0400

    MINIFI-554: Move OSUtils to nifi-bootstrap-utils for MiNiFi and NiFi
    
    This closes #5062
    
    Signed-off-by: David Handermann <ex...@apache.org>
---
 minifi/minifi-assembly/pom.xml                     |  4 +++
 .../main/assembly/dependencies-windows-service.xml |  2 ++
 .../src/main/assembly/dependencies.xml             |  2 ++
 minifi/minifi-bootstrap/pom.xml                    |  4 +++
 .../apache/nifi/minifi/bootstrap/RunMiNiFi.java    | 25 ++-----------
 minifi/pom.xml                                     |  5 +++
 nifi-assembly/pom.xml                              |  7 ++++
 nifi-assembly/src/main/assembly/common.xml         |  1 +
 nifi-assembly/src/main/assembly/dependencies.xml   |  1 +
 nifi-assembly/src/main/assembly/ranger.xml         |  1 +
 nifi-bootstrap/pom.xml                             | 10 +++---
 nifi-commons/nifi-bootstrap-utils/pom.xml          | 41 ++++++++++++++++++++++
 .../org/apache/nifi/bootstrap/util/OSUtils.java    |  0
 .../apache/nifi/bootstrap/util}/OSUtilsTest.java   |  3 +-
 nifi-commons/pom.xml                               |  1 +
 .../src/main/assembly/dependencies.xml             |  1 +
 .../src/main/assembly/dependencies.xml             |  1 +
 nifi-system-tests/nifi-system-test-suite/pom.xml   |  5 +++
 .../src/test/assembly/dependencies.xml             |  2 ++
 19 files changed, 87 insertions(+), 29 deletions(-)

diff --git a/minifi/minifi-assembly/pom.xml b/minifi/minifi-assembly/pom.xml
index 2dec9d7..975b554 100644
--- a/minifi/minifi-assembly/pom.xml
+++ b/minifi/minifi-assembly/pom.xml
@@ -106,6 +106,10 @@ limitations under the License.
             <type>zip</type>
         </dependency>
         <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-bootstrap-utils</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.apache.nifi.minifi</groupId>
             <artifactId>minifi-bootstrap</artifactId>
         </dependency>
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 022beab..8e28643 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 @@
             <fileMode>0660</fileMode>
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <excludes>
+                <exclude>nifi-bootstrap-utils</exclude>
                 <exclude>minifi-bootstrap</exclude>
                 <exclude>minifi-resources</exclude>
                 <!-- Filter items introduced via transitive dependencies that are provided in associated NARs -->
@@ -61,6 +62,7 @@
             <fileMode>0660</fileMode>
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <includes>
+                <include>nifi-bootstrap-utils</include>
                 <include>minifi-bootstrap</include>
                 <include>minifi-utils</include>
                 <include>nifi-utils</include>
diff --git a/minifi/minifi-assembly/src/main/assembly/dependencies.xml b/minifi/minifi-assembly/src/main/assembly/dependencies.xml
index 2f6b2f4..5bdb6da 100644
--- a/minifi/minifi-assembly/src/main/assembly/dependencies.xml
+++ b/minifi/minifi-assembly/src/main/assembly/dependencies.xml
@@ -33,6 +33,7 @@
             <fileMode>0660</fileMode>
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <excludes>
+                <exclude>nifi-bootstrap-utils</exclude>
                 <exclude>minifi-bootstrap</exclude>
                 <exclude>minifi-resources</exclude>
                 <!-- Filter items introduced via transitive dependencies that are provided in associated NARs -->
@@ -61,6 +62,7 @@
             <fileMode>0660</fileMode>
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <includes>
+                <include>nifi-bootstrap-utils</include>
                 <include>minifi-bootstrap</include>
                 <include>minifi-utils</include>
                 <include>nifi-utils</include>
diff --git a/minifi/minifi-bootstrap/pom.xml b/minifi/minifi-bootstrap/pom.xml
index 3c40efb..7293486 100644
--- a/minifi/minifi-bootstrap/pom.xml
+++ b/minifi/minifi-bootstrap/pom.xml
@@ -42,6 +42,10 @@ limitations under the License.
         </dependency>
         <dependency>
             <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-bootstrap-utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-processor-utils</artifactId>
         </dependency>
         <dependency>
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 5d0951a..e9931d9 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 bcc37b8..6e3e2b0 100644
--- a/minifi/pom.xml
+++ b/minifi/pom.xml
@@ -119,6 +119,11 @@ limitations under the License.
     <dependencyManagement>
         <dependencies>
             <dependency>
+                <groupId>org.apache.nifi</groupId>
+                <artifactId>nifi-bootstrap-utils</artifactId>
+                <version>1.14.0-SNAPSHOT</version>
+            </dependency>
+            <dependency>
                 <groupId>org.apache.nifi.minifi</groupId>
                 <artifactId>minifi-bootstrap</artifactId>
                 <version>1.14.0-SNAPSHOT</version>
diff --git a/nifi-assembly/pom.xml b/nifi-assembly/pom.xml
index b88c6a1..8c62dcb 100644
--- a/nifi-assembly/pom.xml
+++ b/nifi-assembly/pom.xml
@@ -118,6 +118,11 @@ language governing permissions and limitations under the License. -->
         </dependency>
         <dependency>
             <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-bootstrap-utils</artifactId>
+            <version>1.14.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-resources</artifactId>
             <classifier>resources</classifier>
             <version>1.14.0-SNAPSHOT</version>
@@ -1178,6 +1183,7 @@ language governing permissions and limitations under the License. -->
                                                     <exclude>javax.mail:mail</exclude>
                                                     <!-- must be in lib <exclude>org.apache.nifi:nifi-api</exclude> -->
                                                     <exclude>org.apache.nifi:nifi-bootstrap</exclude>
+                                                    <exclude>org.apache.nifi:nifi-bootstrap-utils</exclude>
                                                     <exclude>org.apache.nifi:nifi-expression-language</exclude>
                                                     <exclude>org.apache.nifi:nifi-parameter</exclude>
                                                     <exclude>org.apache.nifi:nifi-processor-utils</exclude>
@@ -1237,6 +1243,7 @@ language governing permissions and limitations under the License. -->
                                                     <include>javax.mail:mail</include>
                                                     <include>org.apache.nifi:nifi-api</include>
                                                     <include>org.apache.nifi:nifi-bootstrap</include>
+                                                    <include>org.apache.nifi:nifi-bootstrap-utils</include>
                                                     <include>org.apache.nifi:nifi-expression-language</include>
                                                     <include>org.apache.nifi:nifi-parameter</include>
                                                     <include>org.apache.nifi:nifi-processor-utils</include>
diff --git a/nifi-assembly/src/main/assembly/common.xml b/nifi-assembly/src/main/assembly/common.xml
index d62eac9..45e3c93 100644
--- a/nifi-assembly/src/main/assembly/common.xml
+++ b/nifi-assembly/src/main/assembly/common.xml
@@ -24,6 +24,7 @@
             <fileMode>0664</fileMode>
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <includes>
+                <include>nifi-bootstrap-utils</include>
                 <include>nifi-bootstrap</include>
                 <include>slf4j-api</include>
                 <include>logback-classic</include>
diff --git a/nifi-assembly/src/main/assembly/dependencies.xml b/nifi-assembly/src/main/assembly/dependencies.xml
index 3d8cfd9..6f48841 100644
--- a/nifi-assembly/src/main/assembly/dependencies.xml
+++ b/nifi-assembly/src/main/assembly/dependencies.xml
@@ -32,6 +32,7 @@
             <fileMode>0664</fileMode>
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <excludes>
+                <exclude>nifi-bootstrap-utils</exclude>
                 <exclude>nifi-bootstrap</exclude>
                 <exclude>nifi-resources</exclude>
                 <exclude>nifi-docs</exclude>
diff --git a/nifi-assembly/src/main/assembly/ranger.xml b/nifi-assembly/src/main/assembly/ranger.xml
index 8b28191..531ca30 100644
--- a/nifi-assembly/src/main/assembly/ranger.xml
+++ b/nifi-assembly/src/main/assembly/ranger.xml
@@ -37,6 +37,7 @@
             <fileMode>0660</fileMode>
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <excludes>
+                <exclude>nifi-bootstrap-utils</exclude>
                 <exclude>nifi-bootstrap</exclude>
                 <exclude>nifi-resources</exclude>
                 <exclude>nifi-docs</exclude>
diff --git a/nifi-bootstrap/pom.xml b/nifi-bootstrap/pom.xml
index 6866385..6e282a5 100644
--- a/nifi-bootstrap/pom.xml
+++ b/nifi-bootstrap/pom.xml
@@ -32,6 +32,11 @@ language governing permissions and limitations under the License. -->
         </dependency>
         <dependency>
             <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-bootstrap-utils</artifactId>
+            <version>1.14.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-utils</artifactId>
             <version>1.14.0-SNAPSHOT</version>
         </dependency>
@@ -75,11 +80,6 @@ language governing permissions and limitations under the License. -->
             <version>1.14.0-SNAPSHOT</version>
         </dependency>
         <dependency>
-            <groupId>net.java.dev.jna</groupId>
-            <artifactId>jna-platform</artifactId>
-            <version>4.4.0</version>
-        </dependency>
-        <dependency>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-classic</artifactId>
             <scope>test</scope>
diff --git a/nifi-commons/nifi-bootstrap-utils/pom.xml b/nifi-commons/nifi-bootstrap-utils/pom.xml
new file mode 100644
index 0000000..8c7b2a3
--- /dev/null
+++ b/nifi-commons/nifi-bootstrap-utils/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-commons</artifactId>
+        <version>1.14.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>nifi-bootstrap-utils</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <!-- This needs to be here because it is relied upon by the nifi-runtime which starts NiFi.  It uses this bootstrap module
+        and the libs that get laid down in lib/bootstrap to create a child classloader with these bits in it -->
+        <dependency>
+            <groupId>net.java.dev.jna</groupId>
+            <artifactId>jna-platform</artifactId>
+            <version>4.4.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
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 89a9dbc..5a8abe9 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 c66973e..7bda15b 100644
--- a/nifi-commons/pom.xml
+++ b/nifi-commons/pom.xml
@@ -24,6 +24,7 @@
     <artifactId>nifi-commons</artifactId>
     <packaging>pom</packaging>
     <modules>
+        <module>nifi-bootstrap-utils</module>
         <module>nifi-data-provenance-utils</module>
         <module>nifi-expression-language</module>
         <module>nifi-flowfile-packager</module>
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 7207607..1ce7f18 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 @@
             <fileMode>0664</fileMode>
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <excludes>
+                <exclude>nifi-bootstrap-utils</exclude>
                 <exclude>nifi-bootstrap</exclude>
                 <exclude>nifi-resources</exclude>
                 <exclude>nifi-docs</exclude>
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 00970f8..b631278 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 @@
             <fileMode>0664</fileMode>
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <excludes>
+                <exclude>nifi-bootstrap-utils</exclude>
                 <exclude>nifi-bootstrap</exclude>
                 <exclude>nifi-resources</exclude>
                 <exclude>nifi-docs</exclude>
diff --git a/nifi-system-tests/nifi-system-test-suite/pom.xml b/nifi-system-tests/nifi-system-test-suite/pom.xml
index 50d478b..9fd0dde 100644
--- a/nifi-system-tests/nifi-system-test-suite/pom.xml
+++ b/nifi-system-tests/nifi-system-test-suite/pom.xml
@@ -152,6 +152,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-bootstrap-utils</artifactId>
+            <version>1.14.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-bootstrap</artifactId>
             <version>1.14.0-SNAPSHOT</version>
         </dependency>
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 1c1b90a..8f30238 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 @@
             <fileMode>0664</fileMode>
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <includes>
+                <include>nifi-bootstrap-utils</include>
                 <include>nifi-bootstrap</include>
                 <include>slf4j-api</include>
                 <include>nifi-api</include>
@@ -62,6 +63,7 @@
             <fileMode>0664</fileMode>
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <excludes>
+                <exclude>nifi-bootstrap-utils</exclude>
                 <exclude>nifi-bootstrap</exclude>
                 <exclude>nifi-resources</exclude>
                 <exclude>nifi-docs</exclude>