diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/PipelineJobPreparerUtils.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/PipelineJobPreparerUtils.java index ebb18af17eb42..8be1d3e1e3d2c 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/PipelineJobPreparerUtils.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/PipelineJobPreparerUtils.java @@ -76,12 +76,9 @@ public static boolean isIncrementalSupported(final DatabaseType databaseType) { * @throws SQLException if prepare target schema fail */ public static void prepareTargetSchema(final DatabaseType databaseType, final PrepareTargetSchemasParameter prepareTargetSchemasParam) throws SQLException { - Optional option = DatabaseTypedSPILoader.findService(DataSourcePrepareOption.class, databaseType); - if (!option.isPresent()) { - log.info("Data source preparer option null, ignore prepare target"); - return; - } - new DataSourcePreparer(option.get()).prepareTargetSchemas(prepareTargetSchemasParam); + DataSourcePrepareOption option = DatabaseTypedSPILoader.findService(DataSourcePrepareOption.class, databaseType) + .orElseGet(() -> DatabaseTypedSPILoader.getService(DataSourcePrepareOption.class, null)); + new DataSourcePreparer(option).prepareTargetSchemas(prepareTargetSchemasParam); } /** @@ -105,13 +102,10 @@ public static SQLParserEngine getSQLParserEngine(final ShardingSphereMetaData me * @throws SQLException SQL exception */ public static void prepareTargetTables(final DatabaseType databaseType, final PrepareTargetTablesParameter prepareTargetTablesParam) throws SQLException { - Optional option = DatabaseTypedSPILoader.findService(DataSourcePrepareOption.class, databaseType); - if (!option.isPresent()) { - log.info("Data source preparer option null, ignore prepare target"); - return; - } + DataSourcePrepareOption option = DatabaseTypedSPILoader.findService(DataSourcePrepareOption.class, databaseType) + .orElseGet(() -> DatabaseTypedSPILoader.getService(DataSourcePrepareOption.class, null)); long startTimeMillis = System.currentTimeMillis(); - new DataSourcePreparer(option.get()).prepareTargetTables(prepareTargetTablesParam); + new DataSourcePreparer(option).prepareTargetTables(prepareTargetTablesParam); log.info("prepareTargetTables cost {} ms", System.currentTimeMillis() - startTimeMillis); } diff --git a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/prepare/datasource/MySQLDataSourcePrepareOption.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/datasource/DefaultDataSourcePrepareOption.java similarity index 70% rename from kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/prepare/datasource/MySQLDataSourcePrepareOption.java rename to kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/datasource/DefaultDataSourcePrepareOption.java index ed9a05a053c26..fd22b23e244a5 100644 --- a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/prepare/datasource/MySQLDataSourcePrepareOption.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/datasource/DefaultDataSourcePrepareOption.java @@ -15,17 +15,15 @@ * limitations under the License. */ -package org.apache.shardingsphere.data.pipeline.mysql.prepare.datasource; - -import org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption; +package org.apache.shardingsphere.data.pipeline.core.preparer.datasource; /** - * Data source prepare option for MySQL. + * Default data source prepare option. */ -public final class MySQLDataSourcePrepareOption implements DataSourcePrepareOption { +public final class DefaultDataSourcePrepareOption implements DataSourcePrepareOption { @Override - public String getDatabaseType() { - return "MySQL"; + public boolean isDefault() { + return true; } } diff --git a/test/it/pipeline/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption b/kernel/data-pipeline/core/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption similarity index 89% rename from test/it/pipeline/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption rename to kernel/data-pipeline/core/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption index fb6848a83c3c9..6acc331887724 100644 --- a/test/it/pipeline/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption +++ b/kernel/data-pipeline/core/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption @@ -15,4 +15,4 @@ # limitations under the License. # -org.apache.shardingsphere.test.it.data.pipeline.core.fixture.H2DataSourcePrepareOption +org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DefaultDataSourcePrepareOption diff --git a/kernel/data-pipeline/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption b/kernel/data-pipeline/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption deleted file mode 100644 index 980f6a50028a5..0000000000000 --- a/kernel/data-pipeline/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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. -# - -org.apache.shardingsphere.data.pipeline.mysql.prepare.datasource.MySQLDataSourcePrepareOption diff --git a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/prepare/datasource/PostgreSQLDataSourcePrepareOption.java b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/prepare/datasource/PostgreSQLDataSourcePrepareOption.java deleted file mode 100644 index 7deed37601319..0000000000000 --- a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/prepare/datasource/PostgreSQLDataSourcePrepareOption.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.shardingsphere.data.pipeline.postgresql.prepare.datasource; - -import org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption; - -/** - * Data source prepare option for PostgreSQL. - */ -public final class PostgreSQLDataSourcePrepareOption implements DataSourcePrepareOption { - - @Override - public String getDatabaseType() { - return "PostgreSQL"; - } -} diff --git a/kernel/data-pipeline/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption b/kernel/data-pipeline/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption deleted file mode 100644 index d6f7f72a35ec4..0000000000000 --- a/kernel/data-pipeline/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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. -# - -org.apache.shardingsphere.data.pipeline.postgresql.prepare.datasource.PostgreSQLDataSourcePrepareOption diff --git a/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/fixture/H2DataSourcePrepareOption.java b/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/fixture/H2DataSourcePrepareOption.java deleted file mode 100644 index 7b1fc0f64bb2f..0000000000000 --- a/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/fixture/H2DataSourcePrepareOption.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.shardingsphere.test.it.data.pipeline.core.fixture; - -import org.apache.shardingsphere.data.pipeline.core.preparer.datasource.DataSourcePrepareOption; - -/** - * Data source prepare option for H2. - */ -public final class H2DataSourcePrepareOption implements DataSourcePrepareOption { - - @Override - public String getDatabaseType() { - return "H2"; - } -}