You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by bi...@apache.org on 2017/02/06 06:56:13 UTC

[1/3] kylin git commit: KYLIN-2361 add Tomcat8 ordered class loader

Repository: kylin
Updated Branches:
  refs/heads/master 19252848e -> 4047e8dc5


KYLIN-2361 add Tomcat8 ordered class loader


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

Branch: refs/heads/master
Commit: 9a3bd71c8e5ce9dc13e38560efc556dc862819a1
Parents: 2b60ac6
Author: Billy Liu <bi...@apache.org>
Authored: Sat Feb 4 11:41:49 2017 +0800
Committer: Billy Liu <bi...@apache.org>
Committed: Sat Feb 4 11:42:02 2017 +0800

----------------------------------------------------------------------
 .../kylin/ext/CustomizedWebappClassloader.java  |   4 +-
 .../kylin/ext/OrderedWebResourceRoot.java       | 286 +++++++++++++++++++
 .../kylin/ext/WebappOrderedClassLoader.java     |  66 +++++
 3 files changed, 353 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/9a3bd71c/tomcat-ext/src/main/java/org/apache/kylin/ext/CustomizedWebappClassloader.java
----------------------------------------------------------------------
diff --git a/tomcat-ext/src/main/java/org/apache/kylin/ext/CustomizedWebappClassloader.java b/tomcat-ext/src/main/java/org/apache/kylin/ext/CustomizedWebappClassloader.java
index f241865..bbf4053 100644
--- a/tomcat-ext/src/main/java/org/apache/kylin/ext/CustomizedWebappClassloader.java
+++ b/tomcat-ext/src/main/java/org/apache/kylin/ext/CustomizedWebappClassloader.java
@@ -18,14 +18,12 @@
 
 package org.apache.kylin.ext;
 
-import org.apache.catalina.loader.ParallelWebappClassLoader;
-
 /**
  * simple extension to standard ParallelWebappClassLoader
  * the only difference is that CustomizedWebappClassloader is able to delegate more packages
  * to parent classloaders
  */
