Skip to content

Commit 65aedf6

Browse files
authored
[Feature][Tool] Add connector check script for issue 6199 (apache#6635)
1 parent 9954d1e commit 65aedf6

File tree

24 files changed

+1173
-15
lines changed

24 files changed

+1173
-15
lines changed

docs/en/command/connector-check.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Connector check command usage
2+
3+
## Command Entrypoint
4+
5+
```shell
6+
bin/seatunnel-connector.sh
7+
```
8+
9+
## Options
10+
11+
```text
12+
Usage: seatunnel-connector.sh [options]
13+
Options:
14+
-h, --help Show the usage message
15+
-l, --list List all supported plugins(sources, sinks, transforms)
16+
(default: false)
17+
-o, --option-rule Get option rule of the plugin by the plugin
18+
identifier(connector name or transform name)
19+
-pt, --plugin-type SeaTunnel plugin type, support [source, sink,
20+
transform]
21+
```
22+
23+
## Example
24+
25+
```shell
26+
# List all supported connectors(sources and sinks) and transforms
27+
bin/seatunnel-connector.sh -l
28+
# List all supported sinks
29+
bin/seatunnel-connector.sh -l -pt sink
30+
# Get option rule of the connector or transform by the name
31+
bin/seatunnel-connector.sh -o Paimon
32+
# Get option rule of paimon sink
33+
bin/seatunnel-connector.sh -o Paimon -pt sink
34+
```
35+

docs/sidebars.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ const sidebars = {
161161
"type": "category",
162162
"label": "Command",
163163
"items": [
164-
"command/usage"
164+
"command/usage",
165+
"command/connector-check"
165166
]
166167
},
167168
{

docs/zh/command/connector-check.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# 连接器检查命令用法
2+
3+
## 命令入口
4+
5+
```shell
6+
bin/seatunnel-connector.sh
7+
```
8+
9+
## 命令选项
10+
11+
```text
12+
Usage: seatunnel-connector.sh [options]
13+
Options:
14+
-h, --help Show the usage message
15+
-l, --list List all supported plugins(sources, sinks, transforms)
16+
(default: false)
17+
-o, --option-rule Get option rule of the plugin by the plugin
18+
identifier(connector name or transform name)
19+
-pt, --plugin-type SeaTunnel plugin type, support [source, sink,
20+
transform]
21+
```
22+
23+
## 例子
24+
25+
```shell
26+
# List all supported connectors(sources and sinks) and transforms
27+
bin/seatunnel-connector.sh -l
28+
# List all supported sinks
29+
bin/seatunnel-connector.sh -l -pt sink
30+
# Get option rule of the connector or transform by the name
31+
bin/seatunnel-connector.sh -o Paimon
32+
# Get option rule of paimon sink
33+
bin/seatunnel-connector.sh -o Paimon -pt sink
34+
```
35+

seatunnel-connectors-v2/connector-file/connector-file-cos/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/cos/source/CosFileSourceFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
public class CosFileSourceFactory implements TableSourceFactory {
3636
@Override
3737
public String factoryIdentifier() {
38-
return FileSystemType.OSS.getFileSystemPluginName();
38+
return FileSystemType.COS.getFileSystemPluginName();
3939
}
4040

4141
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@echo off
2+
rem Licensed to the Apache Software Foundation (ASF) under one or more
3+
rem contributor license agreements. See the NOTICE file distributed with
4+
rem this work for additional information regarding copyright ownership.
5+
rem The ASF licenses this file to You under the Apache License, Version 2.0
6+
rem (the "License"); you may not use this file except in compliance with
7+
rem the License. You may obtain a copy of the License at
8+
rem
9+
rem http://www.apache.org/licenses/LICENSE-2.0
10+
rem
11+
rem Unless required by applicable law or agreed to in writing, software
12+
rem distributed under the License is distributed on an "AS IS" BASIS,
13+
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
rem See the License for the specific language governing permissions and
15+
rem limitations under the License.
16+
17+
REM resolve links - %0 may be a softlink
18+
for %%F in ("%~f0") do (
19+
set "PRG=%%~fF"
20+
set "PRG_DIR=%%~dpF"
21+
set "APP_DIR=%%~dpF.."
22+
)
23+
24+
set "APP_JAR=%APP_DIR%\starter\seatunnel-starter.jar"
25+
set "LOAD_CLASS=org.apache.seatunnel.core.starter.seatunnel.SeaTunnelConnector"
26+
27+
if "%~1" == "" (
28+
set "args=-h"
29+
) else (
30+
set "args=%*"
31+
)
32+
33+
set "CLASS_PATH=%APP_DIR%\connectors\*;%APP_JAR%;%APP_DIR%\lib\seatunnel-transforms-v2.jar"
34+
35+
java -cp "%CLASS_PATH%" %LOAD_CLASS% %args% | findstr /v /c:"org.apache.seatunnel.plugin.discovery.AbstractPluginDiscovery"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
set -eu
20+
# resolve links - $0 may be a softlink
21+
PRG="$0"
22+
23+
while [ -h "$PRG" ] ; do
24+
# shellcheck disable=SC2006
25+
ls=`ls -ld "$PRG"`
26+
# shellcheck disable=SC2006
27+
link=`expr "$ls" : '.*-> \(.*\)$'`
28+
if expr "$link" : '/.*' > /dev/null; then
29+
PRG="$link"
30+
else
31+
# shellcheck disable=SC2006
32+
PRG=`dirname "$PRG"`/"$link"
33+
fi
34+
done
35+
36+
PRG_DIR=$(dirname "$PRG")
37+
APP_DIR=$(cd "$PRG_DIR/.." >/dev/null; pwd)
38+
APP_JAR=${APP_DIR}/starter/seatunnel-starter.jar
39+
LOAD_CLASS="org.apache.seatunnel.core.starter.seatunnel.SeaTunnelConnector"
40+
41+
if [ $# == 0 ]
42+
then
43+
args="-h"
44+
else
45+
args=$@
46+
fi
47+
48+
set +u
49+
CLASS_PATH=${APP_DIR}/connectors/*:${APP_JAR}:${APP_DIR}/lib/seatunnel-transforms-v2.jar
50+
51+
java -cp ${CLASS_PATH} ${LOAD_CLASS} ${args} | grep -v 'org\.apache\.seatunnel\.plugin\.discovery\.AbstractPluginDiscovery'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.seatunnel.core.starter.seatunnel;
19+
20+
import org.apache.seatunnel.core.starter.SeaTunnel;
21+
import org.apache.seatunnel.core.starter.seatunnel.args.ConnectorCheckCommandArgs;
22+
import org.apache.seatunnel.core.starter.utils.CommandLineUtils;
23+
24+
import lombok.extern.slf4j.Slf4j;
25+
26+
@Slf4j
27+
public class SeaTunnelConnector {
28+
private static final String SHELL_NAME = "seatunnel-connector.sh";
29+
30+
public static void main(String[] args) {
31+
ConnectorCheckCommandArgs clientCommandArgs =
32+
CommandLineUtils.parse(args, new ConnectorCheckCommandArgs(), SHELL_NAME, true);
33+
SeaTunnel.run(clientCommandArgs.buildCommand());
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.seatunnel.core.starter.seatunnel.args;
19+
20+
import org.apache.seatunnel.common.constants.PluginType;
21+
import org.apache.seatunnel.core.starter.command.Command;
22+
import org.apache.seatunnel.core.starter.command.CommandArgs;
23+
import org.apache.seatunnel.core.starter.seatunnel.command.ConnectorCheckCommand;
24+
25+
import com.beust.jcommander.IStringConverter;
26+
import com.beust.jcommander.Parameter;
27+
import lombok.Data;
28+
import lombok.EqualsAndHashCode;
29+
30+
@EqualsAndHashCode(callSuper = true)
31+
@Data
32+
public class ConnectorCheckCommandArgs extends CommandArgs {
33+
@Parameter(
34+
names = {"-l", "--list"},
35+
description = "List all supported plugins(sources, sinks, transforms)")
36+
private boolean listConnectors = false;
37+
38+
@Parameter(
39+
names = {"-o", "--option-rule"},
40+
description =
41+
"Get option rule of the plugin by the plugin identifier(connector name or transform name)")
42+
private String pluginIdentifier;
43+
44+
@Parameter(
45+
names = {"-pt", "--plugin-type"},
46+
description = "SeaTunnel plugin type, support [source, sink, transform]",
47+
converter = SeaTunnelPluginTypeConverter.class)
48+
private PluginType pluginType;
49+
50+
@Override
51+
public Command<?> buildCommand() {
52+
return new ConnectorCheckCommand(this);
53+
}
54+
55+
public static class SeaTunnelPluginTypeConverter implements IStringConverter<PluginType> {
56+
@Override
57+
public PluginType convert(String value) {
58+
try {
59+
return PluginType.valueOf(value.toUpperCase());
60+
} catch (IllegalArgumentException e) {
61+
throw new IllegalArgumentException(
62+
"The plugin type of seaTunnel only "
63+
+ "support these options: [source, transform, sink]");
64+
}
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)