From b7e43347017abd59b21359f2f9f1010a2fe61835 Mon Sep 17 00:00:00 2001 From: gaodayue Date: Tue, 5 Jul 2016 10:23:54 +0800 Subject: [PATCH] KYLIN-1846 minimize dependencies of JDBC driver --- jdbc/pom.xml | 72 +++++++++++++++------- .../main/java/org/apache/kylin/jdbc/Driver.java | 2 - .../main/java/org/apache/kylin/jdbc/KylinMeta.java | 6 +- .../apache/kylin/jdbc/util/Log4jConfigurer.java | 69 --------------------- jdbc/src/main/resources/kylin-log4j.properties | 28 --------- pom.xml | 5 ++ 6 files changed, 58 insertions(+), 124 deletions(-) delete mode 100644 jdbc/src/main/java/org/apache/kylin/jdbc/util/Log4jConfigurer.java delete mode 100644 jdbc/src/main/resources/kylin-log4j.properties diff --git a/jdbc/pom.xml b/jdbc/pom.xml index 8a0d02c..68b872e 100644 --- a/jdbc/pom.xml +++ b/jdbc/pom.xml @@ -33,15 +33,12 @@ UTF-8 + org.apache.kylin.jdbc.shaded org.apache.calcite - calcite-core - - - org.apache.calcite calcite-avatica @@ -53,10 +50,13 @@ commons-httpclient commons-httpclient - - - log4j - log4j + + + + commons-logging + commons-logging + + org.slf4j @@ -67,10 +67,6 @@ slf4j-api - org.slf4j - slf4j-log4j12 - - junit junit test @@ -81,20 +77,54 @@ - maven-assembly-plugin - - - jar-with-dependencies - - false - + org.apache.maven.plugins + maven-shade-plugin - make-assembly package - single + shade + + false + + + + com.fasterxml.jackson.core:* + + + + + org.apache.calcite + ${shadeBase}.org.apache.calcite + + + com.fasterxml.jackson + ${shadeBase}.com.fasterxml.jackson + + + org.apache.commons + ${shadeBase}.org.apache.commons + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + commons-httpclient:commons-httpclient + + META-INF/** + + + + diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/Driver.java b/jdbc/src/main/java/org/apache/kylin/jdbc/Driver.java index 7f3c407..f9d840a 100644 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/Driver.java +++ b/jdbc/src/main/java/org/apache/kylin/jdbc/Driver.java @@ -25,7 +25,6 @@ import org.apache.calcite.avatica.AvaticaConnection; import org.apache.calcite.avatica.DriverVersion; import org.apache.calcite.avatica.Meta; import org.apache.calcite.avatica.UnregisteredDriver; -import org.apache.kylin.jdbc.util.Log4jConfigurer; /** *

@@ -73,7 +72,6 @@ public class Driver extends UnregisteredDriver { public static final String CONNECT_STRING_PREFIX = "jdbc:kylin:"; static { try { - Log4jConfigurer.initLogger(); DriverManager.registerDriver(new Driver()); } catch (SQLException e) { throw new RuntimeException("Error occurred while registering JDBC driver " + Driver.class.getName() + ": " + e.toString()); diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java index fdcc91b..8059dd0 100644 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java +++ b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java @@ -35,8 +35,6 @@ import org.apache.calcite.avatica.NoSuchStatementException; import org.apache.calcite.avatica.QueryState; import org.apache.calcite.avatica.remote.TypedValue; -import com.google.common.collect.ImmutableList; - /** * Implementation of Avatica interface */ @@ -64,7 +62,7 @@ public class KylinMeta extends MetaImpl { @Override public ExecuteResult execute(StatementHandle sh, List parameterValues, long maxRowCount) throws NoSuchStatementException { final MetaResultSet metaResultSet = MetaResultSet.create(sh.connectionId, sh.id, false, sh.signature, null); - return new ExecuteResult(ImmutableList.of(metaResultSet)); + return new ExecuteResult(Collections.singletonList(metaResultSet)); } // mimic from CalciteMetaImpl, real execution happens via callback in KylinResultSet.execute() @@ -78,7 +76,7 @@ public class KylinMeta extends MetaImpl { } callback.execute(); final MetaResultSet metaResultSet = MetaResultSet.create(sh.connectionId, sh.id, false, sh.signature, null); - return new ExecuteResult(ImmutableList.of(metaResultSet)); + return new ExecuteResult(Collections.singletonList(metaResultSet)); } catch (SQLException e) { throw new RuntimeException(e); } diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/util/Log4jConfigurer.java b/jdbc/src/main/java/org/apache/kylin/jdbc/util/Log4jConfigurer.java deleted file mode 100644 index d68a46f..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/util/Log4jConfigurer.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.kylin.jdbc.util; - -import java.io.Closeable; -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; - -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; - -/** - * Created by dongli on 11/24/15. - */ -public class Log4jConfigurer { - private static boolean INITIALIZED = false; - - public static void initLogger() { - if (!INITIALIZED && !isConfigured()) { - InputStream is = Log4jConfigurer.class.getClassLoader().getResourceAsStream("kylin-log4j.properties"); - PropertyConfigurator.configure(is); - closeQuietly(is); - } - INITIALIZED = true; - } - - private static boolean isConfigured() { - if (LogManager.getRootLogger().getAllAppenders().hasMoreElements()) { - return true; - } else { - Enumeration loggers = LogManager.getCurrentLoggers(); - while (loggers.hasMoreElements()) { - Logger logger = (Logger) loggers.nextElement(); - if (logger.getAllAppenders().hasMoreElements()) - return true; - } - } - return false; - } - - public static void closeQuietly(Closeable closeable) { - try { - if (closeable != null) { - closeable.close(); - } - } catch (IOException ioe) { - // ignore - } - } - -} diff --git a/jdbc/src/main/resources/kylin-log4j.properties b/jdbc/src/main/resources/kylin-log4j.properties deleted file mode 100644 index e7201b3..0000000 --- a/jdbc/src/main/resources/kylin-log4j.properties +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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. -# - -# enable this by -Dlog4j.configuration=kylin-log4j.properties - -log4j.rootLogger=INFO,stdout - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p [%t %c{1}:%L]: %m%n - -#log4j.logger.org.apache.hadoop=ERROR -log4j.logger.org.apache.kylin=DEBUG -log4j.logger.org.springframework=WARN diff --git a/pom.xml b/pom.xml index f446a2d..0ee3703 100644 --- a/pom.xml +++ b/pom.xml @@ -540,6 +540,11 @@ org.apache.maven.plugins + maven-shade-plugin + 2.4.3 + + + org.apache.maven.plugins maven-war-plugin 2.6 -- 2.7.4 (Apple Git-66)