Skip to content

Commit 0f9c103

Browse files
author
fdai
committed
add angular support for jetty
1 parent 5ac0005 commit 0f9c103

File tree

10 files changed

+30091
-44
lines changed

10 files changed

+30091
-44
lines changed

bin/common.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ if [[ -z "${ZEPPELIN_WAR}" ]]; then
4848
fi
4949
fi
5050

51+
if [[ -z "${ZEPPELIN_ANGULAR_WAR}" ]]; then
52+
if [[ -d "${ZEPPELIN_HOME}/zeppelin-web/dist" ]]; then
53+
export ZEPPELIN_ANGULAR_WAR="${ZEPPELIN_HOME}/zeppelin-web-angular/dist"
54+
else
55+
export ZEPPELIN_ANGULAR_WAR=$(find -L "${ZEPPELIN_HOME}" -name "zeppelin-web-angular*.war")
56+
fi
57+
fi
58+
5159
if [[ -f "${ZEPPELIN_CONF_DIR}/zeppelin-env.sh" ]]; then
5260
. "${ZEPPELIN_CONF_DIR}/zeppelin-env.sh"
5361
fi

bin/zeppelin-daemon.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ addJarInDir "${ZEPPELIN_HOME}/zeppelin-interpreter/target/lib"
8181
addJarInDir "${ZEPPELIN_HOME}/zeppelin-zengine/target/lib"
8282
addJarInDir "${ZEPPELIN_HOME}/zeppelin-server/target/lib"
8383
addJarInDir "${ZEPPELIN_HOME}/zeppelin-web/target/lib"
84+
addJarInDir "${ZEPPELIN_HOME}/zeppelin-web-angular/target/lib"
8485

8586
CLASSPATH+=":${ZEPPELIN_CLASSPATH}"
8687

bin/zeppelin.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ addJarInDir "${ZEPPELIN_HOME}/zeppelin-interpreter/target/lib"
7070
addJarInDir "${ZEPPELIN_HOME}/zeppelin-zengine/target/lib"
7171
addJarInDir "${ZEPPELIN_HOME}/zeppelin-server/target/lib"
7272
addJarInDir "${ZEPPELIN_HOME}/zeppelin-web/target/lib"
73+
addJarInDir "${ZEPPELIN_HOME}/zeppelin-web-angular/target/lib"
7374

7475
ZEPPELIN_CLASSPATH="$CLASSPATH:$ZEPPELIN_CLASSPATH"
7576

git_notebook/Presto/Presto Usage_2EVEG73VW.zpln

Lines changed: 30011 additions & 0 deletions
Large diffs are not rendered by default.

zeppelin-distribution/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@
8585
<version>${project.version}</version>
8686
<type>war</type>
8787
</dependency>
88+
<dependency>
89+
<groupId>${project.groupId}</groupId>
90+
<artifactId>zeppelin-web-angular</artifactId>
91+
<version>${project.version}</version>
92+
<type>war</type>
93+
</dependency>
8894
</dependencies>
8995

9096
<build>

zeppelin-distribution/src/assemble/distribution.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<outputDirectory>/lib</outputDirectory>
4343
<excludes>
4444
<exclude>${project.groupId}:zeppelin-web</exclude>
45+
<exclude>${project.groupId}:zeppelin-web-angular</exclude>
4546
</excludes>
4647
<useProjectArtifact>false</useProjectArtifact>
4748
<useTransitiveFiltering>true</useTransitiveFiltering>

zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ public int getServerSslPort() {
306306
return getInt(ConfVars.ZEPPELIN_SSL_PORT);
307307
}
308308

309+
public int getServerAngularSslPort() {
310+
return getInt(ConfVars.ZEPPELIN_SSL_PORT);
311+
}
312+
309313
public boolean useClientAuth() {
310314
return getBoolean(ConfVars.ZEPPELIN_SSL_CLIENT_AUTH);
311315
}
@@ -323,6 +327,10 @@ public int getServerPort() {
323327
return getInt(ConfVars.ZEPPELIN_PORT);
324328
}
325329