-public class CustomizedWebappClassloader extends ParallelWebappClassLoader {
+public class CustomizedWebappClassloader extends WebappOrderedClassLoader {
     /**
      * Set of package names which are not allowed to be loaded from a webapp
      * class loader without delegating first.

http://git-wip-us.apache.org/repos/asf/kylin/blob/9a3bd71c/tomcat-ext/src/main/java/org/apache/kylin/ext/OrderedWebResourceRoot.java
----------------------------------------------------------------------
diff --git a/tomcat-ext/src/main/java/org/apache/kylin/ext/OrderedWebResourceRoot.java b/tomcat-ext/src/main/java/org/apache/kylin/ext/OrderedWebResourceRoot.java
new file mode 100644
index 0000000..9784bd8
--- /dev/null
+++ b/tomcat-ext/src/main/java/org/apache/kylin/ext/OrderedWebResourceRoot.java
@@ -0,0 +1,286 @@
+/*
+ * 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.ext;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.LifecycleState;
+import org.apache.catalina.TrackedWebResource;
+import org.apache.catalina.WebResource;
+import org.apache.catalina.WebResourceRoot;
+import org.apache.catalina.WebResourceSet;
+
+public class OrderedWebResourceRoot implements WebResourceRoot {
+
+    private static final String WEB_INF_LIB_PATH = "/WEB-INF/lib";
+
+    private static final Comparator<WebResource> WEB_RESOURCE_COMPARATOR = new Comparator<WebResource>() {
+        @Override
+        public int compare(WebResource o1, WebResource o2) {
+            return o1.getName().compareTo(o2.getName());
+        }
+    };
+
+    private WebResourceRoot delegate;
+
+    public OrderedWebResourceRoot(WebResourceRoot delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    public WebResource[] listResources(String path) {
+        WebResource[] webResources = delegate.listResources(path);
+
+        if (WEB_INF_LIB_PATH.equals(path)) {
+            Arrays.sort(webResources, WEB_RESOURCE_COMPARATOR);
+        }
+
+        return webResources;
+    }
+
+    @Override
+    public void addLifecycleListener(LifecycleListener listener) {
+        delegate.addLifecycleListener(listener);
+    }
+
+    @Override
+    public LifecycleListener[] findLifecycleListeners() {
+        return delegate.findLifecycleListeners();
+    }
+
+    @Override
+    public void removeLifecycleListener(LifecycleListener listener) {
+        delegate.removeLifecycleListener(listener);
+    }
+
+    @Override
+    public void init() throws LifecycleException {
+        delegate.init();
+    }
+
+    @Override
+    public void start() throws LifecycleException {
+        delegate.start();
+    }
+
+    @Override
+    public void stop() throws LifecycleException {
+        delegate.stop();
+    }
+
+    @Override
+    public void destroy() throws LifecycleException {
+        delegate.destroy();
+    }
+
+    @Override
+    public LifecycleState getState() {
+        return delegate.getState();
+    }
+
+    @Override
+    public String getStateName() {
+        return delegate.getStateName();
+    }
+
+    @Override
+    public WebResource getResource(String path) {
+        return delegate.getResource(path);
+    }
+
+    @Override
+    public WebResource[] getResources(String path) {
+        return delegate.getResources(path);
+    }
+
+    @Override
+    public WebResource getClassLoaderResource(String path) {
+        return delegate.getClassLoaderResource(path);
+    }
+
+    @Override
+    public WebResource[] getClassLoaderResources(String path) {
+        return delegate.getClassLoaderResources(path);
+    }
+
+    @Override
+    public String[] list(String path) {
+        return delegate.list(path);
+    }
+
+    @Override
+    public Set<String> listWebAppPaths(String path) {
+        return delegate.listWebAppPaths(path);
+    }
+
+    @Override
+    public boolean mkdir(String path) {
+        return delegate.mkdir(path);
+    }
+
+    @Override
+    public boolean write(String path, InputStream is, boolean overwrite) {
+        return delegate.write(path, is, overwrite);
+    }
+
+    @Override
+    public void createWebResourceSet(ResourceSetType type, String webAppMount, URL url, String internalPath) {
+        delegate.createWebResourceSet(type, webAppMount, url, internalPath);
+    }
+
+    @Override
+    public void createWebResourceSet(ResourceSetType type, String webAppMount, String base, String archivePath,
+                                     String internalPath) {
+        delegate.createWebResourceSet(type, webAppMount, base, archivePath, internalPath);
+    }
+
+    @Override
+    public void addPreResources(WebResourceSet webResourceSet) {
+        delegate.addPreResources(webResourceSet);
+    }
+
+    @Override
+    public WebResourceSet[] getPreResources() {
+        return delegate.getPreResources();
+    }
+
+    @Override
+    public void addJarResources(WebResourceSet webResourceSet) {
+        delegate.addJarResources(webResourceSet);
+    }
+
+    @Override
+    public WebResourceSet[] getJarResources() {
+        return delegate.getJarResources();
+    }
+
+    @Override
+    public void addPostResources(WebResourceSet webResourceSet) {
+        delegate.addPostResources(webResourceSet);
+    }
+
+    @Override
+    public WebResourceSet[] getPostResources() {
+        return delegate.getPostResources();
+    }
+
+    @Override
+    public Context getContext() {
+        return delegate.getContext();
+    }
+
+    @Override
+    public void setContext(Context context) {
+        delegate.setContext(context);
+    }
+
+    @Override
+    public void setAllowLinking(boolean allowLinking) {
+        delegate.setAllowLinking(allowLinking);
+    }
+
+    @Override
+    public boolean getAllowLinking() {
+        return delegate.getAllowLinking();
+    }
+
+    @Override
+    public void setCachingAllowed(boolean cachingAllowed) {
+        delegate.setCachingAllowed(cachingAllowed);
+    }
+
+    @Override
+    public boolean isCachingAllowed() {
+        return delegate.isCachingAllowed();
+    }
+
+    @Override
+    public void setCacheTtl(long ttl) {
+        delegate.setCacheTtl(ttl);
+    }
+
+    @Override
+    public long getCacheTtl() {
+        return delegate.getCacheTtl();
+    }
+
+    @Override
+    public void setCacheMaxSize(long cacheMaxSize) {
+        delegate.setCacheMaxSize(cacheMaxSize);
+    }
+
+    @Override
+    public long getCacheMaxSize() {
+        return delegate.getCacheMaxSize();
+    }
+
+    @Override
+    public void setCacheObjectMaxSize(int cacheObjectMaxSize) {
+        delegate.setCacheObjectMaxSize(cacheObjectMaxSize);
+    }
+
+    @Override
+    public int getCacheObjectMaxSize() {
+        return delegate.getCacheObjectMaxSize();
+    }
+
+    @Override
+    public void setTrackLockedFiles(boolean trackLockedFiles) {
+        delegate.setTrackLockedFiles(trackLockedFiles);
+    }
+
+    @Override
+    public boolean getTrackLockedFiles() {
+        return delegate.getTrackLockedFiles();
+    }
+
+    @Override
+    public void backgroundProcess() {
+        delegate.backgroundProcess();
+    }
+
+    @Override
+    public void registerTrackedResource(TrackedWebResource trackedResource) {
+        delegate.registerTrackedResource(trackedResource);
+    }
+
+    @Override
+    public void deregisterTrackedResource(TrackedWebResource trackedResource) {
+        delegate.deregisterTrackedResource(trackedResource);
+    }
+
+    @Override
+    public List<URL> getBaseUrls() {
+        return delegate.getBaseUrls();
+    }
+
+    @Override
+    public void gc() {
+        delegate.gc();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/kylin/blob/9a3bd71c/tomcat-ext/src/main/java/org/apache/kylin/ext/WebappOrderedClassLoader.java
----------------------------------------------------------------------
diff --git a/tomcat-ext/src/main/java/org/apache/kylin/ext/WebappOrderedClassLoader.java b/tomcat-ext/src/main/java/org/apache/kylin/ext/WebappOrderedClassLoader.java
new file mode 100644
index 0000000..6a90e55
--- /dev/null
+++ b/tomcat-ext/src/main/java/org/apache/kylin/ext/WebappOrderedClassLoader.java
@@ -0,0 +1,66 @@
+/*
+ * 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.ext;
+
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.WebResourceRoot;
+import org.apache.catalina.loader.ParallelWebappClassLoader;
+
+/**
+ * Modified from the openwide-java/tomcat-classloader-ordered in https://github.com/openwide-java/tomcat-classloader-ordered
+ *
+ * This classloader is designed to return the jar of WEB-INF lib in alphabetical order as it was the case with Tomcat
+ * 7.x.
+ *
+ * See the discussion in https://bz.apache.org/bugzilla/show_bug.cgi?id=57129 for more information.
+ */
+public class WebappOrderedClassLoader extends ParallelWebappClassLoader {
+
+    public WebappOrderedClassLoader() {
+    }
+
+    public WebappOrderedClassLoader(ClassLoader parent) {
+        super(parent);
+    }
+
+    @Override
+    public void setResources(WebResourceRoot resources) {
+        super.setResources(new OrderedWebResourceRoot(resources));
+    }
+
+    @Override
+    public WebappOrderedClassLoader copyWithoutTransformers() {
+        WebappOrderedClassLoader result = new WebappOrderedClassLoader(getParent());
+
+        super.copyStateWithoutTransformers(result);
+
+        try {
+            result.start();
+        } catch (LifecycleException e) {
+            throw new IllegalStateException(e);
+        }
+
+        return result;
+    }
+
+    @Override
+    protected Object getClassLoadingLock(String className) {
+        return this;
+    }
+}
\ No newline at end of file


[3/3] kylin git commit: Merge branch 'KYLIN-2361'

Posted by bi...@apache.org.
Merge branch 'KYLIN-2361'


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

Branch: refs/heads/master
Commit: 4047e8dc5bf8aad7c8db79abb5ef2c3be15cd622
Parents: 1925284 9a3bd71
Author: Billy Liu <bi...@apache.org>
Authored: Mon Feb 6 14:37:46 2017 +0800
Committer: Billy Liu <bi...@apache.org>
Committed: Mon Feb 6 14:37:46 2017 +0800

----------------------------------------------------------------------
 build/script/download-tomcat.sh                 |   8 +-
 pom.xml                                         |   2 +-
 .../java/org/apache/kylin/rest/DebugTomcat.java |  16 +-
 .../kylin/ext/CustomizedWebappClassloader.java  |   9 +-
 .../kylin/ext/OrderedWebResourceRoot.java       | 286 +++++++++++++++++++
 .../kylin/ext/WebappOrderedClassLoader.java     |  66 +++++
 6 files changed, 369 insertions(+), 18 deletions(-)
----------------------------------------------------------------------



[2/3] kylin git commit: KYLIN-2361 Upgrade Tomcat 8.5.9

Posted by bi...@apache.org.
KYLIN-2361 Upgrade Tomcat 8.5.9


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

Branch: refs/heads/master
Commit: 2b60ac6a42741ca70d63e6680a0fbe9aeed7d46e
Parents: a058bfb
Author: Billy Liu <bi...@apache.org>
Authored: Wed Jan 18 17:19:04 2017 +0800
Committer: Billy Liu <bi...@apache.org>
Committed: Sat Feb 4 11:42:02 2017 +0800

----------------------------------------------------------------------
 build/script/download-tomcat.sh                     |  8 ++++----
 pom.xml                                             |  2 +-
 .../java/org/apache/kylin/rest/DebugTomcat.java     | 16 +++++++++-------
 .../kylin/ext/CustomizedWebappClassloader.java      |  5 ++---
 4 files changed, 16 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/2b60ac6a/build/script/download-tomcat.sh
----------------------------------------------------------------------
diff --git a/build/script/download-tomcat.sh b/build/script/download-tomcat.sh
index b3aa509..bdfe351 100755
--- a/build/script/download-tomcat.sh
+++ b/build/script/download-tomcat.sh
@@ -27,19 +27,19 @@ if [[ `uname -a` =~ "Darwin" ]]; then
     alias md5cmd="md5 -q"
 fi
 
-tomcat_pkg_version="7.0.69"
-tomcat_pkg_md5="10a071e5169a1a8b14ff35a0ad181052"
+tomcat_pkg_version="8.5.9"
+tomcat_pkg_md5="b41270a64b7774c964e4bec813eea2ed"
 
 if [ ! -f "build/apache-tomcat-${tomcat_pkg_version}.tar.gz" ]
 then
     echo "no binary file found"
-    wget --directory-prefix=build/ http://archive.apache.org/dist/tomcat/tomcat-7/v${tomcat_pkg_version}/bin/apache-tomcat-${tomcat_pkg_version}.tar.gz || echo "Download tomcat failed"
+    wget --directory-prefix=build/ http://archive.apache.org/dist/tomcat/tomcat-8/v${tomcat_pkg_version}/bin/apache-tomcat-${tomcat_pkg_version}.tar.gz || echo "Download tomcat failed"
 else
     if [ `md5cmd build/apache-tomcat-${tomcat_pkg_version}.tar.gz | awk '{print $1}'` != "${tomcat_pkg_md5}" ]
     then
         echo "md5 check failed"
         rm build/apache-tomcat-${tomcat_pkg_version}.tar.gz
-        wget --directory-prefix=build/ http://archive.apache.org/dist/tomcat/tomcat-7/v${tomcat_pkg_version}/bin/apache-tomcat-${tomcat_pkg_version}.tar.gz || echo "download tomcat failed"
+        wget --directory-prefix=build/ http://archive.apache.org/dist/tomcat/tomcat-8/v${tomcat_pkg_version}/bin/apache-tomcat-${tomcat_pkg_version}.tar.gz || echo "download tomcat failed"
     fi
 fi
 unalias md5cmd

http://git-wip-us.apache.org/repos/asf/kylin/blob/2b60ac6a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index bf33e07..b82eee2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -101,7 +101,7 @@
         <cglib.version>3.2.4</cglib.version>
         <supercsv.version>2.4.0</supercsv.version>
         <cors.version>2.5</cors.version>
-        <tomcat.version>7.0.69</tomcat.version>
+        <tomcat.version>8.5.9</tomcat.version>
         <t-digest.version>3.1</t-digest.version>
 
         <!-- REST Service -->

http://git-wip-us.apache.org/repos/asf/kylin/blob/2b60ac6a/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java b/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
index 3461e1d..1b47f79 100644
--- a/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
+++ b/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
@@ -21,11 +21,13 @@ package org.apache.kylin.rest;
 import org.apache.catalina.Context;
 import org.apache.catalina.core.AprLifecycleListener;
 import org.apache.catalina.core.StandardServer;
-import org.apache.catalina.deploy.ErrorPage;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.util.Shell;
 import org.apache.kylin.common.KylinConfig;
+import org.apache.tomcat.JarScanFilter;
+import org.apache.tomcat.JarScanType;
+import org.apache.tomcat.util.descriptor.web.ErrorPage;
 
 import java.io.File;
 import java.lang.reflect.Field;
@@ -127,12 +129,12 @@ public class DebugTomcat {
         notFound.setLocation("/index.html");
         webContext.addErrorPage(notFound);
         webContext.addWelcomeFile("index.html");
-//        webContext.getJarScanner().setJarScanFilter(new JarScanFilter() {
-//            @Override
-//            public boolean check(JarScanType arg0, String arg1) {
-//                return false;
-//            }
-//        });
+        webContext.getJarScanner().setJarScanFilter(new JarScanFilter() {
+            @Override
+            public boolean check(JarScanType arg0, String arg1) {
+                return false;
+            }
+        });
 
         // tomcat start
         tomcat.start();

http://git-wip-us.apache.org/repos/asf/kylin/blob/2b60ac6a/tomcat-ext/src/main/java/org/apache/kylin/ext/CustomizedWebappClassloader.java
----------------------------------------------------------------------
diff --git a/tomcat-ext/src/main/java/org/apache/kylin/ext/CustomizedWebappClassloader.java b/tomcat-ext/src/main/java/org/apache/kylin/ext/CustomizedWebappClassloader.java
index 816601f..f241865 100644
--- a/tomcat-ext/src/main/java/org/apache/kylin/ext/CustomizedWebappClassloader.java
+++ b/tomcat-ext/src/main/java/org/apache/kylin/ext/CustomizedWebappClassloader.java
@@ -45,7 +45,7 @@ public class CustomizedWebappClassloader extends ParallelWebappClassLoader {
      * @param name class name
      * @return true if the class should be filtered
      */
-    protected boolean filter(String name) {
+    protected boolean filter(String name, boolean isClassName) {
         if (name == null)
             return false;
 
@@ -62,7 +62,6 @@ public class CustomizedWebappClassloader extends ParallelWebappClassLoader {
                 return true;
         }
 
-        //return super.filter(name, isClassName);
-        return false;
+        return super.filter(name, isClassName);
     }
 }