kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaofeng...@apache.org
Subject kylin git commit: KYLIN-1846 minimize dependencies of JDBC driver
Date Sat, 09 Jul 2016 07:20:38 GMT
Repository: kylin
Updated Branches:
  refs/heads/master d48b9aac1 -> f30862eb6


KYLIN-1846 minimize dependencies of JDBC driver

Signed-off-by: shaofengshi <shaofengshi@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/f30862eb
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/f30862eb
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/f30862eb

Branch: refs/heads/master
Commit: f30862eb6a4b2b6c0a2a8c0dbf8e124bf5c6cb9f
Parents: d48b9aa
Author: gaodayue <gaodayue@meituan.com>
Authored: Tue Jul 5 10:23:54 2016 +0800
Committer: shaofengshi <shaofengshi@apache.org>
Committed: Sat Jul 9 15:20:30 2016 +0800

----------------------------------------------------------------------
 jdbc/pom.xml                                    | 69 +++++++++++++-------
 .../main/java/org/apache/kylin/jdbc/Driver.java |  2 -
 .../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, 51 insertions(+), 128 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/f30862eb/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index 3977d85..deb3b49 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -33,15 +33,12 @@
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <shadeBase>org.apache.kylin.jdbc.shaded</shadeBase>
     </properties>
 
     <dependencies>
         <dependency>
             <groupId>org.apache.calcite</groupId>
-            <artifactId>calcite-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.calcite</groupId>
             <artifactId>calcite-avatica</artifactId>
             <exclusions>
                 <exclusion>
@@ -55,22 +52,10 @@
             <artifactId>httpclient</artifactId>
         </dependency>
         <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-        </dependency>
-        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
@@ -81,20 +66,54 @@
     <build>
         <plugins>
             <plugin>
-                <artifactId>maven-assembly-plugin</artifactId>
-                <configuration>
-                    <descriptorRefs>
-                        <descriptorRef>jar-with-dependencies</descriptorRef>
-                    </descriptorRefs>
-                    <appendAssemblyId>false</appendAssemblyId>
-                </configuration>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
                 <executions>
                     <execution>
-                        <id>make-assembly</id>
                         <phase>package</phase>
                         <goals>
-                            <goal>single</goal>
+                            <goal>shade</goal>
                         </goals>
+                        <configuration>
+                            <createDependencyReducedPom>false</createDependencyReducedPom>
+                            <artifactSet>
+                                <!-- jackson is already packaged into calcite-avatica.jar.
To avoid including jackson
+                                twice, we include calcite-avatica which has jackson and exclude
jackson. -->
+                                <excludes>
+                                    <exclude>com.fasterxml.jackson.core:*</exclude>
+                                </excludes>
+                            </artifactSet>
+                            <relocations>
+                                <relocation>
+                                    <pattern>org.apache.calcite</pattern>
+                                    <shadedPattern>${shadeBase}.org.apache.calcite</shadedPattern>
+                                </relocation>
+                                <relocation>
+                                    <pattern>com.fasterxml.jackson</pattern>
+                                    <shadedPattern>${shadeBase}.com.fasterxml.jackson</shadedPattern>
+                                </relocation>
+                                <relocation>
+                                    <pattern>org.apache.commons</pattern>
+                                    <shadedPattern>${shadeBase}.org.apache.commons</shadedPattern>
+                                </relocation>
+                            </relocations>
+                            <filters>
+                                <filter>
+                                    <artifact>*:*</artifact>
+                                    <excludes>
+                                        <exclude>META-INF/*.SF</exclude>
+                                        <exclude>META-INF/*.DSA</exclude>
+                                        <exclude>META-INF/*.RSA</exclude>
+                                    </excludes>
+                                </filter>
+                                <filter>
+                                    <artifact>commons-httpclient:commons-httpclient</artifact>
+                                    <excludes>
+                                        <exclude>META-INF/**</exclude>
+                                    </excludes>
+                                </filter>
+                            </filters>
+                        </configuration>
                     </execution>
                 </executions>
             </plugin>

http://git-wip-us.apache.org/repos/asf/kylin/blob/f30862eb/jdbc/src/main/java/org/apache/kylin/jdbc/Driver.java
----------------------------------------------------------------------
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;
 
 /**
  * <p>
@@ -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());

http://git-wip-us.apache.org/repos/asf/kylin/blob/f30862eb/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java
----------------------------------------------------------------------
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<TypedValue> 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);
         }

http://git-wip-us.apache.org/repos/asf/kylin/blob/f30862eb/jdbc/src/main/java/org/apache/kylin/jdbc/util/Log4jConfigurer.java
----------------------------------------------------------------------
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
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/kylin/blob/f30862eb/jdbc/src/main/resources/kylin-log4j.properties
----------------------------------------------------------------------
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

http://git-wip-us.apache.org/repos/asf/kylin/blob/f30862eb/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7a211fc..752b6ce 100644
--- a/pom.xml
+++ b/pom.xml
@@ -533,6 +533,11 @@
                 </plugin>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-shade-plugin</artifactId>
+                    <version>2.4.3</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-war-plugin</artifactId>
                     <version>2.6</version>
                     <configuration>


Mime
View raw message