diff --git a/eco/src/java/org/apache/heron/eco/Eco.java b/eco/src/java/org/apache/heron/eco/Eco.java index 617924da8ff..1e9fa29c88a 100644 --- a/eco/src/java/org/apache/heron/eco/Eco.java +++ b/eco/src/java/org/apache/heron/eco/Eco.java @@ -31,6 +31,7 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.heron.api.Config; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.eco.builder.BoltBuilder; import org.apache.heron.eco.builder.BuilderUtility; import org.apache.heron.eco.builder.ComponentBuilder; @@ -132,6 +133,7 @@ public void submit(FileInputStream fileInputStream, } public static void main(String[] args) throws Exception { + Slf4jUtils.installSLF4JBridge(); Options options = constructOptions(); CommandLineParser parser = new DefaultParser(); diff --git a/heron/api/src/java/BUILD b/heron/api/src/java/BUILD index 1724ef379b3..1762d846910 100644 --- a/heron/api/src/java/BUILD +++ b/heron/api/src/java/BUILD @@ -18,6 +18,7 @@ api_deps_files = \ ":classification", "//heron/common/src/java:basics-java", "@maven//:javax_xml_bind_jaxb_api", + "@maven//:org_slf4j_jul_to_slf4j", ] # Low Level Api diff --git a/heron/api/src/java/org/apache/heron/api/utils/Slf4jUtils.java b/heron/api/src/java/org/apache/heron/api/utils/Slf4jUtils.java new file mode 100644 index 00000000000..f2b2bffb9c8 --- /dev/null +++ b/heron/api/src/java/org/apache/heron/api/utils/Slf4jUtils.java @@ -0,0 +1,34 @@ +/** + * 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.heron.api.utils; + +import org.slf4j.bridge.SLF4JBridgeHandler; + +public final class Slf4jUtils { + private Slf4jUtils() { + } + + public static void installSLF4JBridge() { + if (!SLF4JBridgeHandler.isInstalled()) { + SLF4JBridgeHandler.removeHandlersForRootLogger(); + SLF4JBridgeHandler.install(); + } + } +} diff --git a/heron/ckptmgr/src/java/org/apache/heron/ckptmgr/CheckpointManager.java b/heron/ckptmgr/src/java/org/apache/heron/ckptmgr/CheckpointManager.java index 2ee2c644f59..8f4934db9c6 100644 --- a/heron/ckptmgr/src/java/org/apache/heron/ckptmgr/CheckpointManager.java +++ b/heron/ckptmgr/src/java/org/apache/heron/ckptmgr/CheckpointManager.java @@ -31,6 +31,7 @@ import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.common.basics.NIOLooper; import org.apache.heron.common.basics.SingletonRegistry; import org.apache.heron.common.config.SystemConfig; @@ -212,6 +213,7 @@ private static IStatefulStorage setupStatefulStorage( public static void main(String[] args) throws IOException, ParseException, CheckpointManagerException { + Slf4jUtils.installSLF4JBridge(); Options options = constructOptions(); Options helpOptions = constructHelpOptions(); CommandLineParser parser = new DefaultParser(); diff --git a/heron/downloaders/src/java/BUILD b/heron/downloaders/src/java/BUILD index fb559658ebe..356ff460a9a 100644 --- a/heron/downloaders/src/java/BUILD +++ b/heron/downloaders/src/java/BUILD @@ -11,6 +11,7 @@ files = glob( downloader_deps = [ "//heron/io/dlog/src/java:dlog-lib", + "//heron/api/src/java:api-java-low-level", "//heron/spi/src/java:common-spi-java", "//third_party/java:commons-compress", "@maven//:commons_cli_commons_cli", diff --git a/heron/downloaders/src/java/org/apache/heron/downloader/DownloadRunner.java b/heron/downloaders/src/java/org/apache/heron/downloader/DownloadRunner.java index 048ab423951..e6ab8857c28 100644 --- a/heron/downloaders/src/java/org/apache/heron/downloader/DownloadRunner.java +++ b/heron/downloaders/src/java/org/apache/heron/downloader/DownloadRunner.java @@ -31,6 +31,7 @@ import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.spi.common.Config; import org.apache.heron.spi.common.ConfigLoader; @@ -127,6 +128,7 @@ private static Options constructCliOptions() { // takes topology package URI and extracts it to a directory public static void main(String[] args) throws Exception { + Slf4jUtils.installSLF4JBridge(); CommandLineParser parser = new DefaultParser(); Options slaManagerCliOptions = constructCliOptions(); diff --git a/heron/healthmgr/src/java/org/apache/heron/healthmgr/HealthManager.java b/heron/healthmgr/src/java/org/apache/heron/healthmgr/HealthManager.java index f41d516fd3f..dd0c7f7af09 100644 --- a/heron/healthmgr/src/java/org/apache/heron/healthmgr/HealthManager.java +++ b/heron/healthmgr/src/java/org/apache/heron/healthmgr/HealthManager.java @@ -48,6 +48,7 @@ import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.classification.InterfaceStability.Evolving; import org.apache.heron.classification.InterfaceStability.Unstable; import org.apache.heron.common.basics.SingletonRegistry; @@ -152,6 +153,7 @@ public HealthManager(Config config, AbstractModule baseModule) { } public static void main(String[] args) throws Exception { + Slf4jUtils.installSLF4JBridge(); CommandLineParser parser = new DefaultParser(); Options slaManagerCliOptions = constructCliOptions(); diff --git a/heron/instance/src/java/shade.conf b/heron/instance/src/java/shade.conf index fddb4fae1f1..c3cab9ab506 100644 --- a/heron/instance/src/java/shade.conf +++ b/heron/instance/src/java/shade.conf @@ -18,3 +18,4 @@ rule com.google.protobuf** org.apache.heron.shaded.@0 rule org.yaml.snakeyaml** org.apache.heron.shaded.@0 rule org.apache.commons** org.apache.heron.shaded.@0 +rule org.slf4j** org.apache.heron.shaded.@0 \ No newline at end of file diff --git a/heron/metricscachemgr/src/java/org/apache/heron/metricscachemgr/MetricsCacheManager.java b/heron/metricscachemgr/src/java/org/apache/heron/metricscachemgr/MetricsCacheManager.java index e1c3a9f4c9f..a9b1644c89b 100644 --- a/heron/metricscachemgr/src/java/org/apache/heron/metricscachemgr/MetricsCacheManager.java +++ b/heron/metricscachemgr/src/java/org/apache/heron/metricscachemgr/MetricsCacheManager.java @@ -32,6 +32,7 @@ import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.common.basics.NIOLooper; import org.apache.heron.common.basics.SysUtils; import org.apache.heron.common.config.SystemConfig; @@ -284,6 +285,7 @@ private static void usage(Options options) { } public static void main(String[] args) throws Exception { + Slf4jUtils.installSLF4JBridge(); Options options = constructOptions(); Options helpOptions = constructHelpOptions(); diff --git a/heron/metricscachemgr/src/java/org/apache/heron/metricscachemgr/MetricsCacheManagerHttpServer.java b/heron/metricscachemgr/src/java/org/apache/heron/metricscachemgr/MetricsCacheManagerHttpServer.java index e8113ddf84e..b185214f5e3 100644 --- a/heron/metricscachemgr/src/java/org/apache/heron/metricscachemgr/MetricsCacheManagerHttpServer.java +++ b/heron/metricscachemgr/src/java/org/apache/heron/metricscachemgr/MetricsCacheManagerHttpServer.java @@ -33,6 +33,7 @@ import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.metricscachemgr.metricscache.MetricsCache; import org.apache.heron.proto.tmanager.TopologyManager; import org.apache.heron.spi.utils.NetworkUtils; @@ -95,6 +96,7 @@ public MetricsCacheManagerHttpServer(MetricsCache cache, int port) throws IOExce */ public static void main(String[] args) throws ExecutionException, InterruptedException, IOException { + Slf4jUtils.installSLF4JBridge(); if (args.length < 3) { System.out.println( "Usage: java MetricsQuery "); diff --git a/heron/metricsmgr/src/java/org/apache/heron/metricsmgr/MetricsManager.java b/heron/metricsmgr/src/java/org/apache/heron/metricsmgr/MetricsManager.java index 374f2b553f6..9bf313f5040 100644 --- a/heron/metricsmgr/src/java/org/apache/heron/metricsmgr/MetricsManager.java +++ b/heron/metricsmgr/src/java/org/apache/heron/metricsmgr/MetricsManager.java @@ -39,6 +39,7 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.heron.api.metric.MultiCountMetric; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.common.basics.Communicator; import org.apache.heron.common.basics.ExecutorLooper; import org.apache.heron.common.basics.NIOLooper; @@ -329,6 +330,7 @@ private static void usage(Options options) { } public static void main(String[] args) throws Exception { + Slf4jUtils.installSLF4JBridge(); final Options options = constructOptions(); final Options helpOptions = constructHelpOptions(); diff --git a/heron/scheduler-core/src/java/org/apache/heron/scheduler/RuntimeManagerMain.java b/heron/scheduler-core/src/java/org/apache/heron/scheduler/RuntimeManagerMain.java index 56df04e250c..271ea63c063 100644 --- a/heron/scheduler-core/src/java/org/apache/heron/scheduler/RuntimeManagerMain.java +++ b/heron/scheduler-core/src/java/org/apache/heron/scheduler/RuntimeManagerMain.java @@ -32,6 +32,7 @@ import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.common.basics.DryRunFormatType; import org.apache.heron.common.basics.SysUtils; import org.apache.heron.common.utils.logging.LoggingHelper; @@ -224,7 +225,7 @@ private static Options constructHelpOptions() { public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, IOException, ParseException { - + Slf4jUtils.installSLF4JBridge(); Options options = constructOptions(); Options helpOptions = constructHelpOptions(); CommandLineParser parser = new DefaultParser(); diff --git a/heron/scheduler-core/src/java/org/apache/heron/scheduler/SchedulerMain.java b/heron/scheduler-core/src/java/org/apache/heron/scheduler/SchedulerMain.java index 5c57e24b5b0..917a5dc3335 100644 --- a/heron/scheduler-core/src/java/org/apache/heron/scheduler/SchedulerMain.java +++ b/heron/scheduler-core/src/java/org/apache/heron/scheduler/SchedulerMain.java @@ -33,6 +33,7 @@ import org.apache.commons.cli.ParseException; import org.apache.heron.api.exception.InvalidTopologyException; import org.apache.heron.api.generated.TopologyAPI; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.api.utils.TopologyUtils; import org.apache.heron.common.basics.FileUtils; import org.apache.heron.common.basics.SysUtils; @@ -177,7 +178,7 @@ private static Options constructHelpOptions() { } public static void main(String[] args) throws Exception { - + Slf4jUtils.installSLF4JBridge(); // construct the options and help options first. Options options = constructOptions(); Options helpOptions = constructHelpOptions(); diff --git a/heron/scheduler-core/src/java/org/apache/heron/scheduler/SubmitterMain.java b/heron/scheduler-core/src/java/org/apache/heron/scheduler/SubmitterMain.java index c88e527b99e..e9a8170f277 100644 --- a/heron/scheduler-core/src/java/org/apache/heron/scheduler/SubmitterMain.java +++ b/heron/scheduler-core/src/java/org/apache/heron/scheduler/SubmitterMain.java @@ -35,6 +35,7 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.heron.api.generated.TopologyAPI; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.api.utils.TopologyUtils; import org.apache.heron.common.basics.DryRunFormatType; import org.apache.heron.common.basics.SysUtils; @@ -297,6 +298,7 @@ dryRunFormat, isVerbose(cmd), isVerboseGC(cmd))) } public static void main(String[] args) throws Exception { + Slf4jUtils.installSLF4JBridge(); Options options = constructOptions(); Options helpOptions = constructHelpOptions(); CommandLineParser parser = new DefaultParser(); diff --git a/heron/statemgrs/src/java/org/apache/heron/statemgr/localfs/LocalFileSystemStateManager.java b/heron/statemgrs/src/java/org/apache/heron/statemgr/localfs/LocalFileSystemStateManager.java index 66d4b02a7b4..220e9330215 100644 --- a/heron/statemgrs/src/java/org/apache/heron/statemgr/localfs/LocalFileSystemStateManager.java +++ b/heron/statemgrs/src/java/org/apache/heron/statemgr/localfs/LocalFileSystemStateManager.java @@ -30,6 +30,7 @@ import com.google.protobuf.Message; import org.apache.heron.api.generated.TopologyAPI; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.common.basics.FileUtils; import org.apache.heron.proto.ckptmgr.CheckpointManager; import org.apache.heron.proto.scheduler.Scheduler; @@ -247,6 +248,7 @@ public void close() { public static void main(String[] args) throws ExecutionException, InterruptedException, IllegalAccessException, ClassNotFoundException, InstantiationException { + Slf4jUtils.installSLF4JBridge(); Config config = Config.newBuilder() .put(Key.STATEMGR_ROOT_PATH, System.getProperty("user.home") + "/.herondata/repository/state/local") diff --git a/heron/statemgrs/src/java/org/apache/heron/statemgr/zookeeper/curator/CuratorStateManager.java b/heron/statemgrs/src/java/org/apache/heron/statemgr/zookeeper/curator/CuratorStateManager.java index b1d3da9abc5..4a9574162a2 100644 --- a/heron/statemgrs/src/java/org/apache/heron/statemgr/zookeeper/curator/CuratorStateManager.java +++ b/heron/statemgrs/src/java/org/apache/heron/statemgr/zookeeper/curator/CuratorStateManager.java @@ -40,6 +40,7 @@ import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.ExponentialBackoffRetry; import org.apache.heron.api.generated.TopologyAPI; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.common.basics.Pair; import org.apache.heron.proto.ckptmgr.CheckpointManager; import org.apache.heron.proto.scheduler.Scheduler; @@ -451,7 +452,7 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc if (args.length < 2) { throw new RuntimeException("Expects 2 arguments: "); } - + Slf4jUtils.installSLF4JBridge(); String zookeeperHostname = args[1]; Config config = Config.newBuilder() .put(Key.STATEMGR_ROOT_PATH, "/storm/heron/states") diff --git a/heron/tools/apiserver/src/java/org/apache/heron/apiserver/Runtime.java b/heron/tools/apiserver/src/java/org/apache/heron/apiserver/Runtime.java index 31f34440ef4..6689ddf2cf0 100644 --- a/heron/tools/apiserver/src/java/org/apache/heron/apiserver/Runtime.java +++ b/heron/tools/apiserver/src/java/org/apache/heron/apiserver/Runtime.java @@ -40,6 +40,7 @@ import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.heron.api.utils.Slf4jUtils; import org.apache.heron.apiserver.resources.HeronResource; import org.apache.heron.apiserver.utils.ConfigUtils; import org.apache.heron.apiserver.utils.Logging; @@ -245,6 +246,7 @@ private static Boolean isVerbose(CommandLine cmd) { @SuppressWarnings({"IllegalCatch", "RegexpSinglelineJava"}) public static void main(String[] args) throws Exception { + Slf4jUtils.installSLF4JBridge(); final Options options = createOptions(); final Options helpOptions = constructHelpOptions(); diff --git a/scripts/travis/test.sh b/scripts/travis/test.sh index a9a2dca76b9..7bf754ea909 100755 --- a/scripts/travis/test.sh +++ b/scripts/travis/test.sh @@ -22,6 +22,7 @@ set -e DIR=`dirname $0` UTILS=${DIR}/../shutils +export log_level=WARN source ${UTILS}/common.sh # integration test binaries have to be specified as absolute path diff --git a/third_party/java/BUILD b/third_party/java/BUILD index d804e2aea10..78417c8415d 100644 --- a/third_party/java/BUILD +++ b/third_party/java/BUILD @@ -19,9 +19,9 @@ java_library( "@maven//:com_fasterxml_jackson_core_jackson_core", "@maven//:com_fasterxml_jackson_core_jackson_databind", "@maven//:commons_codec_commons_codec", - "@maven//:org_slf4j_jcl_over_slf4j", "@maven//:org_apache_httpcomponents_httpclient", "@maven//:org_apache_httpcomponents_httpcore", + "@maven//:org_slf4j_jcl_over_slf4j", ], ) @@ -211,9 +211,9 @@ java_library( "@maven//:com_google_http_client_google_http_client_jackson2", "@maven//:com_google_oauth_client_google_oauth_client", "@maven//:commons_codec_commons_codec", - "@maven//:org_slf4j_jcl_over_slf4j", "@maven//:org_apache_httpcomponents_httpclient", "@maven//:org_apache_httpcomponents_httpcore", + "@maven//:org_slf4j_jcl_over_slf4j", ], ) @@ -351,15 +351,15 @@ java_library( "@maven//:org_apache_distributedlog_distributedlog_protocol", ], deps = [ - "@maven//:org_slf4j_slf4j_api", - "@maven//:org_slf4j_jul_to_slf4j", - "@maven//:org_slf4j_log4j_over_slf4j", - "@maven//:org_slf4j_jcl_over_slf4j", "@maven//:commons_collections_commons_collections", "@maven//:commons_configuration_commons_configuration", "@maven//:commons_lang_commons_lang", "@maven//:io_netty_netty_all", "@maven//:org_apache_distributedlog_distributedlog_core", "@maven//:org_apache_distributedlog_distributedlog_protocol", + "@maven//:org_slf4j_jcl_over_slf4j", + "@maven//:org_slf4j_jul_to_slf4j", + "@maven//:org_slf4j_log4j_over_slf4j", + "@maven//:org_slf4j_slf4j_api", ], ) diff --git a/third_party/java/logback.xml b/third_party/java/logback.xml index 70bbb292499..91d1c14afaf 100644 --- a/third_party/java/logback.xml +++ b/third_party/java/logback.xml @@ -1,4 +1,25 @@ - + + + diff --git a/tools/java/src/org/apache/bazel/checkstyle/BUILD b/tools/java/src/org/apache/bazel/checkstyle/BUILD index 2728f1de69d..942b8911840 100644 --- a/tools/java/src/org/apache/bazel/checkstyle/BUILD +++ b/tools/java/src/org/apache/bazel/checkstyle/BUILD @@ -9,6 +9,7 @@ common_deps = [ "@maven//:com_google_guava_guava", "//third_party/java/bazel:extra_actions_proto_java", "//third_party/java/bazel:proto_java", + "//third_party/java:logging", ] java_binary(