From 82d315a65763c7b321d11803c89e4713febc90c5 Mon Sep 17 00:00:00 2001 From: Vasily V <16948475+basilisk487@users.noreply.github.com> Date: Wed, 20 May 2020 16:32:20 -0500 Subject: [PATCH] Misc fixes (warning for log4j2, print java version) (#531) --- pkg/etc/init.d/wavefront-proxy | 2 +- proxy/pom.xml | 3 +++ .../java/com/wavefront/agent/AbstractAgent.java | 13 +++++++++---- proxy/src/main/java/com/wavefront/common/Utils.java | 11 +++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/pkg/etc/init.d/wavefront-proxy b/pkg/etc/init.d/wavefront-proxy index 02642acb1..2ca8adeaf 100755 --- a/pkg/etc/init.d/wavefront-proxy +++ b/pkg/etc/init.d/wavefront-proxy @@ -123,7 +123,7 @@ if [[ -z "$PROXY_JAVA_HOME" && ! -r $proxy_jre_dir/bin/java ]]; then JAVA_HOME=$($(dirname $(dirname $(readlink -f $(which javac))))) echo "Using Java runtime $JAVA_VERSION detected in $JAVA_HOME" >&2 else - echo "Java runtime [1.8; 12) not found - trying to download and install" >&2 + echo "Found Java runtime $JAVA_VERSION, needs 8, 9, 10 or 11 to run - trying to download and install" >&2 download_jre fi else diff --git a/proxy/pom.xml b/proxy/pom.xml index e02e4ddf2..16ac3cf07 100644 --- a/proxy/pom.xml +++ b/proxy/pom.xml @@ -409,6 +409,9 @@ com.wavefront.agent.PushAgent + + true + diff --git a/proxy/src/main/java/com/wavefront/agent/AbstractAgent.java b/proxy/src/main/java/com/wavefront/agent/AbstractAgent.java index 1eaf62b2b..f9d5c4974 100644 --- a/proxy/src/main/java/com/wavefront/agent/AbstractAgent.java +++ b/proxy/src/main/java/com/wavefront/agent/AbstractAgent.java @@ -53,6 +53,7 @@ import static com.wavefront.agent.ProxyUtil.getOrCreateProxyId; import static com.wavefront.common.Utils.csvToList; import static com.wavefront.common.Utils.getBuildVersion; +import static com.wavefront.common.Utils.getJavaVersion; import static java.util.Collections.EMPTY_LIST; import static org.apache.commons.lang3.StringUtils.isEmpty; @@ -180,9 +181,12 @@ protected LogsIngestionConfig loadLogsIngestionConfig() { } private void postProcessConfig() { - System.setProperty("org.apache.commons.logging.Log", - "org.apache.commons.logging.impl.SimpleLog"); - System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "warn"); + // disable useless info messages when httpClient has to retry a request due to a stale + // connection. the alternative is to always validate connections before reuse, but since + // it happens fairly infrequently, and connection re-validation performance penalty is + // incurred every time, suppressing that message seems to be a more reasonable approach. + org.apache.log4j.Logger.getLogger("org.apache.http.impl.execchain.RetryExec"). + setLevel(org.apache.log4j.Level.WARN); if (StringUtils.isBlank(proxyConfig.getHostname().trim())) { logger.severe("hostname cannot be blank! Please correct your configuration settings."); @@ -193,7 +197,8 @@ private void postProcessConfig() { @VisibleForTesting void parseArguments(String[] args) { // read build information and print version. - String versionStr = "Wavefront Proxy version " + getBuildVersion(); + String versionStr = "Wavefront Proxy version " + getBuildVersion() + + ", runtime: " + getJavaVersion(); try { if (!proxyConfig.parseArguments(args, this.getClass().getCanonicalName())) { System.exit(0); diff --git a/proxy/src/main/java/com/wavefront/common/Utils.java b/proxy/src/main/java/com/wavefront/common/Utils.java index 6075b0118..ad27870c0 100644 --- a/proxy/src/main/java/com/wavefront/common/Utils.java +++ b/proxy/src/main/java/com/wavefront/common/Utils.java @@ -114,6 +114,17 @@ public static String getBuildVersion() { } } + /** + * Returns current java runtime version information (name/vendor/version) as a string. + * + * @return java runtime version as string + */ + public static String getJavaVersion() { + return System.getProperty("java.runtime.name", "(unknown runtime)") + " (" + + System.getProperty("java.vendor", "") + ") " + + System.getProperty("java.version", "(unknown version)"); + } + /** * Makes a best-effort attempt to resolve the hostname for the local host. *