Skip to content

Commit

Permalink
[ZEPPELIN-6143] Add Interpreter Event Server Port configuration option
Browse files Browse the repository at this point in the history
### What is this PR for?
This PR introduces the `ZEPPELIN_EVENT_SERVER_PORT` configuration option.
When this option is set, the Event server that communicates with interpreters will listen on the specified port.

The `ZEPPELIN_EVENT_SERVER_PORT` option takes precedence over `ZEPPELIN_SERVER_RPC_PORTRANGE` option.
If `ZEPPELIN_EVENT_SERVER_PORT` is set, the `ZEPPELIN_SERVER_RPC_PORTRANGE` range will be ignored.

This option is particularly useful when running individual Zeppelin components in container orchestration environments like Kubernetes.
By explicitly specifying the port, it allows for a more declarative and clearer configuration of service resources compared to `ZEPPELIN_SERVER_RPC_PORTRANGE`.

### What type of PR is it?
Improvement

### Todos
* [ ] - Task

### What is the Jira issue?
* Open an issue on Jira https://issues.apache.org/jira/browse/ZEPPELIN-6143

### How should this be tested?
* Run Zeppelin with and without this configuration and check zeppelin-server logs for the message `"InterpreterEventServer is starting at "`. Verify that the specified port is used as intended(If the option is set).

### Questions:
* Does the license files need to update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? Yes


Closes #4893 from tbonelee/add-fixed-interpreter-event-server-port-option.

Signed-off-by: Philipp Dallig <[email protected]>
  • Loading branch information
tbonelee authored Dec 5, 2024
1 parent ae48f71 commit f3551eb
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
1 change: 1 addition & 0 deletions conf/zeppelin-env.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# export ZEPPELIN_SSL_PORT # ssl port (used when ssl environment variable is set to true)
# export ZEPPELIN_JMX_ENABLE # Enable JMX feature by defining "true"
# export ZEPPELIN_JMX_PORT # Port number which JMX uses. If not set, JMX won't be enabled
# export ZEPPELIN_SERVER_RPC_PORT # Port for the Zeppelin Interpreter Event Server. If not set, an available port will be used automatically.

# export ZEPPELIN_LOG_DIR # Where log files are stored. PWD by default.
# export ZEPPELIN_PID_DIR # The pid files are stored. ${ZEPPELIN_HOME}/run by default.
Expand Down
6 changes: 6 additions & 0 deletions conf/zeppelin-site.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
<description>Context Path of the Web Application</description>
</property>

<property>
<name>zeppelin.server.rpc.port</name>
<value></value>
<description>Port for the Zeppelin Interpreter Event Server. If not set, an available port will be used automatically.</description>
</property>

<property>
<name>zeppelin.war.tempdir</name>
<value>webapps</value>
Expand Down
27 changes: 27 additions & 0 deletions docs/setup/operation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,33 @@ Sources descending by priority:
<td>8443</td>
<td>Zeppelin Server ssl port (used when ssl environment/property is set to true)</td>
</tr>
<tr>
<td><h6 class="properties">ZEPPELIN_SERVER_RPC_PORTRANGE</h6></td>
<td><h6 class="properties">zeppelin.server.rpc.portRange</h6></td>
<td>:</td>
<td>
Specifies the port range for the Zeppelin Interpreter Event Server.
<br />Format: <code>&lt;startPort&gt;:&lt;endPort&gt;</code>
<br />If the <code>&lt;startPort&gt;</code> is omitted, the range will begin at 1024. If the <code>&lt;endPort&gt;</code> is omitted, the range will extend up to 65535.
<br /><span style="font-style:italic; color: gray"> Note: If <code>zeppelin.server.rpc.port</code> is set, this property will be ignored.</span>
</td>
</tr>
<tr>
<td><h6 class="properties">ZEPPELIN_INTERPRETER_RPC_PORTRANGE</h6></td>
<td><h6 class="properties">zeppelin.interpreter.rpc.portRange</h6></td>
<td>:</td>
<td>
Specifies the port range for the Zeppelin Interpreter.
<br />Format: <code>&lt;startPort&gt;:&lt;endPort&gt;</code>
<br />If the <code>&lt;startPort&gt;</code> is omitted, the range will begin at 1024. If the <code>&lt;endPort&gt;</code> is omitted, the range will extend up to 65535.
</td>
</tr>
<tr>
<td><h6 class="properties">ZEPPELIN_SERVER_RPC_PORT</h6></td>
<td><h6 class="properties">zeppelin.server.rpc.port</h6></td>
<td></td>
<td>Port for the Zeppelin Interpreter Event Server. If not set, an available port will be used automatically.</td>
</tr>
<tr>
<td><h6 class="properties">ZEPPELIN_JMX_ENABLE</h6></td>
<td><h6 class="properties">zeppelin.jmx.enable</h6></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,14 @@ public int getServerPort() {
return getInt(ConfVars.ZEPPELIN_PORT);
}

