diff --git a/bin/common.sh b/bin/common.sh index 0ebae660907..4e86ce94948 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 e8988497513..0ce9808e2d8 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 a13f9db977d..5509e4f2f54 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 271067060c1..380e7a2f719 100644 --- a/zeppelin-distribution/pom.xml +++ b/zeppelin-distribution/pom.xml @@ -85,6 +85,12 @@ ${project.version} war + + ${project.groupId} + zeppelin-web-angular + ${project.version} + war + diff --git a/zeppelin-distribution/src/assemble/distribution.xml b/zeppelin-distribution/src/assemble/distribution.xml index 0c5e8b64433..0b18b4ae128 100644 --- a/zeppelin-distribution/src/assemble/distribution.xml +++ b/zeppelin-distribution/src/assemble/distribution.xml @@ -26,7 +26,7 @@ true zeppelin-${project.version} - + ${project.groupId}:zeppelin-web + ${project.groupId}:zeppelin-web-angular false false @@ -42,6 +43,7 @@ /lib ${project.groupId}:zeppelin-web + ${project.groupId}:zeppelin-web-angular false true 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 2a6e0bbbf2e..a6123ec661b 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 enum ConfVars { 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 f9d8e8b6262..966f5b553aa 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 @@ /** 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 static void main(String[] args) throws InterruptedException { 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 @@ protected void configure() { } }); - 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 @@ private static Server setupJettyServer(ZeppelinConfiguration conf) { 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 @@ private static Server setupJettyServer(ZeppelinConfiguration conf) { 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 @@ private static void setupRestApiContextHandler(WebAppContext webapp, ZeppelinCon } 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 @@ private static WebAppContext setupWebAppContext( 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 ca8ff95f6f5..d1075471927 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 @@ private static void start(boolean withAuth, 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 @@ private static void start(boolean withAuth, // 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 9d8cafef99e..5459ffd2b35 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 e0a1f7b3e84..cae521489e7 100644 --- a/zeppelin-web-angular/pom.xml +++ b/zeppelin-web-angular/pom.xml @@ -26,7 +26,7 @@ zeppelin-web-angular war 0.9.0-SNAPSHOT - Zeppelin: web Application + Zeppelin: web angular Application