zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject incubator-zeppelin git commit: [ZEPPELIN-38] Add config setting for listen address
Date Sat, 11 Apr 2015 09:48:42 GMT
Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master 84839c77f -> c0a7d08c5


[ZEPPELIN-38] Add config setting for listen address

This is useful when running in a Multi-host environment

Author: Sebastian YEPES <syepes@gmail.com>

Closes #32 from syepes/add_cfg_listen_addr and squashes the following commits:

6df7373 [Sebastian YEPES] Add config setting for listen address


Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/c0a7d08c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/c0a7d08c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/c0a7d08c

Branch: refs/heads/master
Commit: c0a7d08c516c22d9ed4834953aa48e8b1d217114
Parents: 84839c7
Author: Sebastian YEPES <syepes@gmail.com>
Authored: Wed Apr 8 23:27:31 2015 +0200
Committer: Lee moon soo <moon@apache.org>
Committed: Sat Apr 11 18:48:11 2015 +0900

----------------------------------------------------------------------
 conf/zeppelin-site.xml.template                      | 12 ++++++++++++
 .../org/apache/zeppelin/server/ZeppelinServer.java   |  5 +++--
 .../org/apache/zeppelin/socket/NotebookServer.java   | 15 ++++++++-------
 .../apache/zeppelin/conf/ZeppelinConfiguration.java  | 10 ++++++++++
 4 files changed, 33 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/c0a7d08c/conf/zeppelin-site.xml.template
----------------------------------------------------------------------
diff --git a/conf/zeppelin-site.xml.template b/conf/zeppelin-site.xml.template
index c203179..32011b1 100644
--- a/conf/zeppelin-site.xml.template
+++ b/conf/zeppelin-site.xml.template
@@ -20,11 +20,23 @@
 <configuration>
 
 <property>
+  <name>zeppelin.server.addr</name>
+  <value>0.0.0.0</value>
+  <description>Server address</description>
+</property>
+
+<property>
   <name>zeppelin.server.port</name>
   <value>8080</value>
   <description>Server port. port+1 is used for web socket.</description>
 </property>
 
+<property>
+  <name>zeppelin.websocket.addr</name>
+  <value>0.0.0.0</value>
+  <description>Testing websocket address</description>
+</property>
+
 <!-- If the port value is negative, then it'll default to the server
      port + 1.
   -->

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/c0a7d08c/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
----------------------------------------------------------------------
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 1c9aa03..909cc8f 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
@@ -145,6 +145,7 @@ public class ZeppelinServer extends Application {
     int timeout = 1000 * 30;
     connector.setMaxIdleTime(timeout);
     connector.setSoLingerTime(-1);
+    connector.setHost(conf.getServerAddress());
     connector.setPort(conf.getServerPort());
 
     final Server server = new Server();
@@ -156,7 +157,7 @@ public class ZeppelinServer extends Application {
   private static NotebookServer setupNotebookServer(ZeppelinConfiguration conf)
       throws Exception {
 
-    NotebookServer server = new NotebookServer(conf.getWebSocketPort());
+    NotebookServer server = new NotebookServer(conf.getWebSocketAddress(), conf.getWebSocketPort());
 
     // Default WebSocketServer uses unencrypted connector, so only need to
     // change the connector if SSL should be used.
@@ -233,7 +234,7 @@ public class ZeppelinServer extends Application {
     swaggerServlet.setInitParameter("api.version", "1.0.0");
     swaggerServlet.setInitParameter(
         "swagger.api.basepath",
-        "http://localhost:" + conf.getServerPort() + "/api");
+        "http://" + conf.getServerAddress() + ":" + conf.getServerPort() + "/api");
     swaggerServlet.setInitOrder(2);
 
     // Setup the handler

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/c0a7d08c/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
index db5733e..415e8c1 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
@@ -53,10 +53,11 @@ import com.google.gson.Gson;
 public class NotebookServer extends WebSocketServer implements JobListenerFactory {
 
   private static final Logger LOG = LoggerFactory.getLogger(NotebookServer.class);
+  private static final String DEFAULT_ADDR = "0.0.0.0";
   private static final int DEFAULT_PORT = 8282;
 
-  private static void creatingwebSocketServerLog(int port) {
-    LOG.info("Create zeppelin websocket on port {}", port);
+  private static void creatingwebSocketServerLog(String address, int port) {
+    LOG.info("Create zeppelin websocket on {}:{}", address, port);
   }
 
   Gson gson = new Gson();
@@ -64,13 +65,13 @@ public class NotebookServer extends WebSocketServer implements JobListenerFactor
   List<WebSocket> connectedSockets = new LinkedList<WebSocket>();
 
   public NotebookServer() {
-    super(new InetSocketAddress(DEFAULT_PORT));
-    creatingwebSocketServerLog(DEFAULT_PORT);
+    super(new InetSocketAddress(DEFAULT_ADDR, DEFAULT_PORT));
+    creatingwebSocketServerLog(DEFAULT_ADDR, DEFAULT_PORT);
   }
 
-  public NotebookServer(int port) {
-    super(new InetSocketAddress(port));
-    creatingwebSocketServerLog(port);
+  public NotebookServer(String address, int port) {
+    super(new InetSocketAddress(address, port));
+    creatingwebSocketServerLog(address, port);
   }
 
   private Notebook notebook() {

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/c0a7d08c/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
index 8495bb5..4b0d96c 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
@@ -258,10 +258,18 @@ public class ZeppelinConfiguration extends XMLConfiguration {
     return getBoolean(ConfVars.ZEPPELIN_SSL_CLIENT_AUTH);
   }
 
+  public String getServerAddress() {
+    return getString(ConfVars.ZEPPELIN_ADDR);
+  }
+
   public int getServerPort() {
     return getInt(ConfVars.ZEPPELIN_PORT);
   }
 
+  public String getWebSocketAddress() {
+    return getString(ConfVars.ZEPPELIN_WEBSOCKET_ADDR);
+  }
+
   public int getWebSocketPort() {
     int port = getInt(ConfVars.ZEPPELIN_WEBSOCKET_PORT);
     if (port < 0) {
@@ -356,8 +364,10 @@ public class ZeppelinConfiguration extends XMLConfiguration {
    */
   public static enum ConfVars {
     ZEPPELIN_HOME("zeppelin.home", "../"),
+    ZEPPELIN_ADDR("zeppelin.server.addr", "0.0.0.0"),
     ZEPPELIN_PORT("zeppelin.server.port", 8080),
     // negative websocket port denotes that server port + 1 should be used
+    ZEPPELIN_WEBSOCKET_ADDR("zeppelin.websocket.addr", "0.0.0.0"),
     ZEPPELIN_WEBSOCKET_PORT("zeppelin.websocket.port", -1),
     ZEPPELIN_SSL("zeppelin.ssl", false),
     ZEPPELIN_SSL_CLIENT_AUTH("zeppelin.ssl.client.auth", false),


Mime
View raw message