You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by zj...@apache.org on 2020/01/03 02:23:28 UTC
[zeppelin] branch web_angular updated: [ZEPPELIN-4515] Have Jetty
Server support multiple wars
This is an automated email from the ASF dual-hosted git repository.
zjffdu pushed a commit to branch web_angular
in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/web_angular by this push:
new 028e6ce [ZEPPELIN-4515] Have Jetty Server support multiple wars
028e6ce is described below
commit 028e6ceeb5e4df5d6f573d19432f273d50b60683
Author: fdai <fd...@twitter.com>
AuthorDate: Tue Dec 31 17:25:14 2019 -0800
[ZEPPELIN-4515] Have Jetty Server support multiple wars
### What is this PR for?
We have a new UI with version angular 8, which will be retiring the old angularjs.
both of the angular frameworks may need to co-exist for a while until the new UI is stable.
Have the Jetty server support multiple wars with different port (8080 and 9090)
### What type of PR is it?
[Feature ]
### Todos
retire angularJS completely in the future.
### What is the Jira issue?
* [ZEPPELIN-4515](https://issues.apache.org/jira/browse/ZEPPELIN-4515) Have Jetty Server support multiple wars
Add multiple war support for the Zeppelin Server.
two ports (default is 8080 and 9090) will be living for a while until we are comfortable with the new UI.
### How should this be tested?
The default port for new UI is 9090, testing via http://localhost:9090
### Screenshots (if appropriate)
### Questions:
* Does the licenses files need update? **No**
* Is there breaking changes for older versions? **No**
* Does this needs documentation? **No**
Author: fdai <fd...@twitter.com>
Closes #3571 from fred521/add_angular_to_jetty and squashes the following commits:
196547605 [fdai] add next context path
93e2a4fdc [fdai] clean the code
8606ce064 [fdai] use one port two support multiple wars in jetty
f08602e20 [fdai] remove unrelated notebook
0f9c10367 [fdai] add angular support for jetty
---
bin/common.sh | 12 ++-
bin/zeppelin-daemon.sh | 1 +
bin/zeppelin.sh | 1 +
zeppelin-distribution/pom.xml | 6 ++
.../src/assemble/distribution.xml | 4 +-
.../zeppelin/conf/ZeppelinConfiguration.java | 1 +
.../org/apache/zeppelin/server/ZeppelinServer.java | 92 +++++++++++-----------
.../apache/zeppelin/rest/AbstractTestRestApi.java | 3 +
zeppelin-web-angular/package.json | 2 +-
zeppelin-web-angular/pom.xml | 2 +-
10 files changed, 74 insertions(+), 50 deletions(-)
diff --git a/bin/common.sh b/bin/common.sh
index 0ebae66..4e86ce9 100644
--- a/bin/common.sh
+++ b/bin/common.sh
@@ -44,7 +44,15 @@ if [[ -z "${ZEPPELIN_WAR}" ]]; then
if [[ -d "${ZEPPELIN_HOME}/zeppelin-web/dist" ]]; then
export ZEPPELIN_WAR="${ZEPPELIN_HOME}/zeppelin-web/dist"
else
- export ZEPPELIN_WAR=$(find -L "${ZEPPELIN_HOME}" -name "zeppelin-web*.war")
+ export ZEPPELIN_WAR=$(find -L "${ZEPPELIN_HOME}" -name "zeppelin-web-[0-9]*.war")
+ fi
+fi
+
+if [[ -z "${ZEPPELIN_ANGULAR_WAR}" ]]; then
+ if [[ -d "${ZEPPELIN_HOME}/zeppelin-web/dist" ]]; then
+ export ZEPPELIN_ANGULAR_WAR="${ZEPPELIN_HOME}/zeppelin-web-angular/dist/zeppelin"
+ else
+ export ZEPPELIN_ANGULAR_WAR=$(find -L "${ZEPPELIN_HOME}" -name "zeppelin-web-angular*.war")
fi
fi
@@ -102,7 +110,7 @@ function getZeppelinVersion(){
exit 0
}
-# Text encoding for
+# Text encoding for
# read/write job into files,
# receiving/displaying query/result.
if [[ -z "${ZEPPELIN_ENCODING}" ]]; then
diff --git a/bin/zeppelin-daemon.sh b/bin/zeppelin-daemon.sh
index e898849..0ce9808 100755
--- a/bin/zeppelin-daemon.sh
+++ b/bin/zeppelin-daemon.sh
@@ -81,6 +81,7 @@ addJarInDir "${ZEPPELIN_HOME}/zeppelin-interpreter/target/lib"
addJarInDir "${ZEPPELIN_HOME}/zeppelin-zengine/target/lib"
addJarInDir "${ZEPPELIN_HOME}/zeppelin-server/target/lib"
addJarInDir "${ZEPPELIN_HOME}/zeppelin-web/target/lib"
+addJarInDir "${ZEPPELIN_HOME}/zeppelin-web-angular/target/lib"
CLASSPATH+=":${ZEPPELIN_CLASSPATH}"
diff --git a/bin/zeppelin.sh b/bin/zeppelin.sh
index a13f9db..5509e4f 100755
--- a/bin/zeppelin.sh
+++ b/bin/zeppelin.sh
@@ -70,6 +70,7 @@ addJarInDir "${ZEPPELIN_HOME}/zeppelin-interpreter/target/lib"
addJarInDir "${ZEPPELIN_HOME}/zeppelin-zengine/target/lib"
addJarInDir "${ZEPPELIN_HOME}/zeppelin-server/target/lib"
addJarInDir "${ZEPPELIN_HOME}/zeppelin-web/target/lib"
+addJarInDir "${ZEPPELIN_HOME}/zeppelin-web-angular/target/lib"
ZEPPELIN_CLASSPATH="$CLASSPATH:$ZEPPELIN_CLASSPATH"
diff --git a/zeppelin-distribution/pom.xml b/zeppelin-distribution/pom.xml
index 2710670..380e7a2 100644
--- a/zeppelin-distribution/pom.xml
+++ b/zeppelin-distribution/pom.xml
@@ -85,6 +85,12 @@
<version>${project.version}</version>
<type>war</type>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>zeppelin-web-angular</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
</dependencies>
<build>
diff --git a/zeppelin-distribution/src/assemble/distribution.xml b/zeppelin-distribution/src/assemble/distribution.xml
index 0c5e8b6..0b18b4a 100644
--- a/zeppelin-distribution/src/assemble/distribution.xml
+++ b/zeppelin-distribution/src/assemble/distribution.xml
@@ -26,7 +26,7 @@
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<baseDirectory>zeppelin-${project.version}</baseDirectory>
-
+
<dependencySets>
<dependencySet>
<!-- Enable access to all projects in the current multimodule build!
@@ -34,6 +34,7 @@
<!-- Now, select which projects to include in this module-set. -->
<includes>
<include>${project.groupId}:zeppelin-web</include>
+ <include>${project.groupId}:zeppelin-web-angular</include>
</includes>
<useProjectArtifact>false</useProjectArtifact>
<useTransitiveDependencies>false</useTransitiveDependencies>
@@ -42,6 +43,7 @@
<outputDirectory>/lib</outputDirectory>
<excludes>
<exclude>${project.groupId}:zeppelin-web</exclude>
+ <exclude>${project.groupId}:zeppelin-web-angular</exclude>
</excludes>
<useProjectArtifact>false</useProjectArtifact>
<useTransitiveFiltering>true</useTransitiveFiltering>
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
index 2a6e0bb..a6123ec 100644
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
+++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
@@ -812,6 +812,7 @@ public class ZeppelinConfiguration extends XMLConfiguration {
ZEPPELIN_SSL_TRUSTSTORE_TYPE("zeppelin.ssl.truststore.type", null),
ZEPPELIN_SSL_TRUSTSTORE_PASSWORD("zeppelin.ssl.truststore.password", null),
ZEPPELIN_WAR("zeppelin.war", "zeppelin-web/dist"),
+ ZEPPELIN_ANGULAR_WAR("zeppelin.angular.war", "zeppelin-web-angular/dist"),
ZEPPELIN_WAR_TEMPDIR("zeppelin.war.tempdir", "webapps"),
ZEPPELIN_INTERPRETER_JSON("zeppelin.interpreter.setting", "interpreter-setting.json"),
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
index f9d8e8b..966f5b5 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
@@ -97,6 +97,7 @@ import org.slf4j.LoggerFactory;
/** Main class of Zeppelin. */
public class ZeppelinServer extends ResourceConfig {
private static final Logger LOG = LoggerFactory.getLogger(ZeppelinServer.class);
+ private static final String WEB_APP_CONTEXT_NEXT = "/next";
public static Server jettyWebServer;
public static ServiceLocator sharedServiceLocator;
@@ -119,9 +120,6 @@ public class ZeppelinServer extends ResourceConfig {
ContextHandlerCollection contexts = new ContextHandlerCollection();
jettyWebServer.setHandler(contexts);
- // Web UI
- final WebAppContext webApp = setupWebAppContext(contexts, conf);
-
sharedServiceLocator = ServiceLocatorFactory.getInstance().create("shared-locator");
ServiceLocatorUtilities.enableImmediateScope(sharedServiceLocator);
ServiceLocatorUtilities.addClasses(sharedServiceLocator,
@@ -180,25 +178,12 @@ public class ZeppelinServer extends ResourceConfig {
}
});
- webApp.addEventListener(
- new ServletContextListener() {
- @Override
- public void contextInitialized(ServletContextEvent servletContextEvent) {
- servletContextEvent
- .getServletContext()
- .setAttribute(ServletProperties.SERVICE_LOCATOR, sharedServiceLocator);
- }
-
- @Override
- public void contextDestroyed(ServletContextEvent servletContextEvent) {}
- });
-
- // Create `ZeppelinServer` using reflection and setup REST Api
- setupRestApiContextHandler(webApp, conf);
-
- // Notebook server
- setupNotebookServer(webApp, conf, sharedServiceLocator);
+ // Multiple Web UI
+ final WebAppContext defaultWebApp = setupWebAppContext(contexts, conf, conf.getString(ConfVars.ZEPPELIN_WAR), conf.getServerContextPath());
+ final WebAppContext nextWebApp = setupWebAppContext(contexts, conf, conf.getString(ConfVars.ZEPPELIN_ANGULAR_WAR), WEB_APP_CONTEXT_NEXT);
+ initWebApp(defaultWebApp);
+ initWebApp(nextWebApp);
// Cluster Manager Server
setupClusterManagerServer(sharedServiceLocator);
@@ -304,14 +289,18 @@ public class ZeppelinServer extends ResourceConfig {
conf.getInt(ConfVars.ZEPPELIN_SERVER_JETTY_THREAD_POOL_MIN),
conf.getInt(ConfVars.ZEPPELIN_SERVER_JETTY_THREAD_POOL_TIMEOUT));
final Server server = new Server(threadPool);
- ServerConnector connector;
+ initServerConnector(server, conf.getServerPort(), conf.getServerSslPort());
+ return server;
+ }
+ private static void initServerConnector(Server server, int port, int sslPort) {
+ ServerConnector connector;
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.addCustomizer(new ForwardedRequestCustomizer());
if (conf.useSsl()) {
- LOG.debug("Enabling SSL for Zeppelin Server on port " + conf.getServerSslPort());
+ LOG.debug("Enabling SSL for Zeppelin Server on port " + sslPort);
httpConfig.setSecureScheme("https");
- httpConfig.setSecurePort(conf.getServerSslPort());
+ httpConfig.setSecurePort(sslPort);
httpConfig.setOutputBufferSize(32768);
httpConfig.setResponseHeaderSize(8192);
httpConfig.setSendServerVersion(true);
@@ -321,28 +310,20 @@ public class ZeppelinServer extends ResourceConfig {
httpsConfig.addCustomizer(src);
connector =
- new ServerConnector(
- server,
- new SslConnectionFactory(getSslContextFactory(conf), HttpVersion.HTTP_1_1.asString()),
- new HttpConnectionFactory(httpsConfig));
+ new ServerConnector(
+ server,
+ new SslConnectionFactory(getSslContextFactory(conf), HttpVersion.HTTP_1_1.asString()),
+ new HttpConnectionFactory(httpsConfig));
} else {
connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
+ connector.setPort(port);
}
-
configureRequestHeaderSize(conf, connector);
// Set some timeout options to make debugging easier.
int timeout = 1000 * 30;
connector.setIdleTimeout(timeout);
connector.setHost(conf.getServerAddress());
- if (conf.useSsl()) {
- connector.setPort(conf.getServerSslPort());
- } else {
- connector.setPort(conf.getServerPort());
- }
-
server.addConnector(connector);
-
- return server;
}
private static void configureRequestHeaderSize(
@@ -437,19 +418,20 @@ public class ZeppelinServer extends ResourceConfig {
}
private static WebAppContext setupWebAppContext(
- ContextHandlerCollection contexts, ZeppelinConfiguration conf) {
+ ContextHandlerCollection contexts, ZeppelinConfiguration conf, String warPath, String contextPath) {
WebAppContext webApp = new WebAppContext();
- webApp.setContextPath(conf.getServerContextPath());
- File warPath = new File(conf.getString(ConfVars.ZEPPELIN_WAR));
- if (warPath.isDirectory()) {
+ webApp.setContextPath(contextPath);
+ LOG.info("warPath is: {}", warPath);
+ File warFile = new File(warPath);
+ if (warFile.isDirectory()) {
// Development mode, read from FS
// webApp.setDescriptor(warPath+"/WEB-INF/web.xml");
- webApp.setResourceBase(warPath.getPath());
+ webApp.setResourceBase(warFile.getPath());
webApp.setParentLoaderPriority(true);
} else {
// use packaged WAR
- webApp.setWar(warPath.getAbsolutePath());
- File warTempDirectory = new File(conf.getRelativeDir(ConfVars.ZEPPELIN_WAR_TEMPDIR));
+ webApp.setWar(warFile.getAbsolutePath());
+ File warTempDirectory = new File(conf.getRelativeDir(ConfVars.ZEPPELIN_WAR_TEMPDIR) + contextPath);
warTempDirectory.mkdir();
LOG.info("ZeppelinServer Webapp path: {}", warTempDirectory.getPath());
webApp.setTempDirectory(warTempDirectory);
@@ -463,7 +445,27 @@ public class ZeppelinServer extends ResourceConfig {
webApp.setInitParameter(
"org.eclipse.jetty.servlet.Default.dirAllowed",
Boolean.toString(conf.getBoolean(ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED)));
-
return webApp;
}
+
+ private static void initWebApp(WebAppContext webApp) {
+ webApp.addEventListener(
+ new ServletContextListener() {
+ @Override
+ public void contextInitialized(ServletContextEvent servletContextEvent) {
+ servletContextEvent
+ .getServletContext()
+ .setAttribute(ServletProperties.SERVICE_LOCATOR, sharedServiceLocator);
+ }
+
+ @Override
+ public void contextDestroyed(ServletContextEvent servletContextEvent) {}
+ });
+
+ // Create `ZeppelinServer` using reflection and setup REST Api
+ setupRestApiContextHandler(webApp, conf);
+
+ // Notebook server
+ setupNotebookServer(webApp, conf, sharedServiceLocator);
+ }
}
diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java
index ca8ff95..d107547 100644
--- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java
+++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java
@@ -191,6 +191,8 @@ public abstract class AbstractTestRestApi {
zeppelinHome.getAbsolutePath());
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_WAR.getVarName(),
new File("../zeppelin-web/dist").getAbsolutePath());
+ System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_ANGULAR_WAR.getVarName(),
+ new File("../zeppelin-web-angular/dist").getAbsolutePath());
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_CONF_DIR.getVarName(),
confDir.getAbsolutePath());
System.setProperty(
@@ -208,6 +210,7 @@ public abstract class AbstractTestRestApi {
// some test profile does not build zeppelin-web.
// to prevent zeppelin starting up fail, create zeppelin-web/dist directory
new File("../zeppelin-web/dist").mkdirs();
+ new File("../zeppelin-web-angular/dist").mkdirs();
LOG.info("Staring test Zeppelin up...");
ZeppelinConfiguration conf = ZeppelinConfiguration.create();
diff --git a/zeppelin-web-angular/package.json b/zeppelin-web-angular/package.json
index 9d8cafe..5459ffd 100644
--- a/zeppelin-web-angular/package.json
+++ b/zeppelin-web-angular/package.json
@@ -5,7 +5,7 @@
"postinstall": "npm run build:projects",
"ng": "./node_modules/.bin/ng",
"start": "ng serve --proxy-config proxy.conf.js --extra-webpack-config webpack.partial.js",
- "build": "ng build --prod --extra-webpack-config webpack.partial.js",
+ "build": "ng build --prod --extra-webpack-config webpack.partial.js --base-href /next/",
"build:projects": "npm run build-project:sdk && npm run build-project:vis && npm run build-project:helium",
"build-helium-vis-example": " ng build --project helium-vis-example",
"build-project:sdk": " ng build --project zeppelin-sdk",
diff --git a/zeppelin-web-angular/pom.xml b/zeppelin-web-angular/pom.xml
index e0a1f7b..cae5214 100644
--- a/zeppelin-web-angular/pom.xml
+++ b/zeppelin-web-angular/pom.xml
@@ -26,7 +26,7 @@
<artifactId>zeppelin-web-angular</artifactId>
<packaging>war</packaging>
<version>0.9.0-SNAPSHOT</version>
- <name>Zeppelin: web Application</name>
+ <name>Zeppelin: web angular Application</name>
<!-- See https://github.com/eirslett/frontend-maven-plugin/issues/229 -->
<prerequisites>