This is an automated email from the ASF dual-hosted git repository.
liugddx pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git
The following commit(s) were added to refs/heads/dev by this push:
new ff1b7d7b36 [Improve][Example] Improve zeta local/cluster example
(#7877)
ff1b7d7b36 is described below
commit ff1b7d7b36e5d66f9f2a954fb81a4cf90c02d47a
Author: hailin0 <[email protected]>
AuthorDate: Tue Oct 22 09:29:29 2024 +0800
[Improve][Example] Improve zeta local/cluster example (#7877)
---
docs/en/contribution/setup.md | 2 +-
docs/zh/contribution/setup.md | 2 +-
.../SeaTunnelEngineClusterClientExample.java | 81 ++++++++++++++++++++++
...va => SeaTunnelEngineClusterServerExample.java} | 2 +-
...ample.java => SeaTunnelEngineLocalExample.java} | 6 +-
5 files changed, 87 insertions(+), 6 deletions(-)
diff --git a/docs/en/contribution/setup.md b/docs/en/contribution/setup.md
index b2579e1ee1..8fd632a24b 100644
--- a/docs/en/contribution/setup.md
+++ b/docs/en/contribution/setup.md
@@ -80,7 +80,7 @@ After all the above things are done, you just finish the
environment setup and c
of box. All examples are in module `seatunnel-examples`, you could pick one
you are interested in, [Running Or Debugging
It In IDEA](https://www.jetbrains.com/help/idea/run-debug-configuration.html)
as you wish.
-Here we use
`seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineExample.java`
+Here we use
`seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineLocalExample.java`
as an example, when you run it successfully you can see the output as below:
```log
diff --git a/docs/zh/contribution/setup.md b/docs/zh/contribution/setup.md
index c00c3132c2..662663a496 100644
--- a/docs/zh/contribution/setup.md
+++ b/docs/zh/contribution/setup.md
@@ -75,7 +75,7 @@ Apache SeaTunnel 使用 `Spotless` 来统一代码风格和格式检查。可以
完成上面所有的工作后,环境搭建已经完成, 可以直接运行我们的示例了。 所有的示例在 `seatunnel-examples` 模块里,
你可以随意选择进行编译和调试,参考 [running or debugging
it in IDEA](https://www.jetbrains.com/help/idea/run-debug-configuration.html)。
-我们使用
`seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineExample.java`
+我们使用
`seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineLocalExample.java`
作为示例, 运行成功后的输出如下:
```log
diff --git
a/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineClusterClientExample.java
b/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineClusterClientExample.java
new file mode 100644
index 0000000000..c1d47520bb
--- /dev/null
+++
b/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineClusterClientExample.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.example.engine;
+
+import org.apache.seatunnel.core.starter.SeaTunnel;
+import org.apache.seatunnel.core.starter.seatunnel.args.ClientCommandArgs;
+
+import java.io.FileNotFoundException;
+import java.net.URISyntaxException;
+import java.nio.file.Paths;
+import java.util.Collections;
+
+public class SeaTunnelEngineClusterClientExample {
+
+ public static void main(String[] args) throws Exception {
+ String id = "834720088434147329";
+ String configurePath = "/examples/fake_to_console.conf";
+
+ submit(configurePath, id);
+
+ // list();
+ // savepoint(id);
+ // restore(configurePath, id);
+ // cancel(id);
+ }
+
+ public static void list() {
+ ClientCommandArgs clientCommandArgs = new ClientCommandArgs();
+ clientCommandArgs.setListJob(true);
+ SeaTunnel.run(clientCommandArgs.buildCommand());
+ }
+
+ public static void submit(String configurePath, String id)
+ throws FileNotFoundException, URISyntaxException {
+ String configFile =
SeaTunnelEngineLocalExample.getTestConfigFile(configurePath);
+ ClientCommandArgs clientCommandArgs = new ClientCommandArgs();
+ clientCommandArgs.setConfigFile(configFile);
+ clientCommandArgs.setCheckConfig(false);
+
clientCommandArgs.setJobName(Paths.get(configFile).getFileName().toString());
+ clientCommandArgs.setAsync(true);
+ clientCommandArgs.setCustomJobId(id);
+ SeaTunnel.run(clientCommandArgs.buildCommand());
+ }
+
+ public static void restore(String configurePath, String id)
+ throws FileNotFoundException, URISyntaxException {
+ String configFile =
SeaTunnelEngineLocalExample.getTestConfigFile(configurePath);
+ ClientCommandArgs clientCommandArgs = new ClientCommandArgs();
+ clientCommandArgs.setConfigFile(configFile);
+ clientCommandArgs.setRestoreJobId(id);
+ clientCommandArgs.setAsync(true);
+ SeaTunnel.run(clientCommandArgs.buildCommand());
+ }
+
+ public static void savepoint(String id) {
+ ClientCommandArgs clientCommandArgs = new ClientCommandArgs();
+ clientCommandArgs.setSavePointJobId(id);
+ SeaTunnel.run(clientCommandArgs.buildCommand());
+ }
+
+ public static void cancel(String id) {
+ ClientCommandArgs clientCommandArgs = new ClientCommandArgs();
+ clientCommandArgs.setCancelJobId(Collections.singletonList(id));
+ SeaTunnel.run(clientCommandArgs.buildCommand());
+ }
+}
diff --git
a/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineServerExample.java
b/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineClusterServerExample.java
similarity index 96%
rename from
seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineServerExample.java
rename to
seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineClusterServerExample.java
index 07b363c41d..969fad5c34 100644
---
a/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineServerExample.java
+++
b/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineClusterServerExample.java
@@ -21,7 +21,7 @@ import org.apache.seatunnel.core.starter.SeaTunnel;
import org.apache.seatunnel.core.starter.exception.CommandException;
import org.apache.seatunnel.core.starter.seatunnel.args.ServerCommandArgs;
-public class SeaTunnelEngineServerExample {
+public class SeaTunnelEngineClusterServerExample {
static {
//
https://logging.apache.org/log4j/2.x/manual/simple-logger.html#isThreadContextMapInheritable
diff --git
a/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineExample.java
b/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineLocalExample.java
similarity index 93%
rename from
seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineExample.java
rename to
seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineLocalExample.java
index 26a965fefb..3c23400214 100644
---
a/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineExample.java
+++
b/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineLocalExample.java
@@ -27,7 +27,7 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Paths;
-public class SeaTunnelEngineExample {
+public class SeaTunnelEngineLocalExample {
static {
//
https://logging.apache.org/log4j/2.x/manual/simple-logger.html#isThreadContextMapInheritable
@@ -43,14 +43,14 @@ public class SeaTunnelEngineExample {
clientCommandArgs.setCheckConfig(false);
clientCommandArgs.setJobName(Paths.get(configFile).getFileName().toString());
// Change Execution Mode to CLUSTER to use client mode, before do
this, you should start
- // SeaTunnelEngineServerExample
+ // SeaTunnelEngineClusterServerExample
clientCommandArgs.setMasterType(MasterType.LOCAL);
SeaTunnel.run(clientCommandArgs.buildCommand());
}
public static String getTestConfigFile(String configFile)
throws FileNotFoundException, URISyntaxException {
- URL resource = SeaTunnelEngineExample.class.getResource(configFile);
+ URL resource =
SeaTunnelEngineLocalExample.class.getResource(configFile);
if (resource == null) {
throw new FileNotFoundException("Can't find config file: " +
configFile);
}