diff --git a/seatunnel-datasource/seatunnel-datasource-client/src/main/java/org/apache/seatunnel/datasource/classloader/DatasourceLoadConfig.java b/seatunnel-datasource/seatunnel-datasource-client/src/main/java/org/apache/seatunnel/datasource/classloader/DatasourceLoadConfig.java index b2869691a..b8ff93ce8 100644 --- a/seatunnel-datasource/seatunnel-datasource-client/src/main/java/org/apache/seatunnel/datasource/classloader/DatasourceLoadConfig.java +++ b/seatunnel-datasource/seatunnel-datasource-client/src/main/java/org/apache/seatunnel/datasource/classloader/DatasourceLoadConfig.java @@ -97,6 +97,12 @@ public class DatasourceLoadConfig { classLoaderFactoryName.put( "JDBC-DB2", "org.apache.seatunnel.datasource.plugin.db2.jdbc.Db2JdbcDataSourceFactory"); + classLoaderFactoryName.put( + "FAKESOURCE", + "org.apache.seatunnel.datasource.plugin.fakesource.FakeSourceDataSourceFactory"); + classLoaderFactoryName.put( + "CONSOLE", + "org.apache.seatunnel.datasource.plugin.console.ConsoleDataSourceFactory"); classLoaderJarName.put("JDBC-ORACLE", "datasource-jdbc-oracle-"); classLoaderJarName.put("JDBC-CLICKHOUSE", "datasource-jdbc-clickhouse-"); @@ -118,6 +124,8 @@ public class DatasourceLoadConfig { classLoaderJarName.put("JDBC-STARROCKS", "datasource-jdbc-starrocks-"); classLoaderJarName.put("MONGODB", "datasource-mongodb-"); classLoaderJarName.put("JDBC-DB2", "datasource-jdbc-db2-"); + classLoaderJarName.put("FAKESOURCE", "datasource-fakesource-"); + classLoaderJarName.put("CONSOLE", "datasource-console-"); } public static final Set pluginSet = @@ -136,7 +144,9 @@ public class DatasourceLoadConfig { "SqlServer-CDC", "StarRocks", "MongoDB", - "JDBC-Db2"); + "JDBC-Db2", + "FakeSource", + "Console"); public static Map datasourceClassLoaders = new HashMap<>(); diff --git a/seatunnel-datasource/seatunnel-datasource-plugins/datasource-console/pom.xml b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-console/pom.xml new file mode 100644 index 000000000..d97d155ca --- /dev/null +++ b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-console/pom.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + + org.apache.seatunnel + seatunnel-datasource-plugins + ${revision} + + + datasource-console + + + org.apache.seatunnel + datasource-plugins-api + ${project.version} + provided + + + diff --git a/seatunnel-datasource/seatunnel-datasource-plugins/datasource-console/src/main/java/org/apache/seatunnel/datasource/plugin/console/ConsoleDataSourceChannel.java b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-console/src/main/java/org/apache/seatunnel/datasource/plugin/console/ConsoleDataSourceChannel.java new file mode 100644 index 000000000..63a997ca1 --- /dev/null +++ b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-console/src/main/java/org/apache/seatunnel/datasource/plugin/console/ConsoleDataSourceChannel.java @@ -0,0 +1,72 @@ +/* + * 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.datasource.plugin.console; + +import org.apache.seatunnel.api.configuration.util.OptionRule; +import org.apache.seatunnel.datasource.plugin.api.DataSourceChannel; +import org.apache.seatunnel.datasource.plugin.api.model.TableField; + +import lombok.NonNull; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public class ConsoleDataSourceChannel implements DataSourceChannel { + + @Override + public OptionRule getDataSourceOptions(@NonNull String pluginName) { + return ConsoleDataSourceConfig.OPTION_RULE; + } + + @Override + public OptionRule getDatasourceMetadataFieldsByDataSourceName(@NonNull String pluginName) { + return ConsoleDataSourceConfig.METADATA_RULE; + } + + @Override + public List getTables( + @NonNull String pluginName, + Map requestParams, + String database, + Map options) { + return Arrays.asList("console_fake_table"); + } + + @Override + public List getDatabases( + @NonNull String pluginName, @NonNull Map requestParams) { + return Arrays.asList("console_fake_database"); + } + + @Override + public boolean checkDataSourceConnectivity( + @NonNull String pluginName, @NonNull Map requestParams) { + return true; + } + + @Override + public List getTableFields( + @NonNull String pluginName, + @NonNull Map requestParams, + @NonNull String database, + @NonNull String table) { + return Collections.emptyList(); + } +} diff --git a/seatunnel-datasource/seatunnel-datasource-plugins/datasource-console/src/main/java/org/apache/seatunnel/datasource/plugin/console/ConsoleDataSourceConfig.java b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-console/src/main/java/org/apache/seatunnel/datasource/plugin/console/ConsoleDataSourceConfig.java new file mode 100644 index 000000000..8a8fff6a6 --- /dev/null +++ b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-console/src/main/java/org/apache/seatunnel/datasource/plugin/console/ConsoleDataSourceConfig.java @@ -0,0 +1,47 @@ +/* + * 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.datasource.plugin.console; + +import org.apache.seatunnel.api.configuration.Option; +import org.apache.seatunnel.api.configuration.Options; +import org.apache.seatunnel.api.configuration.util.OptionRule; +import org.apache.seatunnel.datasource.plugin.api.DataSourcePluginInfo; +import org.apache.seatunnel.datasource.plugin.api.DatasourcePluginTypeEnum; + +public class ConsoleDataSourceConfig { + + public static final String PLUGIN_NAME = "Console"; + + public static final DataSourcePluginInfo CONSOLE_DATASOURCE_PLUGIN_INFO = + DataSourcePluginInfo.builder() + .name(PLUGIN_NAME) + .icon(PLUGIN_NAME) + .version("1.0.0") + .type(DatasourcePluginTypeEnum.FAKE_CONNECTION.getCode()) + .build(); + + public static final Option URL = + Options.key("url") + .stringType() + .defaultValue("dummy://URL") + .withDescription( + "This is required to meet the design constraints, however, it won't be utilized during execution."); + + public static final OptionRule OPTION_RULE = OptionRule.builder().required(URL).build(); + public static final OptionRule METADATA_RULE = OptionRule.builder().build(); +} diff --git a/seatunnel-datasource/seatunnel-datasource-plugins/datasource-console/src/main/java/org/apache/seatunnel/datasource/plugin/console/ConsoleDataSourceFactory.java b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-console/src/main/java/org/apache/seatunnel/datasource/plugin/console/ConsoleDataSourceFactory.java new file mode 100644 index 000000000..0b40fb14b --- /dev/null +++ b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-console/src/main/java/org/apache/seatunnel/datasource/plugin/console/ConsoleDataSourceFactory.java @@ -0,0 +1,48 @@ +/* + * 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.datasource.plugin.console; + +import org.apache.seatunnel.datasource.plugin.api.DataSourceChannel; +import org.apache.seatunnel.datasource.plugin.api.DataSourceFactory; +import org.apache.seatunnel.datasource.plugin.api.DataSourcePluginInfo; + +import com.google.auto.service.AutoService; +import com.google.common.collect.Sets; +import lombok.extern.slf4j.Slf4j; + +import java.util.Set; + +@Slf4j +@AutoService(DataSourceFactory.class) +public class ConsoleDataSourceFactory implements DataSourceFactory { + + @Override + public String factoryIdentifier() { + return ConsoleDataSourceConfig.PLUGIN_NAME; + } + + @Override + public Set supportedDataSources() { + return Sets.newHashSet(ConsoleDataSourceConfig.CONSOLE_DATASOURCE_PLUGIN_INFO); + } + + @Override + public DataSourceChannel createChannel() { + return new ConsoleDataSourceChannel(); + } +} diff --git a/seatunnel-datasource/seatunnel-datasource-plugins/datasource-fakesource/pom.xml b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-fakesource/pom.xml new file mode 100644 index 000000000..5c195d04b --- /dev/null +++ b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-fakesource/pom.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + + org.apache.seatunnel + seatunnel-datasource-plugins + ${revision} + + + datasource-fakesource + + + org.apache.seatunnel + datasource-plugins-api + ${project.version} + provided + + + diff --git a/seatunnel-datasource/seatunnel-datasource-plugins/datasource-fakesource/src/main/java/org/apache/seatunnel/datasource/plugin/fakesource/FakeSourceDataSourceChannel.java b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-fakesource/src/main/java/org/apache/seatunnel/datasource/plugin/fakesource/FakeSourceDataSourceChannel.java new file mode 100644 index 000000000..b99288ac1 --- /dev/null +++ b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-fakesource/src/main/java/org/apache/seatunnel/datasource/plugin/fakesource/FakeSourceDataSourceChannel.java @@ -0,0 +1,94 @@ +/* + * 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.datasource.plugin.fakesource; + +import org.apache.seatunnel.api.configuration.util.OptionRule; +import org.apache.seatunnel.common.utils.JsonUtils; +import org.apache.seatunnel.datasource.plugin.api.DataSourceChannel; +import org.apache.seatunnel.datasource.plugin.api.DataSourcePluginException; +import org.apache.seatunnel.datasource.plugin.api.model.TableField; + +import lombok.NonNull; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class FakeSourceDataSourceChannel implements DataSourceChannel { + + @Override + public OptionRule getDataSourceOptions(@NonNull String pluginName) { + return FakeSourceDataSourceConfig.OPTION_RULE; + } + + @Override + public OptionRule getDatasourceMetadataFieldsByDataSourceName(@NonNull String pluginName) { + return FakeSourceDataSourceConfig.METADATA_RULE; + } + + @Override + public List getTables( + @NonNull String pluginName, + Map requestParams, + String database, + Map options) { + return Arrays.asList("fake_table"); + } + + @Override + public List getDatabases( + @NonNull String pluginName, @NonNull Map requestParams) { + return Arrays.asList("fake_database"); + } + + @Override + public boolean checkDataSourceConnectivity( + @NonNull String pluginName, @NonNull Map requestParams) { + try { + JsonUtils.toMap(requestParams.get("fields")); + } catch (RuntimeException ex) { + throw new DataSourcePluginException( + "Failed to parse field parameter. " + ex.getMessage(), ex); + } + return true; + } + + @Override + public List getTableFields( + @NonNull String pluginName, + @NonNull Map requestParams, + @NonNull String database, + @NonNull String table) { + String fieldsJson = requestParams.get("fields"); + if (fieldsJson == null) { + return Collections.emptyList(); + } + Map fields = JsonUtils.toMap(fieldsJson); + return fields.entrySet().stream() + .map( + entry -> { + TableField tableField = new TableField(); + tableField.setName(entry.getKey()); + tableField.setType(entry.getValue()); + return tableField; + }) + .collect(Collectors.toList()); + } +} diff --git a/seatunnel-datasource/seatunnel-datasource-plugins/datasource-fakesource/src/main/java/org/apache/seatunnel/datasource/plugin/fakesource/FakeSourceDataSourceConfig.java b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-fakesource/src/main/java/org/apache/seatunnel/datasource/plugin/fakesource/FakeSourceDataSourceConfig.java new file mode 100644 index 000000000..b60c12b2d --- /dev/null +++ b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-fakesource/src/main/java/org/apache/seatunnel/datasource/plugin/fakesource/FakeSourceDataSourceConfig.java @@ -0,0 +1,52 @@ +/* + * 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.datasource.plugin.fakesource; + +import org.apache.seatunnel.api.configuration.Option; +import org.apache.seatunnel.api.configuration.Options; +import org.apache.seatunnel.api.configuration.util.OptionRule; +import org.apache.seatunnel.datasource.plugin.api.DataSourcePluginInfo; +import org.apache.seatunnel.datasource.plugin.api.DatasourcePluginTypeEnum; + +public class FakeSourceDataSourceConfig { + + public static final String PLUGIN_NAME = "FakeSource"; + + public static final DataSourcePluginInfo FAKESOURCE_DATASOURCE_PLUGIN_INFO = + DataSourcePluginInfo.builder() + .name(PLUGIN_NAME) + .icon(PLUGIN_NAME) + .version("1.0.0") + .type(DatasourcePluginTypeEnum.FAKE_CONNECTION.getCode()) + .build(); + public static final Option FAKESOURCE_FIELDS = + Options.key("fields") + .stringType() + .defaultValue( + "{\n" + + " \"name\": \"string\",\n" + + " \"age\": \"int\"\n" + + " }") + .withDescription( + "This value will be used to populate field details in UI, however, it won't be utilized during execution."); + + public static final OptionRule OPTION_RULE = + OptionRule.builder().required(FAKESOURCE_FIELDS).build(); + + public static final OptionRule METADATA_RULE = OptionRule.builder().required().build(); +} diff --git a/seatunnel-datasource/seatunnel-datasource-plugins/datasource-fakesource/src/main/java/org/apache/seatunnel/datasource/plugin/fakesource/FakeSourceDataSourceFactory.java b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-fakesource/src/main/java/org/apache/seatunnel/datasource/plugin/fakesource/FakeSourceDataSourceFactory.java new file mode 100644 index 000000000..520561308 --- /dev/null +++ b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-fakesource/src/main/java/org/apache/seatunnel/datasource/plugin/fakesource/FakeSourceDataSourceFactory.java @@ -0,0 +1,48 @@ +/* + * 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.datasource.plugin.fakesource; + +import org.apache.seatunnel.datasource.plugin.api.DataSourceChannel; +import org.apache.seatunnel.datasource.plugin.api.DataSourceFactory; +import org.apache.seatunnel.datasource.plugin.api.DataSourcePluginInfo; + +import com.google.auto.service.AutoService; +import com.google.common.collect.Sets; +import lombok.extern.slf4j.Slf4j; + +import java.util.Set; + +@Slf4j +@AutoService(DataSourceFactory.class) +public class FakeSourceDataSourceFactory implements DataSourceFactory { + + @Override + public String factoryIdentifier() { + return FakeSourceDataSourceConfig.PLUGIN_NAME; + } + + @Override + public Set supportedDataSources() { + return Sets.newHashSet(FakeSourceDataSourceConfig.FAKESOURCE_DATASOURCE_PLUGIN_INFO); + } + + @Override + public DataSourceChannel createChannel() { + return new FakeSourceDataSourceChannel(); + } +} diff --git a/seatunnel-datasource/seatunnel-datasource-plugins/datasource-plugins-api/src/main/java/org/apache/seatunnel/datasource/plugin/api/DatasourcePluginTypeEnum.java b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-plugins-api/src/main/java/org/apache/seatunnel/datasource/plugin/api/DatasourcePluginTypeEnum.java index e5d8e0049..47dc2adec 100644 --- a/seatunnel-datasource/seatunnel-datasource-plugins/datasource-plugins-api/src/main/java/org/apache/seatunnel/datasource/plugin/api/DatasourcePluginTypeEnum.java +++ b/seatunnel-datasource/seatunnel-datasource-plugins/datasource-plugins-api/src/main/java/org/apache/seatunnel/datasource/plugin/api/DatasourcePluginTypeEnum.java @@ -25,7 +25,8 @@ public enum DatasourcePluginTypeEnum { FILE(2, "file", "文件"), NO_STRUCTURED(3, "no_structured", "非结构化数据(NoSQLs)"), STORAGE(4, "storage", "存储"), - REMOTE_CONNECTION(5, "remote_connection", "远程连接"); + REMOTE_CONNECTION(5, "remote_connection", "远程连接"), + FAKE_CONNECTION(6, "fake_connection", "假连接"); private final Integer code; diff --git a/seatunnel-datasource/seatunnel-datasource-plugins/pom.xml b/seatunnel-datasource/seatunnel-datasource-plugins/pom.xml index 13af3009f..7a4568582 100644 --- a/seatunnel-datasource/seatunnel-datasource-plugins/pom.xml +++ b/seatunnel-datasource/seatunnel-datasource-plugins/pom.xml @@ -46,6 +46,8 @@ datasource-jdbc-tidb datasource-mongodb datasource-jdbc-db2 + datasource-fakesource + datasource-console diff --git a/seatunnel-server/seatunnel-app/src/main/bin/download_datasource.sh b/seatunnel-server/seatunnel-app/src/main/bin/download_datasource.sh index 3ea36ab6d..985446340 100644 --- a/seatunnel-server/seatunnel-app/src/main/bin/download_datasource.sh +++ b/seatunnel-server/seatunnel-app/src/main/bin/download_datasource.sh @@ -44,6 +44,8 @@ datasource_list=( "datasource-sqlserver-cdc" "datasource-starrocks" "datasource-mongodb" + "datasource-fakesource" + "datasource-console" ) # the datasource default version is 1.0.0, you can also choose a custom version. eg: 1.1.2: sh install-datasource.sh 2.1.2 diff --git a/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/service/impl/ConnectorServiceImpl.java b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/service/impl/ConnectorServiceImpl.java index 92c60e72a..307066a2f 100644 --- a/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/service/impl/ConnectorServiceImpl.java +++ b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/service/impl/ConnectorServiceImpl.java @@ -65,7 +65,7 @@ public class ConnectorServiceImpl extends SeatunnelBaseServiceImpl implements IC private static final List SKIP_SOURCE = Collections.emptyList(); - private static final List SKIP_SINK = Collections.singletonList("Console"); + private static final List SKIP_SINK = Collections.emptyList(); @Autowired public ConnectorServiceImpl(ConnectorCache connectorCache) { diff --git a/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/thirdparty/datasource/impl/ConsoleDataSourceConfigSwitcher.java b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/thirdparty/datasource/impl/ConsoleDataSourceConfigSwitcher.java new file mode 100644 index 000000000..880c27617 --- /dev/null +++ b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/thirdparty/datasource/impl/ConsoleDataSourceConfigSwitcher.java @@ -0,0 +1,80 @@ +/* + * 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.app.thirdparty.datasource.impl; + +import org.apache.seatunnel.shade.com.typesafe.config.Config; + +import org.apache.seatunnel.api.configuration.Option; +import org.apache.seatunnel.api.configuration.util.OptionRule; +import org.apache.seatunnel.api.configuration.util.RequiredOption; +import org.apache.seatunnel.app.domain.request.connector.BusinessMode; +import org.apache.seatunnel.app.domain.request.job.DataSourceOption; +import org.apache.seatunnel.app.domain.request.job.SelectTableFields; +import org.apache.seatunnel.app.domain.response.datasource.VirtualTableDetailRes; +import org.apache.seatunnel.app.dynamicforms.FormStructure; +import org.apache.seatunnel.app.thirdparty.datasource.AbstractDataSourceConfigSwitcher; +import org.apache.seatunnel.app.thirdparty.datasource.DataSourceConfigSwitcher; +import org.apache.seatunnel.common.constants.PluginType; + +import com.google.auto.service.AutoService; + +import java.util.List; + +@AutoService(DataSourceConfigSwitcher.class) +public class ConsoleDataSourceConfigSwitcher extends AbstractDataSourceConfigSwitcher { + + @Override + public String getDataSourceName() { + return "CONSOLE"; + } + + @Override + public FormStructure filterOptionRule( + String connectorName, + OptionRule dataSourceOptionRule, + OptionRule virtualTableOptionRule, + BusinessMode businessMode, + PluginType pluginType, + OptionRule connectorOptionRule, + List addRequiredOptions, + List> addOptionalOptions, + List excludedKeys) { + return super.filterOptionRule( + connectorName, + dataSourceOptionRule, + virtualTableOptionRule, + businessMode, + pluginType, + connectorOptionRule, + addRequiredOptions, + addOptionalOptions, + excludedKeys); + } + + @Override + public Config mergeDatasourceConfig( + Config dataSourceInstanceConfig, + VirtualTableDetailRes virtualTableDetail, + DataSourceOption dataSourceOption, + SelectTableFields selectTableFields, + BusinessMode businessMode, + PluginType pluginType, + Config connectorConfig) { + return connectorConfig; + } +} diff --git a/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/thirdparty/datasource/impl/FakeSourceDataSourceConfigSwitcher.java b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/thirdparty/datasource/impl/FakeSourceDataSourceConfigSwitcher.java new file mode 100644 index 000000000..29684ddef --- /dev/null +++ b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/thirdparty/datasource/impl/FakeSourceDataSourceConfigSwitcher.java @@ -0,0 +1,79 @@ +/* + * 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.app.thirdparty.datasource.impl; + +import org.apache.seatunnel.shade.com.typesafe.config.Config; + +import org.apache.seatunnel.api.configuration.Option; +import org.apache.seatunnel.api.configuration.util.OptionRule; +import org.apache.seatunnel.api.configuration.util.RequiredOption; +import org.apache.seatunnel.app.domain.request.connector.BusinessMode; +import org.apache.seatunnel.app.domain.request.job.DataSourceOption; +import org.apache.seatunnel.app.domain.request.job.SelectTableFields; +import org.apache.seatunnel.app.domain.response.datasource.VirtualTableDetailRes; +import org.apache.seatunnel.app.dynamicforms.FormStructure; +import org.apache.seatunnel.app.thirdparty.datasource.AbstractDataSourceConfigSwitcher; +import org.apache.seatunnel.app.thirdparty.datasource.DataSourceConfigSwitcher; +import org.apache.seatunnel.common.constants.PluginType; + +import com.google.auto.service.AutoService; + +import java.util.List; + +@AutoService(DataSourceConfigSwitcher.class) +public class FakeSourceDataSourceConfigSwitcher extends AbstractDataSourceConfigSwitcher { + @Override + public String getDataSourceName() { + return "FAKESOURCE"; + } + + @Override + public FormStructure filterOptionRule( + String connectorName, + OptionRule dataSourceOptionRule, + OptionRule virtualTableOptionRule, + BusinessMode businessMode, + PluginType pluginType, + OptionRule connectorOptionRule, + List addRequiredOptions, + List> addOptionalOptions, + List excludedKeys) { + return super.filterOptionRule( + connectorName, + dataSourceOptionRule, + virtualTableOptionRule, + businessMode, + pluginType, + connectorOptionRule, + addRequiredOptions, + addOptionalOptions, + excludedKeys); + } + + @Override + public Config mergeDatasourceConfig( + Config dataSourceInstanceConfig, + VirtualTableDetailRes virtualTableDetail, + DataSourceOption dataSourceOption, + SelectTableFields selectTableFields, + BusinessMode businessMode, + PluginType pluginType, + Config connectorConfig) { + return connectorConfig; + } +} diff --git a/seatunnel-server/seatunnel-app/src/main/resources/connector-datasource-mapper.yaml b/seatunnel-server/seatunnel-app/src/main/resources/connector-datasource-mapper.yaml index 4bcd6fd0f..0ba9a780f 100644 --- a/seatunnel-server/seatunnel-app/src/main/resources/connector-datasource-mapper.yaml +++ b/seatunnel-server/seatunnel-app/src/main/resources/connector-datasource-mapper.yaml @@ -59,6 +59,14 @@ connector-datasource-mapper: dataSources: - MongoDB + FakeSource: + dataSources: + - FakeSource + + Console: + dataSources: + - Console + sourceDatasourceFeatures: JDBC-Mysql: businessMode: @@ -140,6 +148,13 @@ connector-datasource-mapper: - DATA_INTEGRATION sceneMode: - SINGLE_TABLE + FakeSource: + businessMode: + - DATA_INTEGRATION + - DATA_REPLICA + sceneMode: + - SINGLE_TABLE + - MULTIPLE_TABLE sinkDatasourceFeatures: JDBC-Mysql: @@ -224,4 +239,12 @@ connector-datasource-mapper: businessMode: - DATA_INTEGRATION sceneMode: - - SINGLE_TABLE \ No newline at end of file + - SINGLE_TABLE + + Console: + businessMode: + - DATA_INTEGRATION + - DATA_REPLICA + sceneMode: + - SINGLE_TABLE + - MULTIPLE_TABLE \ No newline at end of file diff --git a/seatunnel-server/seatunnel-app/src/main/resources/i18n_en.config b/seatunnel-server/seatunnel-app/src/main/resources/i18n_en.config index 750bacf0f..5d0137125 100644 --- a/seatunnel-server/seatunnel-app/src/main/resources/i18n_en.config +++ b/seatunnel-server/seatunnel-app/src/main/resources/i18n_en.config @@ -294,3 +294,13 @@ PROXY { username = "username" password = "password" } + +FakeSource { + fields = "Fields" + fields_description = "This value will be used to populate field details in UI, however, it won't be utilized during execution." +} + +Console { + url = "JDBC Url" + url_description = "This is required to meet the design constraints, however, it won't be utilized during execution." +} diff --git a/seatunnel-server/seatunnel-app/src/main/resources/i18n_zh.config b/seatunnel-server/seatunnel-app/src/main/resources/i18n_zh.config index 7404a3855..c43b49ff8 100644 --- a/seatunnel-server/seatunnel-app/src/main/resources/i18n_zh.config +++ b/seatunnel-server/seatunnel-app/src/main/resources/i18n_zh.config @@ -293,3 +293,13 @@ PROXY { username = "用户名" password = "密码" } + +FakeSource { + fields = "领域" + fields_description = "该值将用于填充 UI 中的字段详细信息,但是在执行期间不会使用它。" +} + +Console { + url = "JDBC连接Url" + url_description = "这是满足设计约束所必需的,但是在执行过程中不会使用它。" +} diff --git a/seatunnel-ui/src/hooks/use-source-type.ts b/seatunnel-ui/src/hooks/use-source-type.ts index f5c6a098d..fe71124b3 100644 --- a/seatunnel-ui/src/hooks/use-source-type.ts +++ b/seatunnel-ui/src/hooks/use-source-type.ts @@ -34,7 +34,8 @@ export const useSourceType = (showVirtualDataSource = false) => { 2: 'file', 3: 'no_structured', 4: 'storage', - 5: 'remote_connection' + 5: 'remote_connection', + 6: 'fake_connection' } const state = reactive({ loading: false, diff --git a/seatunnel-ui/src/locales/en_US/datasource.ts b/seatunnel-ui/src/locales/en_US/datasource.ts index 27b2412c6..69c9863c0 100644 --- a/seatunnel-ui/src/locales/en_US/datasource.ts +++ b/seatunnel-ui/src/locales/en_US/datasource.ts @@ -86,5 +86,6 @@ export default { no_structured: 'NoSQLs', storage: 'Storage', data_analysis: 'Data Analysis', - remote_connection: 'Remote Connection' + remote_connection: 'Remote Connection', + fake_connection: 'Fake Connection' } diff --git a/seatunnel-ui/src/locales/en_US/project.ts b/seatunnel-ui/src/locales/en_US/project.ts index b28b497b8..18e6c552d 100644 --- a/seatunnel-ui/src/locales/en_US/project.ts +++ b/seatunnel-ui/src/locales/en_US/project.ts @@ -958,6 +958,7 @@ export default { git_file: 'Git File', break_continue: 'Break continue', remote_connection: 'Remote Connection', + fake_connection: 'Fake Connection', connection_type: 'Connection Type', source_name: 'Source Name', ssh: 'SSH', diff --git a/seatunnel-ui/src/locales/zh_CN/datasource.ts b/seatunnel-ui/src/locales/zh_CN/datasource.ts index 6222fd05b..ec3f0599c 100644 --- a/seatunnel-ui/src/locales/zh_CN/datasource.ts +++ b/seatunnel-ui/src/locales/zh_CN/datasource.ts @@ -82,5 +82,6 @@ export default { no_structured: '非结构化', storage: '存储', data_analysis: '数据分析', - remote_connection: '远程连接' + remote_connection: '远程连接', + fake_connection: '假连接' } diff --git a/seatunnel-ui/src/locales/zh_CN/project.ts b/seatunnel-ui/src/locales/zh_CN/project.ts index a490f38d9..83b98aa03 100644 --- a/seatunnel-ui/src/locales/zh_CN/project.ts +++ b/seatunnel-ui/src/locales/zh_CN/project.ts @@ -927,6 +927,7 @@ export default { whale_seatunnel_task_tips: '请选择任务', break_continue: '断点续传', remote_connection: '远程连接', + fake_connection: '假连接', connection_type: '连接类型', source_name: '源名称', ssh: 'SSH', diff --git a/seatunnel-ui/src/views/datasource/components/use-source.ts b/seatunnel-ui/src/views/datasource/components/use-source.ts index a775cde6c..f2a049f5c 100644 --- a/seatunnel-ui/src/views/datasource/components/use-source.ts +++ b/seatunnel-ui/src/views/datasource/components/use-source.ts @@ -36,7 +36,8 @@ export const useSource = (showVirtualDataSource = false) => { 2: 'file', 3: 'no_structured', 4: 'storage', - 5: 'remote_connection' + 5: 'remote_connection', + 6: 'fake_connection' } const state = reactive({ types: [] as IType[] diff --git a/seatunnel-ui/src/views/datasource/list/use-source.ts b/seatunnel-ui/src/views/datasource/list/use-source.ts index c0e79cc43..025412817 100644 --- a/seatunnel-ui/src/views/datasource/list/use-source.ts +++ b/seatunnel-ui/src/views/datasource/list/use-source.ts @@ -34,7 +34,8 @@ export const useSource = (showVirtualDataSource = false) => { 2: 'file', 3: 'no_structured', 4: 'storage', - 5: 'remote_connection' + 5: 'remote_connection', + 6: 'fake_connection' } const state = reactive({ loading: false, diff --git a/seatunnel-web-dist/pom.xml b/seatunnel-web-dist/pom.xml index 0623bd2f6..372c24ce2 100644 --- a/seatunnel-web-dist/pom.xml +++ b/seatunnel-web-dist/pom.xml @@ -375,6 +375,18 @@ + + org.apache.seatunnel + datasource-fakesource + ${project.version} + provided + + + org.apache.seatunnel + datasource-console + ${project.version} + provided +