public OptionalInt getZeppelinServerRpcPort() {
String zeppelinServerRpcPort = getString(ConfVars.ZEPPELIN_SERVER_RPC_PORT);
if (StringUtils.isBlank(zeppelinServerRpcPort)) {
return OptionalInt.empty();
}
return OptionalInt.of(Integer.parseInt(zeppelinServerRpcPort));
}

public String getServerContextPath() {
return getString(ConfVars.ZEPPELIN_SERVER_CONTEXT_PATH);
}
Expand Down Expand Up @@ -948,6 +956,7 @@ public enum ConfVars {
ZEPPELIN_SSL_TRUSTSTORE_PATH("zeppelin.ssl.truststore.path", null),
ZEPPELIN_SSL_TRUSTSTORE_TYPE("zeppelin.ssl.truststore.type", null),
ZEPPELIN_SSL_TRUSTSTORE_PASSWORD("zeppelin.ssl.truststore.password", null),
ZEPPELIN_SERVER_RPC_PORT("zeppelin.server.rpc.port", null),
ZEPPELIN_WAR("zeppelin.war", "zeppelin-web/dist"),
ZEPPELIN_ANGULAR_WAR("zeppelin.angular.war", "zeppelin-web-angular/dist/zeppelin"),
ZEPPELIN_WAR_TEMPDIR("zeppelin.war.tempdir", "webapps"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.OptionalInt;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.thrift.TException;
Expand Down Expand Up @@ -49,7 +50,6 @@
import org.apache.zeppelin.interpreter.thrift.RemoteInterpreterResultMessage;
import org.apache.zeppelin.interpreter.thrift.RunParagraphsEvent;
import org.apache.zeppelin.interpreter.thrift.WebUrlInfo;
import org.apache.zeppelin.notebook.Note;
import org.apache.zeppelin.resource.RemoteResource;
import org.apache.zeppelin.resource.Resource;
import org.apache.zeppelin.resource.ResourceId;
Expand Down Expand Up @@ -78,7 +78,6 @@ public class RemoteInterpreterEventServer implements RemoteInterpreterEventServi
private static final Logger LOGGER = LoggerFactory.getLogger(RemoteInterpreterEventServer.class);
private static final Gson GSON = new Gson();

private String portRange;
private int port;
private String host;
private ZeppelinConfiguration zConf;
Expand All @@ -96,7 +95,6 @@ public class RemoteInterpreterEventServer implements RemoteInterpreterEventServi
public RemoteInterpreterEventServer(ZeppelinConfiguration zConf,
InterpreterSettingManager interpreterSettingManager) {
this.zConf = zConf;
this.portRange = zConf.getZeppelinServerRPCPortRange();
this.interpreterSettingManager = interpreterSettingManager;
this.listener = interpreterSettingManager.getRemoteInterpreterProcessListener();
this.appListener = interpreterSettingManager.getAppEventListener();
Expand All @@ -106,7 +104,9 @@ public void start() throws IOException {
Thread startingThread = new Thread() {
@Override
public void run() {
try (TServerSocket tSocket = new TServerSocket(RemoteInterpreterUtils.findAvailablePort(portRange))){
try (TServerSocket tSocket = new TServerSocket(zConf.getZeppelinServerRpcPort().orElse(
RemoteInterpreterUtils.findAvailablePort(zConf.getZeppelinServerRPCPortRange())))
) {
port = tSocket.getServerSocket().getLocalPort();
host = RemoteInterpreterUtils.findAvailableHostAddress();
LOGGER.info("InterpreterEventServer is starting at {}:{}", host, port);
Expand Down

0 comments on commit f3551eb

Please sign in to comment.