Skip to content

Commit

Permalink
HBASE-24309 Avoid introducing log4j and slf4j-log4j dependencies for …
Browse files Browse the repository at this point in the history
…modules other than hbase-assembly (apache#1640)

Signed-off-by: stack <[email protected]>
  • Loading branch information
Apache9 committed May 12, 2020
1 parent bb3191c commit 8601416
Show file tree
Hide file tree
Showing 55 changed files with 1,175 additions and 999 deletions.
16 changes: 10 additions & 6 deletions hbase-archetypes/hbase-client-project/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,35 @@
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-testing-util</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-server</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
13 changes: 10 additions & 3 deletions hbase-archetypes/hbase-shaded-client-project/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-testing-util</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand All @@ -59,12 +58,20 @@
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-shaded-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
21 changes: 21 additions & 0 deletions hbase-assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -318,5 +318,26 @@
<artifactId>jaxws-ri</artifactId>
<type>pom</type>
</dependency>
<!--
Include the log framework here.
For other sub modules, we only declare slf4j-api as a compile dependency,
so here we must pull in the real logging framework to actually log to log4j.
-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
</dependencies>
</project>
42 changes: 24 additions & 18 deletions hbase-assembly/src/main/assembly/client.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd">
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
Expand Down Expand Up @@ -28,7 +30,7 @@
<!-- Override the root directory in the tarball -->
<baseDirectory>hbase-${project.version}-client</baseDirectory>
<componentDescriptors>
<componentDescriptor>src/main/assembly/client-components.xml</componentDescriptor>
<componentDescriptor>src/main/assembly/client-components.xml</componentDescriptor>
</componentDescriptors>
<moduleSets>
<!-- include regular jars so the shell can use them -->
Expand All @@ -40,8 +42,8 @@
<binaries>
<unpack>false</unpack>
<outputDirectory>lib</outputDirectory>
<dependencySets>
<dependencySet>
<dependencySets>
<dependencySet>
<excludes>
<!-- Exclude J2EE libraries that get pulled in when building on JDK11 -->
<exclude>com.sun.xml.ws:jaxws-ri</exclude>
Expand All @@ -50,20 +52,22 @@
<exclude>com.sun.jersey:*</exclude>
<exclude>com.sun.jersey.contribs:*</exclude>
<exclude>jline:jline</exclude>
<exclude>com.github.stephenc.findbugs:findbugs-annotations</exclude>
<exclude>commons-logging:commons-logging</exclude>
<exclude>log4j:log4j</exclude>
<exclude>org.apache.hbase:hbase-shaded-client</exclude>
<exclude>org.apache.hbase:hbase-shaded-client-byo-hadoop</exclude>
<exclude>org.apache.hbase:hbase-shaded-mapreduce</exclude>
<exclude>org.apache.htrace:htrace-core4</exclude>
<exclude>org.apache.htrace:htrace-core</exclude>
<exclude>org.apache.yetus:audience-annotations</exclude>
<exclude>org.slf4j:slf4j-api</exclude>
<exclude>org.slf4j:slf4j-log4j12</exclude>
<exclude>com.github.stephenc.findbugs:findbugs-annotations</exclude>
<exclude>commons-logging:commons-logging</exclude>
<exclude>log4j:log4j</exclude>
<exclude>org.apache.hbase:hbase-shaded-client</exclude>
<exclude>org.apache.hbase:hbase-shaded-client-byo-hadoop</exclude>
<exclude>org.apache.hbase:hbase-shaded-mapreduce</exclude>
<exclude>org.apache.htrace:htrace-core4</exclude>
<exclude>org.apache.htrace:htrace-core</exclude>
<exclude>org.apache.yetus:audience-annotations</exclude>
<exclude>org.slf4j:slf4j-api</exclude>
<exclude>org.slf4j:jcl-over-slf4j</exclude>
<exclude>org.slf4j:jul-to-slf4j</exclude>
<exclude>org.slf4j:slf4j-log4j12</exclude>
</excludes>
</dependencySet>
</dependencySets>
</dependencySet>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
Expand Down Expand Up @@ -91,7 +95,7 @@

<dependencySets>
<dependencySet>
<outputDirectory>lib/shaded-clients</outputDirectory>
<outputDirectory>lib/shaded-clients</outputDirectory>
<includes>
<include>org.apache.hbase:hbase-shaded-client</include>
<include>org.apache.hbase:hbase-shaded-mapreduce</include>
Expand Down Expand Up @@ -146,6 +150,8 @@
<include>org.apache.htrace:htrace-core</include>
<include>org.apache.yetus:audience-annotations</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:jcl-over-slf4j</include>
<include>org.slf4j:jul-to-slf4j</include>
<include>org.slf4j:slf4j-log4j12</include>
</includes>
</dependencySet>
Expand Down
3 changes: 3 additions & 0 deletions hbase-assembly/src/main/assembly/hadoop-three-compat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<include>org.apache.hbase:hbase-hadoop-compat</include>
<include>org.apache.hbase:hbase-http</include>
<include>org.apache.hbase:hbase-it</include>
<include>org.apache.hbase:hbase-logging</include>
<include>org.apache.hbase:hbase-mapreduce</include>
<include>org.apache.hbase:hbase-metrics</include>
<include>org.apache.hbase:hbase-metrics-api</include>
Expand Down Expand Up @@ -209,6 +210,8 @@
<include>org.apache.htrace:htrace-core</include>
<include>org.apache.yetus:audience-annotations</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:jcl-over-slf4j</include>
<include>org.slf4j:jul-to-slf4j</include>
<include>org.slf4j:slf4j-log4j12</include>
</includes>
</dependencySet>
Expand Down
26 changes: 26 additions & 0 deletions hbase-asyncfs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-logging</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-common</artifactId>
Expand Down Expand Up @@ -132,6 +138,26 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
23 changes: 22 additions & 1 deletion hbase-backup/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-logging</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
Expand Down Expand Up @@ -132,9 +138,24 @@
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<!--For Hadoop-->
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@
import org.apache.hadoop.hbase.backup.BackupRestoreConstants.BackupCommand;
import org.apache.hadoop.hbase.backup.impl.BackupCommands;
import org.apache.hadoop.hbase.backup.impl.BackupManager;
import org.apache.hadoop.hbase.logging.Log4jUtils;
import org.apache.hadoop.hbase.util.AbstractHBaseTool;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.util.ToolRunner;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -75,7 +74,7 @@ public BackupDriver() throws IOException {

protected void init() throws IOException {
// disable irrelevant loggers to avoid it mess up command output
LogUtils.disableZkAndClientLoggers();
Log4jUtils.disableZkAndClientLoggers();
}

private int parseAndRun(String[] args) throws IOException {
Expand Down Expand Up @@ -128,9 +127,7 @@ private int parseAndRun(String[] args) throws IOException {

// enable debug logging
if (this.cmd.hasOption(OPTION_DEBUG)) {
LogManager.getLogger("org.apache.hadoop.hbase.backup").setLevel(Level.DEBUG);
} else {
LogManager.getLogger("org.apache.hadoop.hbase.backup").setLevel(Level.INFO);
Log4jUtils.setLogLevel("org.apache.hadoop.hbase.backup", "DEBUG");
}

BackupCommands.Command command = BackupCommands.createCommand(getConf(), type, this.cmd);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@
import org.apache.hadoop.hbase.backup.util.BackupUtils;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.logging.Log4jUtils;
import org.apache.hadoop.hbase.util.AbstractHBaseTool;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.util.ToolRunner;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -83,7 +82,7 @@ protected RestoreDriver() throws IOException {

protected void init() {
// disable irrelevant loggers to avoid it mess up command output
LogUtils.disableZkAndClientLoggers();
Log4jUtils.disableZkAndClientLoggers();
}

private int parseAndRun(String[] args) throws IOException {
Expand All @@ -97,7 +96,7 @@ private int parseAndRun(String[] args) throws IOException {

// enable debug logging
if (cmd.hasOption(OPTION_DEBUG)) {
LogManager.getLogger("org.apache.hadoop.hbase.backup").setLevel(Level.DEBUG);
Log4jUtils.setLogLevel("org.apache.hadoop.hbase.backup", "DEBUG");
}

// whether to overwrite to existing table if any, false by default
Expand Down
Loading

0 comments on commit 8601416

Please sign in to comment.