Repository: kylin Updated Branches: refs/heads/master f36b1341b -> 7976b5fc7
KYLIN-2361 revert again because ordered class loader is not guaranteed to work Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/7976b5fc Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/7976b5fc Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/7976b5fc Branch: refs/heads/master Commit: 7976b5fc714f5e73734b3037c05fc2601ea17662 Parents: f36b134 Author: Hongbin Ma <mahong...@apache.org> Authored: Sun Mar 12 17:18:27 2017 +0800 Committer: Hongbin Ma <mahong...@apache.org> Committed: Sun Mar 12 17:18:37 2017 +0800 ---------------------------------------------------------------------- build/deploy/context.xml | 46 +-- build/deploy/server.xml | 63 ++-- build/script/download-tomcat.sh | 8 +- pom.xml | 2 +- .../java/org/apache/kylin/rest/DebugTomcat.java | 10 +- .../kylin/ext/CustomizedWebappClassloader.java | 8 +- .../kylin/ext/OrderedWebResourceRoot.java | 286 ------------------- .../kylin/ext/WebappOrderedClassLoader.java | 66 ----- 8 files changed, 53 insertions(+), 436 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/7976b5fc/build/deploy/context.xml ---------------------------------------------------------------------- diff --git a/build/deploy/context.xml b/build/deploy/context.xml index da4777b..38c6ec8 100644 --- a/build/deploy/context.xml +++ b/build/deploy/context.xml @@ -1,32 +1,38 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version='1.0' encoding='utf-8'?> <!-- - 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. ---> + ~ 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. + --> <!-- The contents of this file will be loaded for each web application --> <Context> - <!-- Default set of monitored resources. If one of these changes, the --> - <!-- web application will be reloaded. --> + <!-- Default set of monitored resources --> <WatchedResource>WEB-INF/web.xml</WatchedResource> - <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> + + <!-- Uncomment this to enable Comet connection tacking (provides events + on session expiration as well as webapp lifecycle) --> + <!-- + <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" /> + --> + <Loader loaderClass="org.apache.kylin.ext.CustomizedWebappClassloader"/> - <JarScanner scanClassPath="false" /> + </Context> http://git-wip-us.apache.org/repos/asf/kylin/blob/7976b5fc/build/deploy/server.xml ---------------------------------------------------------------------- diff --git a/build/deploy/server.xml b/build/deploy/server.xml index bea6146..42fab2d 100644 --- a/build/deploy/server.xml +++ b/build/deploy/server.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -20,12 +20,13 @@ Documentation at /docs/config/server.html --> <Server port="9005" shutdown="SHUTDOWN"> - <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html <Listener className="org.apache.catalina.security.SecurityListener" /> --> <!--APR library loader. Documentation at /docs/apr.html --> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> + <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html --> + <Listener className="org.apache.catalina.core.JasperListener" /> <!-- Prevent memory leaks due to use of particular java/javax APIs--> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> @@ -61,61 +62,29 @@ <!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Documentation at : - Java HTTP Connector: /docs/config/http.html + Java HTTP Connector: /docs/config/http.html (blocking & non-blocking) Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html - Define a non-SSL/TLS HTTP/1.1 Connector on port 8080 + Define a non-SSL HTTP/1.1 Connector on port 8080 --> <Connector port="7070" protocol="HTTP/1.1" connectionTimeout="20000" - redirectPort="9443" + redirectPort="7443" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla,traviata" compressableMimeType="text/html,text/xml,text/javascript,application/javascript,application/json,text/css,text/plain" /> <!-- A "Connector" using the shared thread pool--> - <!-- - <Connector executor="tomcatThreadPool" - port="8080" protocol="HTTP/1.1" - connectionTimeout="20000" - redirectPort="8443" /> - --> - <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 - This connector uses the NIO implementation. The default - SSLImplementation will depend on the presence of the APR/native - library and the useOpenSSL attribute of the - AprLifecycleListener. - Either JSSE or OpenSSL style configuration may be used regardless of - the SSLImplementation selected. JSSE style configuration is used below. - --> - <!-- - <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" - maxThreads="150" SSLEnabled="true"> - <SSLHostConfig> - <Certificate certificateKeystoreFile="conf/localhost-rsa.jks" - type="RSA" /> - </SSLHostConfig> - </Connector> - --> - <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2 - This connector uses the APR/native implementation which always uses - OpenSSL for TLS. - Either JSSE or OpenSSL style configuration may be used. OpenSSL style - configuration is used below. - --> - <!-- - <Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol" - maxThreads="150" SSLEnabled="true" > - <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" /> - <SSLHostConfig> - <Certificate certificateKeyFile="conf/localhost-rsa-key.pem" - certificateFile="conf/localhost-rsa-cert.pem" - certificateChainFile="conf/localhost-rsa-chain.pem" - type="RSA" /> - </SSLHostConfig> - </Connector> - --> + <!-- Define a SSL HTTP/1.1 Connector on port 8443 + This connector uses the BIO implementation that requires the JSSE + style configuration. When using the APR/native implementation, the + OpenSSL style configuration is required as described in the APR/native + documentation --> + <Connector port="7443" protocol="org.apache.coyote.http11.Http11Protocol" + maxThreads="150" SSLEnabled="true" scheme="https" secure="true" + keystoreFile="conf/.keystore" keystorePass="changeit" + clientAuth="false" sslProtocol="TLS" /> <!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="9009" protocol="AJP/1.3" redirectPort="9443" /> @@ -163,7 +132,7 @@ Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" - prefix="localhost_access_log" suffix=".txt" + prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> http://git-wip-us.apache.org/repos/asf/kylin/blob/7976b5fc/build/script/download-tomcat.sh ---------------------------------------------------------------------- diff --git a/build/script/download-tomcat.sh b/build/script/download-tomcat.sh index bdfe351..b3aa509 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="8.5.9" -tomcat_pkg_md5="b41270a64b7774c964e4bec813eea2ed" +tomcat_pkg_version="7.0.69" +tomcat_pkg_md5="10a071e5169a1a8b14ff35a0ad181052" 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-8/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-7/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-8/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-7/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/7976b5fc/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index bb7fde9..30506e5 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ <cglib.version>3.2.4</cglib.version> <supercsv.version>2.4.0</supercsv.version> <cors.version>2.5</cors.version> - <tomcat.version>8.5.9</tomcat.version> + <tomcat.version>7.0.69</tomcat.version> <t-digest.version>3.1</t-digest.version> <!-- REST Service --> http://git-wip-us.apache.org/repos/asf/kylin/blob/7976b5fc/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 1b47f79..cd6768e 100644 --- a/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java +++ b/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java @@ -21,13 +21,11 @@ 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; @@ -129,12 +127,6 @@ 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; - } - }); // tomcat start tomcat.start(); http://git-wip-us.apache.org/repos/asf/kylin/blob/7976b5fc/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 bbf4053..ec41842 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,12 +18,14 @@ 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 WebappOrderedClassLoader { +public class CustomizedWebappClassloader extends ParallelWebappClassLoader { /** * Set of package names which are not allowed to be loaded from a webapp * class loader without delegating first. @@ -43,7 +45,7 @@ public class CustomizedWebappClassloader extends WebappOrderedClassLoader { * @param name class name * @return true if the class should be filtered */ - protected boolean filter(String name, boolean isClassName) { + protected boolean filter(String name) { if (name == null) return false; @@ -60,6 +62,6 @@ public class CustomizedWebappClassloader extends WebappOrderedClassLoader { return true; } - return super.filter(name, isClassName); + return super.filter(name); } } http://git-wip-us.apache.org/repos/asf/kylin/blob/7976b5fc/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 deleted file mode 100644 index 9784bd8..0000000 --- a/tomcat-ext/src/main/java/org/apache/kylin/ext/OrderedWebResourceRoot.java +++ /dev/null @@ -1,286 +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.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/7976b5fc/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 deleted file mode 100644 index 6a90e55..0000000 --- a/tomcat-ext/src/main/java/org/apache/kylin/ext/WebappOrderedClassLoader.java +++ /dev/null @@ -1,66 +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.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