-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature][Tool] Add connector check script for issue 6199 (#6635)
- Loading branch information
Showing
24 changed files
with
1,173 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Connector check command usage | ||
|
||
## Command Entrypoint | ||
|
||
```shell | ||
bin/seatunnel-connector.sh | ||
``` | ||
|
||
## Options | ||
|
||
```text | ||
Usage: seatunnel-connector.sh [options] | ||
Options: | ||
-h, --help Show the usage message | ||
-l, --list List all supported plugins(sources, sinks, transforms) | ||
(default: false) | ||
-o, --option-rule Get option rule of the plugin by the plugin | ||
identifier(connector name or transform name) | ||
-pt, --plugin-type SeaTunnel plugin type, support [source, sink, | ||
transform] | ||
``` | ||
|
||
## Example | ||
|
||
```shell | ||
# List all supported connectors(sources and sinks) and transforms | ||
bin/seatunnel-connector.sh -l | ||
# List all supported sinks | ||
bin/seatunnel-connector.sh -l -pt sink | ||
# Get option rule of the connector or transform by the name | ||
bin/seatunnel-connector.sh -o Paimon | ||
# Get option rule of paimon sink | ||
bin/seatunnel-connector.sh -o Paimon -pt sink | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 连接器检查命令用法 | ||
|
||
## 命令入口 | ||
|
||
```shell | ||
bin/seatunnel-connector.sh | ||
``` | ||
|
||
## 命令选项 | ||
|
||
```text | ||
Usage: seatunnel-connector.sh [options] | ||
Options: | ||
-h, --help Show the usage message | ||
-l, --list List all supported plugins(sources, sinks, transforms) | ||
(default: false) | ||
-o, --option-rule Get option rule of the plugin by the plugin | ||
identifier(connector name or transform name) | ||
-pt, --plugin-type SeaTunnel plugin type, support [source, sink, | ||
transform] | ||
``` | ||
|
||
## 例子 | ||
|
||
```shell | ||
# List all supported connectors(sources and sinks) and transforms | ||
bin/seatunnel-connector.sh -l | ||
# List all supported sinks | ||
bin/seatunnel-connector.sh -l -pt sink | ||
# Get option rule of the connector or transform by the name | ||
bin/seatunnel-connector.sh -o Paimon | ||
# Get option rule of paimon sink | ||
bin/seatunnel-connector.sh -o Paimon -pt sink | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
35 changes: 35 additions & 0 deletions
35
seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-connector.cmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@echo off | ||
rem Licensed to the Apache Software Foundation (ASF) under one or more | ||
rem contributor license agreements. See the NOTICE file distributed with | ||
rem this work for additional information regarding copyright ownership. | ||
rem The ASF licenses this file to You under the Apache License, Version 2.0 | ||
rem (the "License"); you may not use this file except in compliance with | ||
rem the License. You may obtain a copy of the License at | ||
rem | ||
rem http://www.apache.org/licenses/LICENSE-2.0 | ||
rem | ||
rem Unless required by applicable law or agreed to in writing, software | ||
rem distributed under the License is distributed on an "AS IS" BASIS, | ||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
rem See the License for the specific language governing permissions and | ||
rem limitations under the License. | ||
|
||
REM resolve links - %0 may be a softlink | ||
for %%F in ("%~f0") do ( | ||
set "PRG=%%~fF" | ||
set "PRG_DIR=%%~dpF" | ||
set "APP_DIR=%%~dpF.." | ||
) | ||
|
||
set "APP_JAR=%APP_DIR%\starter\seatunnel-starter.jar" | ||
set "LOAD_CLASS=org.apache.seatunnel.core.starter.seatunnel.SeaTunnelConnector" | ||
|
||
if "%~1" == "" ( | ||
set "args=-h" | ||
) else ( | ||
set "args=%*" | ||
) | ||
|
||
set "CLASS_PATH=%APP_DIR%\connectors\*;%APP_JAR%;%APP_DIR%\lib\seatunnel-transforms-v2.jar" | ||
|
||
java -cp "%CLASS_PATH%" %LOAD_CLASS% %args% | findstr /v /c:"org.apache.seatunnel.plugin.discovery.AbstractPluginDiscovery" |
51 changes: 51 additions & 0 deletions
51
seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-connector.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
# | ||
# 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. | ||
# | ||
|
||
set -eu | ||
# resolve links - $0 may be a softlink | ||
PRG="$0" | ||
|
||
while [ -h "$PRG" ] ; do | ||
# shellcheck disable=SC2006 | ||
ls=`ls -ld "$PRG"` | ||
# shellcheck disable=SC2006 | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
PRG="$link" | ||
else | ||
# shellcheck disable=SC2006 | ||
PRG=`dirname "$PRG"`/"$link" | ||
fi | ||
done | ||
|
||
PRG_DIR=$(dirname "$PRG") | ||
APP_DIR=$(cd "$PRG_DIR/.." >/dev/null; pwd) | ||
APP_JAR=${APP_DIR}/starter/seatunnel-starter.jar | ||
LOAD_CLASS="org.apache.seatunnel.core.starter.seatunnel.SeaTunnelConnector" | ||
|
||
if [ $# == 0 ] | ||
then | ||
args="-h" | ||
else | ||
args=$@ | ||
fi | ||
|
||
set +u | ||
CLASS_PATH=${APP_DIR}/connectors/*:${APP_JAR}:${APP_DIR}/lib/seatunnel-transforms-v2.jar | ||
|
||
java -cp ${CLASS_PATH} ${LOAD_CLASS} ${args} | grep -v 'org\.apache\.seatunnel\.plugin\.discovery\.AbstractPluginDiscovery' |
35 changes: 35 additions & 0 deletions
35
...starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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.core.starter.seatunnel; | ||
|
||
import org.apache.seatunnel.core.starter.SeaTunnel; | ||
import org.apache.seatunnel.core.starter.seatunnel.args.ConnectorCheckCommandArgs; | ||
import org.apache.seatunnel.core.starter.utils.CommandLineUtils; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class SeaTunnelConnector { | ||
private static final String SHELL_NAME = "seatunnel-connector.sh"; | ||
|
||
public static void main(String[] args) { | ||
ConnectorCheckCommandArgs clientCommandArgs = | ||
CommandLineUtils.parse(args, new ConnectorCheckCommandArgs(), SHELL_NAME, true); | ||
SeaTunnel.run(clientCommandArgs.buildCommand()); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...main/java/org/apache/seatunnel/core/starter/seatunnel/args/ConnectorCheckCommandArgs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* 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.core.starter.seatunnel.args; | ||
|
||
import org.apache.seatunnel.common.constants.PluginType; | ||
import org.apache.seatunnel.core.starter.command.Command; | ||
import org.apache.seatunnel.core.starter.command.CommandArgs; | ||
import org.apache.seatunnel.core.starter.seatunnel.command.ConnectorCheckCommand; | ||
|
||
import com.beust.jcommander.IStringConverter; | ||
import com.beust.jcommander.Parameter; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
@EqualsAndHashCode(callSuper = true) | ||
@Data | ||
public class ConnectorCheckCommandArgs extends CommandArgs { | ||
@Parameter( | ||
names = {"-l", "--list"}, | ||
description = "List all supported plugins(sources, sinks, transforms)") | ||
private boolean listConnectors = false; | ||
|
||
@Parameter( | ||
names = {"-o", "--option-rule"}, | ||
description = | ||
"Get option rule of the plugin by the plugin identifier(connector name or transform name)") | ||
private String pluginIdentifier; | ||
|
||
@Parameter( | ||
names = {"-pt", "--plugin-type"}, | ||
description = "SeaTunnel plugin type, support [source, sink, transform]", | ||
converter = SeaTunnelPluginTypeConverter.class) | ||
private PluginType pluginType; | ||
|
||
@Override | ||
public Command<?> buildCommand() { | ||
return new ConnectorCheckCommand(this); | ||
} | ||
|
||
public static class SeaTunnelPluginTypeConverter implements IStringConverter<PluginType> { | ||
@Override | ||
public PluginType convert(String value) { | ||
try { | ||
return PluginType.valueOf(value.toUpperCase()); | ||
} catch (IllegalArgumentException e) { | ||
throw new IllegalArgumentException( | ||
"The plugin type of seaTunnel only " | ||
+ "support these options: [source, transform, sink]"); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.