mirror of https://github.com/apache/nifi.git
NIFI-10798 Added Deprecation Logging for Java 8 on Startup
- Added deprecation warnings for NiFi, Registry, and MiNiFi - Added RuntimeVersionProvider for shared reference to deprecated and minimum versions Signed-off-by: Nathan Gough <thenatog@gmail.com> This closes #6648.
This commit is contained in:
parent
b14eedfa7f
commit
3a536e261f
|
@ -60,6 +60,10 @@ Apache NiFi was made for dataflow. It supports highly configurable directed grap
|
|||
- Pluggable fine-grained role-based authentication/authorization
|
||||
- Multiple teams can manage and share specific portions of the flow
|
||||
|
||||
## Minimum Recommendations
|
||||
* JDK 11.0.16
|
||||
* Apache Maven 3.8.6
|
||||
|
||||
## Minimum Requirements
|
||||
* JDK 8 Update 251
|
||||
* Apache Maven 3.6.0
|
||||
|
|
|
@ -49,6 +49,10 @@ limitations under the License.
|
|||
<groupId>org.apache.nifi</groupId>
|
||||
<artifactId>nifi-bootstrap-utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.nifi</groupId>
|
||||
<artifactId>nifi-deprecation-log</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.nifi</groupId>
|
||||
<artifactId>nifi-expression-language</artifactId>
|
||||
|
|
|
@ -43,6 +43,9 @@ import java.util.concurrent.locks.Condition;
|
|||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.apache.nifi.bootstrap.util.OSUtils;
|
||||
import org.apache.nifi.bootstrap.util.RuntimeVersionProvider;
|
||||
import org.apache.nifi.deprecation.log.DeprecationLogger;
|
||||
import org.apache.nifi.deprecation.log.DeprecationLoggerFactory;
|
||||
import org.apache.nifi.minifi.bootstrap.MiNiFiParameters;
|
||||
import org.apache.nifi.minifi.bootstrap.RunMiNiFi;
|
||||
import org.apache.nifi.minifi.bootstrap.ShutdownHook;
|
||||
|
@ -60,6 +63,8 @@ import org.apache.nifi.util.Tuple;
|
|||
public class StartRunner implements CommandRunner {
|
||||
private static final int STARTUP_WAIT_SECONDS = 60;
|
||||
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLoggerFactory.getLogger(StartRunner.class);
|
||||
|
||||
private final CurrentPortProvider currentPortProvider;
|
||||
private final BootstrapFileProvider bootstrapFileProvider;
|
||||
private final PeriodicStatusReporterManager periodicStatusReporterManager;
|
||||
|
@ -110,6 +115,11 @@ public class StartRunner implements CommandRunner {
|
|||
return;
|
||||
}
|
||||
|
||||
final int javaMajorVersion = RuntimeVersionProvider.getMajorVersion();
|
||||
if (RuntimeVersionProvider.isMajorVersionDeprecated(javaMajorVersion)) {
|
||||
deprecationLogger.warn("Support for Java {} is deprecated. Java {} is the minimum recommended version", javaMajorVersion, RuntimeVersionProvider.getMinimumMajorVersion());
|
||||
}
|
||||
|
||||
File prevLockFile = bootstrapFileProvider.getLockFile();
|
||||
if (prevLockFile.exists() && !prevLockFile.delete()) {
|
||||
CMD_LOGGER.warn("Failed to delete previous lock file {}; this file should be cleaned up manually", prevLockFile);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.nifi.minifi.bootstrap.service;
|
||||
|
||||
import static org.apache.nifi.minifi.bootstrap.RunMiNiFi.CONF_DIR_KEY;
|
||||
import static org.apache.nifi.minifi.bootstrap.RunMiNiFi.DEFAULT_LOGGER;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -27,7 +26,7 @@ import java.util.List;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import org.apache.nifi.bootstrap.util.OSUtils;
|
||||
import org.apache.nifi.bootstrap.util.RuntimeVersionProvider;
|
||||
|
||||
public class MiNiFiExecCommandProvider {
|
||||
|
||||
|
@ -146,9 +145,8 @@ public class MiNiFiExecCommandProvider {
|
|||
|
||||
private List<String> getJava11Files(File libDir) {
|
||||
List<String> java11Files = new ArrayList();
|
||||
String runtimeJavaVersion = System.getProperty("java.version");
|
||||
DEFAULT_LOGGER.info("Runtime Java version: {}", runtimeJavaVersion);
|
||||
if (OSUtils.parseJavaVersion(runtimeJavaVersion) >= 11) {
|
||||
final int javaMajorVersion = RuntimeVersionProvider.getMajorVersion();
|
||||
if (javaMajorVersion >= 11) {
|
||||
/* If running on Java 11 or greater, add the JAXB/activation/annotation libs to the classpath.
|
||||
*
|
||||
* TODO: Once the minimum Java version requirement of NiFi is 11, this processing should be removed.
|
||||
|
|
|
@ -51,6 +51,11 @@ limitations under the License.
|
|||
<artifactId>nifi-bootstrap-utils</artifactId>
|
||||
<version>1.19.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.nifi</groupId>
|
||||
<artifactId>nifi-deprecation-log</artifactId>
|
||||
<version>1.19.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.nifi.minifi</groupId>
|
||||
<artifactId>minifi-bootstrap</artifactId>
|
||||
|
|
|
@ -30,6 +30,11 @@ language governing permissions and limitations under the License. -->
|
|||
<version>1.19.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.nifi</groupId>
|
||||
<artifactId>nifi-deprecation-log</artifactId>
|
||||
<version>1.19.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.nifi</groupId>
|
||||
<artifactId>nifi-bootstrap-utils</artifactId>
|
||||
|
|
|
@ -20,7 +20,10 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.nifi.bootstrap.notification.NotificationType;
|
||||
import org.apache.nifi.bootstrap.util.DumpFileValidator;
|
||||
import org.apache.nifi.bootstrap.util.OSUtils;
|
||||
import org.apache.nifi.bootstrap.util.RuntimeVersionProvider;
|
||||
import org.apache.nifi.bootstrap.util.SecureNiFiConfigUtil;
|
||||
import org.apache.nifi.deprecation.log.DeprecationLogger;
|
||||
import org.apache.nifi.deprecation.log.DeprecationLoggerFactory;
|
||||
import org.apache.nifi.util.file.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -147,7 +150,7 @@ public class RunNiFi {
|
|||
private final Logger cmdLogger = LoggerFactory.getLogger("org.apache.nifi.bootstrap.Command");
|
||||
// used for logging all info. These by default will be written to the log file
|
||||
private final Logger defaultLogger = LoggerFactory.getLogger(RunNiFi.class);
|
||||
|
||||
private final DeprecationLogger deprecationLogger = DeprecationLoggerFactory.getLogger(RunNiFi.class);
|
||||
|
||||
private final ExecutorService loggingExecutor;
|
||||
private volatile Set<Future<?>> loggingFutures = new HashSet<>(2);
|
||||
|
@ -1203,7 +1206,7 @@ public class RunNiFi {
|
|||
|
||||
String runtimeJavaVersion = System.getProperty("java.version");
|
||||
defaultLogger.info("Runtime Java version: {}", runtimeJavaVersion);
|
||||
int javaMajorVersion = OSUtils.parseJavaVersion(runtimeJavaVersion);
|
||||
final int javaMajorVersion = RuntimeVersionProvider.getMajorVersion();
|
||||
if (javaMajorVersion >= 11) {
|
||||
/* If running on Java 11 or greater, add the JAXB/activation/annotation libs to the classpath.
|
||||
*
|
||||
|
@ -1219,6 +1222,10 @@ public class RunNiFi {
|
|||
}
|
||||
}
|
||||
|
||||
if (RuntimeVersionProvider.isMajorVersionDeprecated(javaMajorVersion)) {
|
||||
deprecationLogger.warn("Support for Java {} is deprecated. Java {} is the minimum recommended version", javaMajorVersion, RuntimeVersionProvider.getMinimumMajorVersion());
|
||||
}
|
||||
|
||||
final StringBuilder classPathBuilder = new StringBuilder();
|
||||
for (int i = 0; i < cpFiles.size(); i++) {
|
||||
final String filename = cpFiles.get(i);
|
||||
|
|
|
@ -75,7 +75,7 @@ public final class OSUtils {
|
|||
* @param version the Java version string
|
||||
* @return the major version as an int
|
||||
*/
|
||||
public static int parseJavaVersion(final String version) {
|
||||
static int parseJavaVersion(final String version) {
|
||||
String majorVersion;
|
||||
if (version.startsWith("1.")) {
|
||||
majorVersion = version.substring(2, 3);
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.nifi.bootstrap.util;
|
||||
|
||||
/**
|
||||
* Java Runtime Version Provider with information on supported and deprecated versions
|
||||
*/
|
||||
public class RuntimeVersionProvider {
|
||||
|
||||
private static final String JAVA_VERSION_PROPERTY = "java.version";
|
||||
|
||||
private static final int DEPRECATED_JAVA_VERSION = 8;
|
||||
|
||||
private static final int MINIMUM_JAVA_VERSION = 11;
|
||||
|
||||
/**
|
||||
* Get major version from java.version System property
|
||||
*
|
||||
* @return Major Version
|
||||
*/
|
||||
public static int getMajorVersion() {
|
||||
final String javaVersion = System.getProperty(JAVA_VERSION_PROPERTY);
|
||||
return OSUtils.parseJavaVersion(javaVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get minimum supported major version
|
||||
*
|
||||
* @return Minimum Major Version
|
||||
*/
|
||||
public static int getMinimumMajorVersion() {
|
||||
return MINIMUM_JAVA_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is major version deprecated
|
||||
*
|
||||
* @param majorVersion Java major version
|
||||
* @return Deprecated status
|
||||
*/
|
||||
public static boolean isMajorVersionDeprecated(final int majorVersion) {
|
||||
return majorVersion == DEPRECATED_JAVA_VERSION;
|
||||
}
|
||||
}
|
|
@ -35,5 +35,10 @@
|
|||
<artifactId>nifi-bootstrap-utils</artifactId>
|
||||
<version>1.19.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.nifi</groupId>
|
||||
<artifactId>nifi-deprecation-log</artifactId>
|
||||
<version>1.19.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -18,6 +18,9 @@ package org.apache.nifi.registry.bootstrap;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.nifi.bootstrap.util.OSUtils;
|
||||
import org.apache.nifi.bootstrap.util.RuntimeVersionProvider;
|
||||
import org.apache.nifi.deprecation.log.DeprecationLogger;
|
||||
import org.apache.nifi.deprecation.log.DeprecationLoggerFactory;
|
||||
import org.apache.nifi.registry.util.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -119,7 +122,7 @@ public class RunNiFiRegistry {
|
|||
private final Logger cmdLogger = LoggerFactory.getLogger("org.apache.nifi.registry.bootstrap.Command");
|
||||
// used for logging all info. These by default will be written to the log file
|
||||
private final Logger defaultLogger = LoggerFactory.getLogger(RunNiFiRegistry.class);
|
||||
|
||||
private final DeprecationLogger deprecationLogger = DeprecationLoggerFactory.getLogger(RunNiFiRegistry.class);
|
||||
|
||||
private final ExecutorService loggingExecutor;
|
||||
private volatile Set<Future<?>> loggingFutures = new HashSet<>(2);
|
||||
|
@ -923,7 +926,8 @@ public class RunNiFiRegistry {
|
|||
|
||||
final String runtimeJavaVersion = System.getProperty("java.version");
|
||||
defaultLogger.info("Runtime Java version: {}", runtimeJavaVersion);
|
||||
if (Integer.parseInt(runtimeJavaVersion.substring(0, runtimeJavaVersion.indexOf('.'))) >= 11) {
|
||||
final int javaMajorVersion = RuntimeVersionProvider.getMajorVersion();
|
||||
if (javaMajorVersion >= 11) {
|
||||
// If running on Java 11 or greater, add lib/java11 to the classpath.
|
||||
// TODO: Once the minimum Java version requirement of NiFi Registry is 11, this processing should be removed.
|
||||
final String libJava11Filename = replaceNull(props.get("lib.dir"), "./lib").trim() + "/java11";
|
||||
|
@ -935,6 +939,10 @@ public class RunNiFiRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
if (RuntimeVersionProvider.isMajorVersionDeprecated(javaMajorVersion)) {
|
||||
deprecationLogger.warn("Support for Java {} is deprecated. Java {} is the minimum recommended version", javaMajorVersion, RuntimeVersionProvider.getMinimumMajorVersion());
|
||||
}
|
||||
|
||||
final StringBuilder classPathBuilder = new StringBuilder();
|
||||
for (int i = 0; i < cpFiles.size(); i++) {
|
||||
final String filename = cpFiles.get(i);
|
||||
|
|
Loading…
Reference in New Issue