Skip to content

Commit f3551eb

Browse files
authored
[ZEPPELIN-6143] Add Interpreter Event Server Port configuration option
### 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]>
1 parent ae48f71 commit f3551eb

File tree

5 files changed

+47
-4
lines changed

5 files changed

+47
-4
lines changed

conf/zeppelin-env.sh.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
# export ZEPPELIN_SSL_PORT # ssl port (used when ssl environment variable is set to true)
3030
# export ZEPPELIN_JMX_ENABLE # Enable JMX feature by defining "true"
3131
# export ZEPPELIN_JMX_PORT # Port number which JMX uses. If not set, JMX won't be enabled
32+
# export ZEPPELIN_SERVER_RPC_PORT # Port for the Zeppelin Interpreter Event Server. If not set, an available port will be used automatically.
3233

3334
# export ZEPPELIN_LOG_DIR # Where log files are stored. PWD by default.
3435
# export ZEPPELIN_PID_DIR # The pid files are stored. ${ZEPPELIN_HOME}/run by default.

conf/zeppelin-site.xml.template

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
<description>Context Path of the Web Application</description>
4444
</property>
4545

46+
<property>
47+
<name>zeppelin.server.rpc.port</name>
48+
<value></value>
49+
<description>Port for the Zeppelin Interpreter Event Server. If not set, an available port will be used automatically.</description>
50+
</property>
51+
4652
<property>
4753
<name>zeppelin.war.tempdir</name>
4854
<value>webapps</value>

docs/setup/operation/configuration.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,33 @@ Sources descending by priority:
6161
<td>8443</td>
6262
<td>Zeppelin Server ssl port (used when ssl environment/property is set to true)</td>
6363
</tr>
64+
<tr>
65+
<td><h6 class="properties">ZEPPELIN_SERVER_RPC_PORTRANGE</h6></td>
66+
<td><h6 class="properties">zeppelin.server.rpc.portRange</h6></td>
67+
<td>:</td>
68+
<td>
69+
Specifies the port range for the Zeppelin Interpreter Event Server.
70+
<br />Format: <code>&lt;startPort&gt;:&lt;endPort&gt;</code>
71+
<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.
72+
<br /><span style="font-style:italic; color: gray"> Note: If <code>zeppelin.server.rpc.port</code> is set, this property will be ignored.</span>
73+
</td>
74+
</tr>
75+
<tr>
76+
<td><h6 class="properties">ZEPPELIN_INTERPRETER_RPC_PORTRANGE</h6></td>
77+
<td><h6 class="properties">zeppelin.interpreter.rpc.portRange</h6></td>
78+
<td>:</td>
79+
<td>
80+
Specifies the port range for the Zeppelin Interpreter.
81+
<br />Format: <code>&lt;startPort&gt;:&lt;endPort&gt;</code>
82+
<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.
83+
</td>
84+
</tr>
85+
<tr>
86+
<td><h6 class="properties">ZEPPELIN_SERVER_RPC_PORT</h6></td>
87+
<td><h6 class="properties">zeppelin.server.rpc.port</h6></td>
88+
<td></td>
89+
<td>Port for the Zeppelin Interpreter Event Server. If not set, an available port will be used automatically.</td>
90+
</tr>
6491
<tr>
6592
<td><h6 class="properties">ZEPPELIN_JMX_ENABLE</h6></td>
6693
<td><h6 class="properties">zeppelin.jmx.enable</h6></td>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,14 @@ public int getServerPort() {
338338
return getInt(ConfVars.ZEPPELIN_PORT);
339339
}
340340

341+
public OptionalInt getZeppelinServerRpcPort() {
342+
String zeppelinServerRpcPort = getString(ConfVars.ZEPPELIN_SERVER_RPC_PORT);
343+
if (StringUtils.isBlank(zeppelinServerRpcPort)) {
344+
return OptionalInt.empty();
345+
}
346+
return OptionalInt.of(Integer.parseInt(zeppelinServerRpcPort));
347+
}
348+
341349
public String getServerContextPath() {
342350
return getString(ConfVars.ZEPPELIN_SERVER_CONTEXT_PATH);
343351
}
@@ -948,6 +956,7 @@ public enum ConfVars {
948956
ZEPPELIN_SSL_TRUSTSTORE_PATH("zeppelin.ssl.truststore.path", null),
949957
ZEPPELIN_SSL_TRUSTSTORE_TYPE("zeppelin.ssl.truststore.type", null),
950958
ZEPPELIN_SSL_TRUSTSTORE_PASSWORD("zeppelin.ssl.truststore.password", null),
959+
ZEPPELIN_SERVER_RPC_PORT("zeppelin.server.rpc.port", null),
951960
ZEPPELIN_WAR("zeppelin.war", "zeppelin-web/dist"),
952961
ZEPPELIN_ANGULAR_WAR("zeppelin.angular.war", "zeppelin-web-angular/dist/zeppelin"),
953962
ZEPPELIN_WAR_TEMPDIR("zeppelin.war.tempdir", "webapps"),

zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/RemoteInterpreterEventServer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.google.gson.Gson;
2121
import com.google.gson.reflect.TypeToken;
2222

23+
import java.util.OptionalInt;
2324
import org.apache.commons.io.FileUtils;
2425
import org.apache.commons.lang3.StringUtils;
2526
import org.apache.thrift.TException;
@@ -49,7 +50,6 @@
4950
import org.apache.zeppelin.interpreter.thrift.RemoteInterpreterResultMessage;
5051
import org.apache.zeppelin.interpreter.thrift.RunParagraphsEvent;
5152
import org.apache.zeppelin.interpreter.thrift.WebUrlInfo;
52-
import org.apache.zeppelin.notebook.Note;
5353
import org.apache.zeppelin.resource.RemoteResource;
5454
import org.apache.zeppelin.resource.Resource;
5555
import org.apache.zeppelin.resource.ResourceId;
@@ -78,7 +78,6 @@ public class RemoteInterpreterEventServer implements RemoteInterpreterEventServi
7878
private static final Logger LOGGER = LoggerFactory.getLogger(RemoteInterpreterEventServer.class);
7979
private static final Gson GSON = new Gson();
8080

81-
private String portRange;
8281
private int port;
8382
private String host;
8483
private ZeppelinConfiguration zConf;
@@ -96,7 +95,6 @@ public class RemoteInterpreterEventServer implements RemoteInterpreterEventServi
9695
public RemoteInterpreterEventServer(ZeppelinConfiguration zConf,
9796
InterpreterSettingManager interpreterSettingManager) {
9897
this.zConf = zConf;
99-
this.portRange = zConf.getZeppelinServerRPCPortRange();
10098
this.interpreterSettingManager = interpreterSettingManager;
10199
this.listener = interpreterSettingManager.getRemoteInterpreterProcessListener();
102100
this.appListener = interpreterSettingManager.getAppEventListener();
@@ -106,7 +104,9 @@ public void start() throws IOException {
106104
Thread startingThread = new Thread() {
107105
@Override
108106
public void run() {
109-
try (TServerSocket tSocket = new TServerSocket(RemoteInterpreterUtils.findAvailablePort(portRange))){
107+
try (TServerSocket tSocket = new TServerSocket(zConf.getZeppelinServerRpcPort().orElse(
108+
RemoteInterpreterUtils.findAvailablePort(zConf.getZeppelinServerRPCPortRange())))
109+
) {
110110
port = tSocket.getServerSocket().getLocalPort();
111111
host = RemoteInterpreterUtils.findAvailableHostAddress();
112112
LOGGER.info("InterpreterEventServer is starting at {}:{}", host, port);

0 commit comments

Comments
 (0)