330+
public int getServerAngularPort() {
331+
return getInt(ConfVars.ZEPPELIN_ANGULAR_PORT);
332+
}
333+
326334
public String getServerContextPath() {
327335
return getString(ConfVars.ZEPPELIN_SERVER_CONTEXT_PATH);
328336
}
@@ -800,9 +808,11 @@ public enum ConfVars {
800808
ZEPPELIN_HOME("zeppelin.home", "./"),
801809
ZEPPELIN_ADDR("zeppelin.server.addr", "127.0.0.1"),
802810
ZEPPELIN_PORT("zeppelin.server.port", 8080),
811+
ZEPPELIN_ANGULAR_PORT("zeppelin.server.angular.port", 9090),
803812
ZEPPELIN_SERVER_CONTEXT_PATH("zeppelin.server.context.path", "/"),
804813
ZEPPELIN_SSL("zeppelin.ssl", false),
805814
ZEPPELIN_SSL_PORT("zeppelin.server.ssl.port", 8443),
815+
ZEPPELIN_ANGULAR_SSL_PORT("zeppelin.server.angular.ssl.port", 9443),
806816
ZEPPELIN_SSL_CLIENT_AUTH("zeppelin.ssl.client.auth", false),
807817
ZEPPELIN_SSL_KEYSTORE_PATH("zeppelin.ssl.keystore.path", "keystore"),
808818
ZEPPELIN_SSL_KEYSTORE_TYPE("zeppelin.ssl.keystore.type", "JKS"),
@@ -812,6 +822,7 @@ public enum ConfVars {
812822
ZEPPELIN_SSL_TRUSTSTORE_TYPE("zeppelin.ssl.truststore.type", null),
813823
ZEPPELIN_SSL_TRUSTSTORE_PASSWORD("zeppelin.ssl.truststore.password", null),
814824
ZEPPELIN_WAR("zeppelin.war", "zeppelin-web/dist"),
825+
ZEPPELIN_ANGULAR_WAR("zeppelin.angular.war", "zeppelin-web-angular/dist"),
815826
ZEPPELIN_WAR_TEMPDIR("zeppelin.war.tempdir", "webapps"),
816827

817828
ZEPPELIN_INTERPRETER_JSON("zeppelin.interpreter.setting", "interpreter-setting.json"),

zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ public class ZeppelinServer extends ResourceConfig {
102102
public static ServiceLocator sharedServiceLocator;
103103

104104
private static ZeppelinConfiguration conf = ZeppelinConfiguration.create();
105+
private static final String CONNCETOR_NAME_DEFAULT = "default";
106+
private static final String CONNCETOR_NAME_ANGULAR = "angular";
105107

106108
@Inject
107109
public ZeppelinServer() {
@@ -119,9 +121,6 @@ public static void main(String[] args) throws InterruptedException {
119121
ContextHandlerCollection contexts = new ContextHandlerCollection();
120122
jettyWebServer.setHandler(contexts);
121123

122-
// Web UI
123-
final WebAppContext webApp = setupWebAppContext(contexts, conf);
124-
125124
sharedServiceLocator = ServiceLocatorFactory.getInstance().create("shared-locator");
126125
ServiceLocatorUtilities.enableImmediateScope(sharedServiceLocator);
127126
ServiceLocatorUtilities.addClasses(sharedServiceLocator,
@@ -180,25 +179,12 @@ protected void configure() {
180179
}
181180
});
182181

183-
webApp.addEventListener(
184-
new ServletContextListener() {
185-
@Override
186-
public void contextInitialized(ServletContextEvent servletContextEvent) {
187-
servletContextEvent
188-
.getServletContext()
189-
.setAttribute(ServletProperties.SERVICE_LOCATOR, sharedServiceLocator);
190-
}
191-
192-
@Override
193-
public void contextDestroyed(ServletContextEvent servletContextEvent) {}
194-
});
195-
196-
// Create `ZeppelinServer` using reflection and setup REST Api
197-
setupRestApiContextHandler(webApp, conf);
198-
199-
// Notebook server
200-
setupNotebookServer(webApp, conf, sharedServiceLocator);
182+
// Multiple Web UI
183+
final WebAppContext defaultWebApp = setupWebAppContext(contexts, conf, conf.getString(ConfVars.ZEPPELIN_WAR), CONNCETOR_NAME_DEFAULT);
184+
final WebAppContext angularWebApp = setupWebAppContext(contexts, conf, conf.getString(ConfVars.ZEPPELIN_ANGULAR_WAR), CONNCETOR_NAME_ANGULAR);
201185

186+
initWebApp(defaultWebApp);
187+
initWebApp(angularWebApp);
202188
// Cluster Manager Server
203189
setupClusterManagerServer(sharedServiceLocator);
204190

@@ -304,14 +290,19 @@ private static Server setupJettyServer(ZeppelinConfiguration conf) {
304290
conf.getInt(ConfVars.ZEPPELIN_SERVER_JETTY_THREAD_POOL_MIN),
305291
conf.getInt(ConfVars.ZEPPELIN_SERVER_JETTY_THREAD_POOL_TIMEOUT));
306292
final Server server = new Server(threadPool);
307-
ServerConnector connector;
293+
initServerConnector(server, conf.getServerPort(), conf.getServerSslPort(), CONNCETOR_NAME_DEFAULT);
294+
initServerConnector(server, conf.getServerAngularPort(), conf.getServerAngularSslPort(), CONNCETOR_NAME_ANGULAR);
295+
return server;
296+
}
297+
private static void initServerConnector(Server server, int port, int sslPort, String name) {
308298

299+
ServerConnector connector;
309300
HttpConfiguration httpConfig = new HttpConfiguration();
310301
httpConfig.addCustomizer(new ForwardedRequestCustomizer());
311302
if (conf.useSsl()) {
312-
LOG.debug("Enabling SSL for Zeppelin Server on port " + conf.getServerSslPort());
303+
LOG.debug("Enabling SSL for Zeppelin Server on port " + sslPort);
313304
httpConfig.setSecureScheme("https");
314-
httpConfig.setSecurePort(conf.getServerSslPort());
305+
httpConfig.setSecurePort(sslPort);
315306
httpConfig.setOutputBufferSize(32768);
316307
httpConfig.setResponseHeaderSize(8192);
317308
httpConfig.setSendServerVersion(true);
@@ -321,28 +312,21 @@ private static Server setupJettyServer(ZeppelinConfiguration conf) {
321312
httpsConfig.addCustomizer(src);
322313

323314
connector =
324-
new ServerConnector(
325-
server,
326-
new SslConnectionFactory(getSslContextFactory(conf), HttpVersion.HTTP_1_1.asString()),
327-
new HttpConnectionFactory(httpsConfig));
315+
new ServerConnector(
316+
server,
317+
new SslConnectionFactory(getSslContextFactory(conf), HttpVersion.HTTP_1_1.asString()),
318+
new HttpConnectionFactory(httpsConfig));
328319
} else {
329320
connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
321+
connector.setPort(port);
330322
}
331-
332323
configureRequestHeaderSize(conf, connector);
333324
// Set some timeout options to make debugging easier.
334325
int timeout = 1000 * 30;
335326
connector.setIdleTimeout(timeout);
336327
connector.setHost(conf.getServerAddress());
337-
if (conf.useSsl()) {
338-
connector.setPort(conf.getServerSslPort());
339-
} else {
340-
connector.setPort(conf.getServerPort());
341-
}
342-
328+
connector.setName(name);
343329
server.addConnector(connector);
344-
345-
return server;
346330
}
347331

348332
private static void configureRequestHeaderSize(
@@ -437,18 +421,18 @@ private static void setupRestApiContextHandler(WebAppContext webapp, ZeppelinCon
437421
}
438422

439423
private static WebAppContext setupWebAppContext(
440-
ContextHandlerCollection contexts, ZeppelinConfiguration conf) {
424+
ContextHandlerCollection contexts, ZeppelinConfiguration conf, String warPath, String connectorName) {
441425
WebAppContext webApp = new WebAppContext();
442426
webApp.setContextPath(conf.getServerContextPath());
443-
File warPath = new File(conf.getString(ConfVars.ZEPPELIN_WAR));
444-
if (warPath.isDirectory()) {
427+
File warFile = new File(warPath);
428+
if (warFile.isDirectory()) {
445429
// Development mode, read from FS
446430
// webApp.setDescriptor(warPath+"/WEB-INF/web.xml");
447-
webApp.setResourceBase(warPath.getPath());
431+
webApp.setResourceBase(warFile.getPath());
448432
webApp.setParentLoaderPriority(true);
449433
} else {
450434
// use packaged WAR
451-
webApp.setWar(warPath.getAbsolutePath());
435+
webApp.setWar(warFile.getAbsolutePath());
452436
File warTempDirectory = new File(conf.getRelativeDir(ConfVars.ZEPPELIN_WAR_TEMPDIR));
453437
warTempDirectory.mkdir();
454438
LOG.info("ZeppelinServer Webapp path: {}", warTempDirectory.getPath());
@@ -463,7 +447,28 @@ private static WebAppContext setupWebAppContext(
463447
webApp.setInitParameter(
464448
"org.eclipse.jetty.servlet.Default.dirAllowed",
465449
Boolean.toString(conf.getBoolean(ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED)));
466-
450+
webApp.setVirtualHosts(new String[] {"@" + connectorName});
467451
return webApp;
468452
}
453+
454+
private static void initWebApp(WebAppContext webApp) {
455+
webApp.addEventListener(
456+
new ServletContextListener() {
457+
@Override
458+
public void contextInitialized(ServletContextEvent servletContextEvent) {
459+
servletContextEvent
460+
.getServletContext()
461+
.setAttribute(ServletProperties.SERVICE_LOCATOR, sharedServiceLocator);
462+
}
463+
464+
@Override
465+
public void contextDestroyed(ServletContextEvent servletContextEvent) {}
466+
});
467+
468+
// Create `ZeppelinServer` using reflection and setup REST Api
469+
setupRestApiContextHandler(webApp, conf);
470+
471+
// Notebook server
472+
setupNotebookServer(webApp, conf, sharedServiceLocator);
473+
}
469474
}

zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ private static void start(boolean withAuth,
191191
zeppelinHome.getAbsolutePath());
192192
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_WAR.getVarName(),
193193
new File("../zeppelin-web/dist").getAbsolutePath());
194+
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_ANGULAR_WAR.getVarName(),
195+
new File("../zeppelin-web-angular/dist").getAbsolutePath());
194196
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_CONF_DIR.getVarName(),
195197
confDir.getAbsolutePath());
196198
System.setProperty(
@@ -208,6 +210,7 @@ private static void start(boolean withAuth,
208210
// some test profile does not build zeppelin-web.
209211
// to prevent zeppelin starting up fail, create zeppelin-web/dist directory
210212
new File("../zeppelin-web/dist").mkdirs();
213+
new File("../zeppelin-web-angular/dist").mkdirs();
211214

212215
LOG.info("Staring test Zeppelin up...");
213216
ZeppelinConfiguration conf = ZeppelinConfiguration.create();

zeppelin-web-angular/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<artifactId>zeppelin-web-angular</artifactId>
2727
<packaging>war</packaging>
2828
<version>0.9.0-SNAPSHOT</version>
29-
<name>Zeppelin: web Application</name>
29+
<name>Zeppelin: web angular Application</name>
3030

3131
<!-- See https://github.com/eirslett/frontend-maven-plugin/issues/229 -->
3232
<prerequisites>

0 commit comments

Comments
 (0)