Skip to content

Commit

Permalink
[Hotfix][Zeta] Fix hazelcast client should overwrite cluster address …
Browse files Browse the repository at this point in the history
…by system env (#7790)
  • Loading branch information
liunaijie authored Oct 8, 2024
1 parent 5b5ee84 commit 62619e8
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 16 deletions.
22 changes: 14 additions & 8 deletions docs/en/start-v2/docker/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,20 @@ run this command to get the pod ip.

- start worker node
```shell
# you need update yourself master container ip to `ST_DOCKER_MEMBER_LIST`
docker run -d --name seatunnel_worker_1 \
--network seatunnel-network \
--rm \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \ # set master container ip to here
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \
apache/seatunnel \
./bin/seatunnel-cluster.sh -r worker

## start worker2
docker run -d --name seatunnel_worker_2 \
# you need update yourself master container ip to `ST_DOCKER_MEMBER_LIST`
docker run -d --name seatunnel_worker_2 \
--network seatunnel-network \
--rm \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \ # set master container ip to here
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \
apache/seatunnel \
./bin/seatunnel-cluster.sh -r worker

Expand All @@ -194,20 +196,22 @@ docker run -d --name seatunnel_worker_2 \

run this command to start master node.
```shell
# you need update yourself master container ip to `ST_DOCKER_MEMBER_LIST`
docker run -d --name seatunnel_master \
--network seatunnel-network \
--rm \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \ # set exist master container ip to here
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \
apache/seatunnel \
./bin/seatunnel-cluster.sh -r master
```

run this command to start worker node.
```shell
# you need update yourself master container ip to `ST_DOCKER_MEMBER_LIST`
docker run -d --name seatunnel_worker_1 \
--network seatunnel-network \
--rm \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \ # set master container ip to here
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \
apache/seatunnel \
./bin/seatunnel-cluster.sh -r worker
```
Expand Down Expand Up @@ -371,21 +375,23 @@ and run `docker-compose up -d` command, the new worker node will start, and the
#### use docker as a client
- submit job :
```shell
# you need update yourself master container ip to `ST_DOCKER_MEMBER_LIST`
docker run --name seatunnel_client \
--network seatunnel-network \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \
--rm \
apache/seatunnel \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \ # set it as master node container ip
./bin/seatunnel.sh -c config/v2.batch.config.template # this is an default config, if you need submit your self config, you can mount config file.
./bin/seatunnel.sh -c config/v2.batch.config.template
```

- list job
```shell
# you need update yourself master container ip to `ST_DOCKER_MEMBER_LIST`
docker run --name seatunnel_client \
--network seatunnel-network \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \
--rm \
apache/seatunnel \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \ # set it as master node container ip
./bin/seatunnel.sh -l
```

Expand Down
22 changes: 14 additions & 8 deletions docs/zh/start-v2/docker/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,20 @@ docker inspect master-1

- 启动worker节点
```shell
# 将ST_DOCKER_MEMBER_LIST设置为master容器的ip
docker run -d --name seatunnel_worker_1 \
--network seatunnel-network \
--rm \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \ # 设置为刚刚启动的master容器ip
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \
apache/seatunnel \
./bin/seatunnel-cluster.sh -r worker

docker run -d --name seatunnel_worker_2 \
## 启动第二个worker节点
# 将ST_DOCKER_MEMBER_LIST设置为master容器的ip
docker run -d --name seatunnel_worker_2 \
--network seatunnel-network \
--rm \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \ # 设置为刚刚启动的master容器ip
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \
apache/seatunnel \
./bin/seatunnel-cluster.sh -r worker

Expand All @@ -195,21 +198,22 @@ docker run -d --name seatunnel_worker_2 \
#### 集群扩容

```shell
## start master and export 5801 port
# 将ST_DOCKER_MEMBER_LIST设置为已经启动的master容器的ip
docker run -d --name seatunnel_master \
--network seatunnel-network \
--rm \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \ # 设置为已启动的master容器ip
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \
apache/seatunnel \
./bin/seatunnel-cluster.sh -r master
```

运行这个命令创建一个worker节点
```shell
# 将ST_DOCKER_MEMBER_LIST设置为master容器的ip
docker run -d --name seatunnel_worker_1 \
--network seatunnel-network \
--rm \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \ # 设置为已启动的master容器ip
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \
apache/seatunnel \
./bin/seatunnel-cluster.sh -r worker
```
Expand Down Expand Up @@ -363,21 +367,23 @@ networks:
#### 使用docker container作为客户端
- 提交任务
```shell
# 将ST_DOCKER_MEMBER_LIST设置为master容器的ip
docker run --name seatunnel_client \
--network seatunnel-network \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \
--rm \
apache/seatunnel \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \ # set it as master node container ip
./bin/seatunnel.sh -c config/v2.batch.config.template
```

- 查看作业列表
```shell
# 将ST_DOCKER_MEMBER_LIST设置为master容器的ip
docker run --name seatunnel_client \
--network seatunnel-network \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \
--rm \
apache/seatunnel \
-e ST_DOCKER_MEMBER_LIST=172.18.0.2:5801 \ # set it as master node container ip
./bin/seatunnel.sh -l
```

Expand Down
6 changes: 6 additions & 0 deletions seatunnel-engine/seatunnel-engine-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,11 @@
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<version>1.9.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junitpioneer.jupiter.SetEnvironmentVariable;

import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.core.HazelcastInstance;
Expand Down Expand Up @@ -745,6 +746,15 @@ public void testGetMultiTableJobMetrics() {
}
}

@Test
@SetEnvironmentVariable(
key = "ST_DOCKER_MEMBER_LIST",
value = "127.0.0.1,127.0.0.2,127.0.0.3,127.0.0.4")
public void testDockerEnvOverwrite() {
ClientConfig clientConfig = ConfigProvider.locateAndGetClientConfig();
Assertions.assertEquals(4, clientConfig.getNetworkConfig().getAddresses().size());
}

@AfterAll
public static void after() {
INSTANCE.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public static SeaTunnelConfig locateAndGetSeaTunnelConfigFromString(String sourc
yamlConfigLocator.locateDefault();
config = new YamlClientConfigBuilder(yamlConfigLocator.getIn()).build();
}
String stDockerMemberList = System.getenv("ST_DOCKER_MEMBER_LIST");
if (stDockerMemberList != null) {
config.getNetworkConfig().setAddresses(Arrays.asList(stDockerMemberList.split(",")));
}
return config;
}

Expand Down
6 changes: 6 additions & 0 deletions seatunnel-engine/seatunnel-engine-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@
<version>2.7.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<version>1.9.1</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package org.apache.seatunnel.engine.server;

import org.apache.seatunnel.engine.common.Constant;
import org.apache.seatunnel.engine.common.config.ConfigProvider;
import org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
import org.apache.seatunnel.engine.common.exception.SeaTunnelEngineException;
import org.apache.seatunnel.engine.core.dag.logical.LogicalDag;
import org.apache.seatunnel.engine.core.job.JobImmutableInformation;
Expand All @@ -27,6 +29,7 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetEnvironmentVariable;

import com.hazelcast.instance.impl.HazelcastInstanceImpl;
import com.hazelcast.internal.serialization.Data;
Expand Down Expand Up @@ -238,4 +241,28 @@ public void testJobRestoreWhenMasterNodeSwitch() throws InterruptedException {
server2.getCoordinatorService().getJobStatus(jobId)));
instance2.shutdown();
}

@Test
@SetEnvironmentVariable(
key = "ST_DOCKER_MEMBER_LIST",
value = "127.0.0.1,127.0.0.2,127.0.0.3,127.0.0.4")
public void testDockerEnvOverwrite() {
SeaTunnelConfig seaTunnelConfig = ConfigProvider.locateAndGetSeaTunnelConfig();
if (seaTunnelConfig
.getHazelcastConfig()
.getNetworkConfig()
.getJoin()
.getTcpIpConfig()
.isEnabled()) {
Assertions.assertEquals(
4,
seaTunnelConfig
.getHazelcastConfig()
.getNetworkConfig()
.getJoin()
.getTcpIpConfig()
.getMembers()
.size());
}
}
}

0 comments on commit 62619e8

Please sign in to comment.