From 7427de464eca0178711ec8f3278797b4bf4a06d1 Mon Sep 17 00:00:00 2001 From: linghengqian Date: Sun, 12 Nov 2023 13:12:15 +0800 Subject: [PATCH] Fixes nativeTest unit that failed to execute --- ...riteSplittingRuleConfigurationChecker.java | 12 +- .../rule/ReadwriteSplittingRule.java | 20 +- .../nativetest/jdbc/features/EncryptTest.java | 17 +- .../nativetest/jdbc/features/MaskTest.java | 17 +- .../jdbc/features/ReadWriteSplittingTest.java | 44 +- .../nativetest/jdbc/features/ShadowTest.java | 17 +- .../jdbc/features/ShardingTest.java | 17 +- ...ssBasedInlineShardingAlgorithmFixture.java | 44 ++ ...QueryAssistedShardingEncryptAlgorithm.java | 3 +- .../resource-config.json | 9 + ...hardingsphere.encrypt.spi.EncryptAlgorithm | 2 +- .../nativetest/src/test/resources/logback.xml | 34 -- .../src/test/resources/yaml/sharding.yaml | 8 +- .../jni-config.json | 2 +- .../proxy-config.json | 2 +- .../reflect-config.json | 431 +++++------------- .../resource-config.json | 14 +- .../serialization-config.json | 2 +- .../jdbc/sql/JDBCRepositorySQLLoader.java | 25 +- 19 files changed, 299 insertions(+), 421 deletions(-) create mode 100644 infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/algorithm/ClassBasedInlineShardingAlgorithmFixture.java rename infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/{ => algorithm}/TestQueryAssistedShardingEncryptAlgorithm.java (96%) create mode 100644 infra/nativetest/src/test/resources/META-INF/native-image/shardingsphere-infra-nativetest-test-image/resource-config.json delete mode 100644 infra/nativetest/src/test/resources/logback.xml diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationChecker.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationChecker.java index 984a472bb0932c..7d76a371955c86 100644 --- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationChecker.java +++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationChecker.java @@ -49,6 +49,8 @@ */ public final class ReadwriteSplittingRuleConfigurationChecker implements RuleConfigurationChecker { + private final String inlineExpressionTypePrefix = ""; + @Override public void check(final String databaseName, final ReadwriteSplittingRuleConfiguration config, final Map dataSourceMap, final Collection builtRules) { Collection configs = config.getDataSources(); @@ -79,7 +81,10 @@ private void checkDataSources(final String databaseName, final Map dataSourceMap, final Collection addedWriteDataSourceNames, final ReadwriteSplittingDataSourceRuleConfiguration config, final Collection rules) { - for (String each : InlineExpressionParserFactory.newInstance(config.getWriteDataSourceName()).splitAndEvaluate()) { + String resultInlineExpression = null == System.getProperty("org.graalvm.nativeimage.imagecode") || !"runtime".equals(System.getProperty("org.graalvm.nativeimage.imagecode")) + ? config.getWriteDataSourceName() + : inlineExpressionTypePrefix + config.getWriteDataSourceName(); + for (String each : InlineExpressionParserFactory.newInstance(resultInlineExpression).splitAndEvaluate()) { ShardingSpherePreconditions.checkState(dataSourceMap.containsKey(each) || containsInOtherRules(each, rules), () -> new DataSourceNameExistedException(String.format("Write data source name `%s` not in database `%s`.", each, databaseName))); ShardingSpherePreconditions.checkState(addedWriteDataSourceNames.add(each), @@ -97,7 +102,10 @@ private boolean containsInOtherRules(final String datasourceName, final Collecti } private void checkReadeDataSourceNames(final String databaseName, final Map dataSourceMap, final Collection addedReadDataSourceNames, final String readDataSourceName) { - for (String each : InlineExpressionParserFactory.newInstance(readDataSourceName).splitAndEvaluate()) { + String resultInlineExpression = null == System.getProperty("org.graalvm.nativeimage.imagecode") || !"runtime".equals(System.getProperty("org.graalvm.nativeimage.imagecode")) + ? readDataSourceName + : inlineExpressionTypePrefix + readDataSourceName; + for (String each : InlineExpressionParserFactory.newInstance(resultInlineExpression).splitAndEvaluate()) { ShardingSpherePreconditions.checkState(dataSourceMap.containsKey(each), () -> new DataSourceNameExistedException(String.format("Read data source name `%s` not in database `%s`.", each, databaseName))); ShardingSpherePreconditions.checkState(addedReadDataSourceNames.add(each), diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java index 68ec5cb4267565..d477aae2e7684d 100644 --- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java +++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java @@ -57,6 +57,8 @@ */ public final class ReadwriteSplittingRule implements DatabaseRule, DataSourceContainedRule, StaticDataSourceContainedRule, ExportableRule, StorageConnectorReusableRule { + private final String inlineExpressionTypePrefix = ""; + private final String databaseName; @Getter @@ -103,10 +105,22 @@ private Map createDataSourceRules(fina private Map createStaticDataSourceRules(final ReadwriteSplittingDataSourceRuleConfiguration config, final ReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm) { - List inlineReadwriteDataSourceNames = InlineExpressionParserFactory.newInstance(config.getName()).splitAndEvaluate(); - List inlineWriteDatasourceNames = InlineExpressionParserFactory.newInstance(config.getWriteDataSourceName()).splitAndEvaluate(); + String resultConfigNameInlineExpression = null == System.getProperty("org.graalvm.nativeimage.imagecode") || !"runtime".equals(System.getProperty("org.graalvm.nativeimage.imagecode")) + ? config.getName() + : inlineExpressionTypePrefix + config.getName(); + List inlineReadwriteDataSourceNames = InlineExpressionParserFactory.newInstance(resultConfigNameInlineExpression).splitAndEvaluate(); + String resultConfigWriteDataSourceNameInlineExpression = + null == System.getProperty("org.graalvm.nativeimage.imagecode") || !"runtime".equals(System.getProperty("org.graalvm.nativeimage.imagecode")) + ? config.getWriteDataSourceName() + : inlineExpressionTypePrefix + config.getWriteDataSourceName(); + List inlineWriteDatasourceNames = InlineExpressionParserFactory.newInstance(resultConfigWriteDataSourceNameInlineExpression).splitAndEvaluate(); List> inlineReadDatasourceNames = config.getReadDataSourceNames().stream() - .map(each -> InlineExpressionParserFactory.newInstance(each).splitAndEvaluate()).collect(Collectors.toList()); + .map(each -> { + String resultInlineExpression = null == System.getProperty("org.graalvm.nativeimage.imagecode") || !"runtime".equals(System.getProperty("org.graalvm.nativeimage.imagecode")) + ? each + : inlineExpressionTypePrefix + each; + return InlineExpressionParserFactory.newInstance(resultInlineExpression).splitAndEvaluate(); + }).collect(Collectors.toList()); ShardingSpherePreconditions.checkState(inlineWriteDatasourceNames.size() == inlineReadwriteDataSourceNames.size(), () -> new InvalidInlineExpressionDataSourceNameException("Inline expression write data source names size error.")); inlineReadDatasourceNames.forEach(each -> ShardingSpherePreconditions.checkState(each.size() == inlineReadwriteDataSourceNames.size(), diff --git a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/EncryptTest.java b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/EncryptTest.java index 4fd0146d782453..a6e4363b6576db 100644 --- a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/EncryptTest.java +++ b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/EncryptTest.java @@ -50,13 +50,16 @@ public final class EncryptTest { @Test void testEncryptInLocalTransactions() throws SQLException, IOException { - DataSource dataSource = YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("yaml/encrypt.yaml")); - orderRepository = new OrderRepository(dataSource); - orderItemRepository = new OrderItemRepository(dataSource); - addressRepository = new AddressRepository(dataSource); - this.initEnvironment(); - this.processSuccess(); - this.cleanEnvironment(); + try { + DataSource dataSource = YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("yaml/encrypt.yaml")); + orderRepository = new OrderRepository(dataSource); + orderItemRepository = new OrderItemRepository(dataSource); + addressRepository = new AddressRepository(dataSource); + this.initEnvironment(); + this.processSuccess(); + } finally { + this.cleanEnvironment(); + } } private void initEnvironment() throws SQLException { diff --git a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/MaskTest.java b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/MaskTest.java index 18b11bf6af87d4..c202daa35ae3ba 100644 --- a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/MaskTest.java +++ b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/MaskTest.java @@ -49,13 +49,16 @@ public final class MaskTest { @Test void testMaskInLocalTransactions() throws SQLException, IOException { - DataSource dataSource = YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("yaml/mask.yaml")); - orderRepository = new OrderRepository(dataSource); - orderItemRepository = new OrderItemRepository(dataSource); - addressRepository = new AddressRepository(dataSource); - this.initEnvironment(); - this.processSuccess(); - this.cleanEnvironment(); + try { + DataSource dataSource = YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("yaml/mask.yaml")); + orderRepository = new OrderRepository(dataSource); + orderItemRepository = new OrderItemRepository(dataSource); + addressRepository = new AddressRepository(dataSource); + this.initEnvironment(); + this.processSuccess(); + } finally { + this.cleanEnvironment(); + } } private void initEnvironment() throws SQLException { diff --git a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ReadWriteSplittingTest.java b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ReadWriteSplittingTest.java index 566adbc091572a..dbef2e2eaf8037 100644 --- a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ReadWriteSplittingTest.java +++ b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ReadWriteSplittingTest.java @@ -27,8 +27,6 @@ import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.OrderRepository; import org.h2.jdbc.JdbcSQLSyntaxErrorException; import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.sql.DataSource; import java.io.IOException; @@ -40,8 +38,6 @@ public final class ReadWriteSplittingTest { - private static final Logger LOGGER = LoggerFactory.getLogger(ReadWriteSplittingTest.class); - private OrderRepository orderRepository; private OrderItemRepository orderItemRepository; @@ -50,13 +46,16 @@ public final class ReadWriteSplittingTest { @Test void testReadWriteSplittingInLocalTransactions() throws SQLException, IOException { - DataSource dataSource = YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("yaml/readwrite-splitting.yaml")); - orderRepository = new OrderRepository(dataSource); - orderItemRepository = new OrderItemRepository(dataSource); - addressRepository = new AddressRepository(dataSource); - this.initEnvironment(); - this.processSuccess(); - this.cleanEnvironment(); + try { + DataSource dataSource = YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("yaml/readwrite-splitting.yaml")); + orderRepository = new OrderRepository(dataSource); + orderItemRepository = new OrderItemRepository(dataSource); + addressRepository = new AddressRepository(dataSource); + this.initEnvironment(); + this.processSuccess(); + } finally { + this.cleanEnvironment(); + } } private void initEnvironment() throws SQLException { @@ -69,18 +68,15 @@ private void initEnvironment() throws SQLException { } private void processSuccess() throws SQLException { - LOGGER.info("-------------- Process Success Begin ---------------"); List orderIds = insertData(); // This is intentional because the read operation is in the slave database and the corresponding table does not exist. assertThrows(JdbcSQLSyntaxErrorException.class, this::printData); deleteData(orderIds); // This is intentional because the read operation is in the slave database and the corresponding table does not exist. assertThrows(JdbcSQLSyntaxErrorException.class, this::printData); - LOGGER.info("-------------- Process Success Finish --------------"); } private List insertData() throws SQLException { - LOGGER.info("---------------------------- Insert Data ----------------------------"); List result = new ArrayList<>(10); for (int i = 1; i <= 10; i++) { Order order = new Order(); @@ -97,9 +93,7 @@ private List insertData() throws SQLException { orderItem.setStatus("INSERT_TEST"); orderItemRepository.insert(orderItem); - Address address = new Address(); - address.setAddressId((long) i); - address.setAddressName("address_test_" + i); + Address address = new Address((long) i, "address_test_" + i); addressRepository.insert(address); result.add(order.getOrderId()); @@ -108,7 +102,6 @@ private List insertData() throws SQLException { } private void deleteData(final List orderIds) throws SQLException { - LOGGER.info("---------------------------- Delete Data ----------------------------"); long count = 1; for (Long each : orderIds) { orderRepository.delete(each); @@ -118,18 +111,9 @@ private void deleteData(final List orderIds) throws SQLException { } private void printData() throws SQLException { - LOGGER.info("---------------------------- Print Order Data -----------------------"); - for (Object each : orderRepository.selectAll()) { - LOGGER.info(each.toString()); - } - LOGGER.info("---------------------------- Print OrderItem Data -------------------"); - for (Object each : orderItemRepository.selectAll()) { - LOGGER.info(each.toString()); - } - LOGGER.info("---------------------------- Print Address Data -------------------"); - for (Object each : addressRepository.selectAll()) { - LOGGER.info(each.toString()); - } + orderRepository.selectAll(); + orderItemRepository.selectAll(); + addressRepository.selectAll(); } private void cleanEnvironment() throws SQLException { diff --git a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ShadowTest.java b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ShadowTest.java index 34eef534fee1df..1ee413199a306e 100644 --- a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ShadowTest.java +++ b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ShadowTest.java @@ -50,13 +50,16 @@ public final class ShadowTest { @Test void testShadowInLocalTransactions() throws SQLException, IOException { - DataSource dataSource = YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("yaml/shadow.yaml")); - orderRepository = new OrderRepository(dataSource); - orderItemRepository = new OrderItemRepository(dataSource); - addressRepository = new AddressRepository(dataSource); - this.initEnvironment(); - this.processSuccess(); - this.cleanEnvironment(); + try { + DataSource dataSource = YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("yaml/shadow.yaml")); + orderRepository = new OrderRepository(dataSource); + orderItemRepository = new OrderItemRepository(dataSource); + addressRepository = new AddressRepository(dataSource); + this.initEnvironment(); + this.processSuccess(); + } finally { + this.cleanEnvironment(); + } } private void initEnvironment() throws SQLException { diff --git a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ShardingTest.java b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ShardingTest.java index 8e07d05a4b58f4..521610c7428a3b 100644 --- a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ShardingTest.java +++ b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ShardingTest.java @@ -50,13 +50,16 @@ public final class ShardingTest { @Test void testShardingInLocalTransactions() throws SQLException, IOException { - DataSource dataSource = YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("yaml/sharding.yaml")); - orderRepository = new OrderRepository(dataSource); - orderItemRepository = new OrderItemRepository(dataSource); - addressRepository = new AddressRepository(dataSource); - this.initEnvironment(); - this.processSuccess(); - this.cleanEnvironment(); + try { + DataSource dataSource = YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("yaml/sharding.yaml")); + orderRepository = new OrderRepository(dataSource); + orderItemRepository = new OrderItemRepository(dataSource); + addressRepository = new AddressRepository(dataSource); + this.initEnvironment(); + this.processSuccess(); + } finally { + this.cleanEnvironment(); + } } private void initEnvironment() throws SQLException { diff --git a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/algorithm/ClassBasedInlineShardingAlgorithmFixture.java b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/algorithm/ClassBasedInlineShardingAlgorithmFixture.java new file mode 100644 index 00000000000000..55652a13e6d499 --- /dev/null +++ b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/algorithm/ClassBasedInlineShardingAlgorithmFixture.java @@ -0,0 +1,44 @@ +/* + * 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.infra.nativetest.jdbc.features.algorithm; + +import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue; +import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue; +import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm; + +import java.util.Collection; + +@SuppressWarnings("unused") +public final class ClassBasedInlineShardingAlgorithmFixture implements StandardShardingAlgorithm { + + @Override + public String doSharding(final Collection availableTargetNames, final PreciseShardingValue shardingValue) { + String resultDatabaseName = "ds_" + shardingValue.getValue() % 2; + for (String each : availableTargetNames) { + if (each.equals(resultDatabaseName)) { + return each; + } + } + return null; + } + + @Override + public Collection doSharding(final Collection availableTargetNames, final RangeShardingValue shardingValue) { + throw new RuntimeException("This algorithm class does not support range queries."); + } +} diff --git a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/TestQueryAssistedShardingEncryptAlgorithm.java b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/algorithm/TestQueryAssistedShardingEncryptAlgorithm.java similarity index 96% rename from infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/TestQueryAssistedShardingEncryptAlgorithm.java rename to infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/algorithm/TestQueryAssistedShardingEncryptAlgorithm.java index c985b8fd19ada3..d47fb24bf567a7 100644 --- a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/TestQueryAssistedShardingEncryptAlgorithm.java +++ b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/algorithm/TestQueryAssistedShardingEncryptAlgorithm.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.infra.nativetest.jdbc.features; +package org.apache.shardingsphere.infra.nativetest.jdbc.features.algorithm; import lombok.Getter; import org.apache.shardingsphere.encrypt.api.context.EncryptContext; @@ -23,6 +23,7 @@ import java.util.Properties; +@SuppressWarnings("LombokGetterMayBeUsed") public final class TestQueryAssistedShardingEncryptAlgorithm implements AssistedEncryptAlgorithm { @Getter diff --git a/infra/nativetest/src/test/resources/META-INF/native-image/shardingsphere-infra-nativetest-test-image/resource-config.json b/infra/nativetest/src/test/resources/META-INF/native-image/shardingsphere-infra-nativetest-test-image/resource-config.json new file mode 100644 index 00000000000000..855aee2e26a1f9 --- /dev/null +++ b/infra/nativetest/src/test/resources/META-INF/native-image/shardingsphere-infra-nativetest-test-image/resource-config.json @@ -0,0 +1,9 @@ +{ + "resources":{ + "includes":[{ + "pattern":"\\Qsql/H2.xml\\E" + }, { + "pattern":"\\Qsql/MySQL.xml\\E" + }]}, + "bundles":[] +} \ No newline at end of file diff --git a/infra/nativetest/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm b/infra/nativetest/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm index 37c6277959e6d4..be8532cc700cbc 100644 --- a/infra/nativetest/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm +++ b/infra/nativetest/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm @@ -15,4 +15,4 @@ # limitations under the License. # -org.apache.shardingsphere.infra.nativetest.jdbc.features.TestQueryAssistedShardingEncryptAlgorithm +org.apache.shardingsphere.infra.nativetest.jdbc.features.algorithm.TestQueryAssistedShardingEncryptAlgorithm diff --git a/infra/nativetest/src/test/resources/logback.xml b/infra/nativetest/src/test/resources/logback.xml deleted file mode 100644 index a4847ef2c0bda2..00000000000000 --- a/infra/nativetest/src/test/resources/logback.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - ${log.context.name} - - - - ${log.pattern} - - - - - - - diff --git a/infra/nativetest/src/test/resources/yaml/sharding.yaml b/infra/nativetest/src/test/resources/yaml/sharding.yaml index be76577f1aab4d..1ca597dd219935 100644 --- a/infra/nativetest/src/test/resources/yaml/sharding.yaml +++ b/infra/nativetest/src/test/resources/yaml/sharding.yaml @@ -58,10 +58,14 @@ rules: shardingColumn: user_id shardingAlgorithmName: inline shardingAlgorithms: + # GroovyShell related classes are not available on GraalVM CE 23.0.2 For JDK 17.0.9, + # This CLASS_BASE algorithm class is designed to emulate INLINE's `ds_${user_id % 2}`. + # See https://github.com/oracle/graal/issues/5522 . inline: - type: INLINE + type: CLASS_BASED props: - algorithm-expression: ds_${user_id % 2} + strategy: STANDARD + algorithmClassName: org.apache.shardingsphere.infra.nativetest.jdbc.features.algorithm.ClassBasedInlineShardingAlgorithmFixture keyGenerators: snowflake: type: SNOWFLAKE diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/jni-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/jni-config.json index c8b081385033ae..0ee2739762f2dc 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/jni-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/jni-config.json @@ -7,4 +7,4 @@ "name":"sun.management.VMManagementImpl", "fields":[{"name":"compTimeMonitoringSupport"}, {"name":"currentThreadCpuTimeSupport"}, {"name":"objectMonitorUsageSupport"}, {"name":"otherThreadCpuTimeSupport"}, {"name":"remoteDiagnosticCommandsSupport"}, {"name":"synchronizerUsageSupport"}, {"name":"threadAllocatedMemorySupport"}, {"name":"threadContentionMonitoringSupport"}] } -] +] \ No newline at end of file diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/proxy-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/proxy-config.json index 641a8f15102354..fbfaf87cb7a19f 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/proxy-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/proxy-config.json @@ -2,4 +2,4 @@ { "interfaces":["java.sql.Connection"] } -] +] \ No newline at end of file diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reflect-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reflect-config.json index 5a2d98a818c4df..84d0959f4844df 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reflect-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reflect-config.json @@ -8,34 +8,61 @@ "methods":[{"name":"","parameterTypes":["groovy.lang.Binding"] }] }, { - "name":"Script1$_run_closure1", + "name":"Script1BeanInfo" +}, +{ + "name":"Script1Customizer" +}, +{ + "name":"Script2", + "allDeclaredFields":true, "queryAllDeclaredMethods":true, + "queryAllPublicMethods":true, "queryAllDeclaredConstructors":true, - "methods":[{"name":"doCall","parameterTypes":["java.lang.Object"] }] + "methods":[{"name":"","parameterTypes":["groovy.lang.Binding"] }] }, { - "name":"Script1BeanInfo" + "name":"Script2BeanInfo" }, { - "name":"Script1Customizer" + "name":"Script2Customizer" }, { - "name":"[B" + "name":"Script3", + "allDeclaredFields":true, + "queryAllDeclaredMethods":true, + "queryAllPublicMethods":true, + "queryAllDeclaredConstructors":true, + "methods":[{"name":"","parameterTypes":["groovy.lang.Binding"] }] }, { - "name":"[C" + "name":"Script3BeanInfo" }, { - "name":"[I" + "name":"Script3Customizer" }, { - "name":"[Lcom.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry;" + "name":"Script4", + "allDeclaredFields":true, + "queryAllDeclaredMethods":true, + "queryAllPublicMethods":true, + "queryAllDeclaredConstructors":true, + "methods":[{"name":"","parameterTypes":["groovy.lang.Binding"] }] }, { - "name":"[Ljava.io.ObjectStreamField;" + "name":"Script4BeanInfo" }, { - "name":"[Ljava.lang.CharSequence;" + "name":"Script4Customizer" +}, +{ + "name":"[B" +}, +{ + "name":"[Lcom.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry;" +}, +{ + "name":"[Ljava.io.ObjectStreamField;" }, { "name":"[Ljava.lang.Class;" @@ -79,68 +106,6 @@ { "name":"[Lsun.security.pkcs.SignerInfo;" }, -{ - "name":"ch.qos.logback.classic.encoder.PatternLayoutEncoder", - "queryAllPublicMethods":true, - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.joran.SerializedModelConfigurator", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.pattern.DateConverter", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.pattern.LevelConverter", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.pattern.LineSeparatorConverter", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.pattern.LoggerConverter", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.pattern.MessageConverter", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.pattern.ThreadConverter", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.util.DefaultJoranConfigurator", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.core.ConsoleAppender", - "queryAllPublicMethods":true, - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.core.OutputStreamAppender", - "methods":[{"name":"setEncoder","parameterTypes":["ch.qos.logback.core.encoder.Encoder"] }] -}, -{ - "name":"ch.qos.logback.core.encoder.Encoder", - "methods":[{"name":"valueOf","parameterTypes":["java.lang.String"] }] -}, -{ - "name":"ch.qos.logback.core.encoder.LayoutWrappingEncoder", - "methods":[{"name":"setParent","parameterTypes":["ch.qos.logback.core.spi.ContextAware"] }] -}, -{ - "name":"ch.qos.logback.core.pattern.PatternLayoutEncoderBase", - "methods":[{"name":"setPattern","parameterTypes":["java.lang.String"] }] -}, -{ - "name":"ch.qos.logback.core.spi.ContextAware", - "methods":[{"name":"valueOf","parameterTypes":["java.lang.String"] }] -}, { "name":"com.github.benmanes.caffeine.cache.BBHeader$ReadAndWriteCounterRef", "fields":[{"name":"writeCounter"}] @@ -243,14 +208,15 @@ }, { "name":"com.zaxxer.hikari.HikariConfig", + "queryAllPublicMethods":true, "fields":[{"name":"dataSourceProperties"}, {"name":"jdbcUrl"}], - "methods":[{"name":"getCatalog","parameterTypes":[] }, {"name":"getConnectionInitSql","parameterTypes":[] }, {"name":"getConnectionTestQuery","parameterTypes":[] }, {"name":"getConnectionTimeout","parameterTypes":[] }, {"name":"getDataSourceClassName","parameterTypes":[] }, {"name":"getDataSourceJNDI","parameterTypes":[] }, {"name":"getDataSourceProperties","parameterTypes":[] }, {"name":"getExceptionOverrideClassName","parameterTypes":[] }, {"name":"getHealthCheckProperties","parameterTypes":[] }, {"name":"getIdleTimeout","parameterTypes":[] }, {"name":"getInitializationFailTimeout","parameterTypes":[] }, {"name":"getJdbcUrl","parameterTypes":[] }, {"name":"getKeepaliveTime","parameterTypes":[] }, {"name":"getLeakDetectionThreshold","parameterTypes":[] }, {"name":"getMaxLifetime","parameterTypes":[] }, {"name":"getMaximumPoolSize","parameterTypes":[] }, {"name":"getMinimumIdle","parameterTypes":[] }, {"name":"getPassword","parameterTypes":[] }, {"name":"getPoolName","parameterTypes":[] }, {"name":"getSchema","parameterTypes":[] }, {"name":"getTransactionIsolation","parameterTypes":[] }, {"name":"getUsername","parameterTypes":[] }, {"name":"getValidationTimeout","parameterTypes":[] }, {"name":"isAllowPoolSuspension","parameterTypes":[] }, {"name":"isAutoCommit","parameterTypes":[] }, {"name":"isIsolateInternalQueries","parameterTypes":[] }, {"name":"isReadOnly","parameterTypes":[] }, {"name":"isRegisterMbeans","parameterTypes":[] }, {"name":"setConnectionTimeout","parameterTypes":["long"] }, {"name":"setDataSourceProperties","parameterTypes":["java.util.Properties"] }, {"name":"setIdleTimeout","parameterTypes":["long"] }, {"name":"setJdbcUrl","parameterTypes":["java.lang.String"] }, {"name":"setKeepaliveTime","parameterTypes":["long"] }, {"name":"setMaxLifetime","parameterTypes":["long"] }, {"name":"setMaximumPoolSize","parameterTypes":["int"] }, {"name":"setMinimumIdle","parameterTypes":["int"] }, {"name":"setPassword","parameterTypes":["java.lang.String"] }, {"name":"setReadOnly","parameterTypes":["boolean"] }, {"name":"setUsername","parameterTypes":["java.lang.String"] }] + "methods":[{"name":"getCatalog","parameterTypes":[] }, {"name":"getConnectionInitSql","parameterTypes":[] }, {"name":"getConnectionTestQuery","parameterTypes":[] }, {"name":"getConnectionTimeout","parameterTypes":[] }, {"name":"getDataSource","parameterTypes":[] }, {"name":"getDataSourceClassName","parameterTypes":[] }, {"name":"getDataSourceJNDI","parameterTypes":[] }, {"name":"getDataSourceProperties","parameterTypes":[] }, {"name":"getDriverClassName","parameterTypes":[] }, {"name":"getExceptionOverrideClassName","parameterTypes":[] }, {"name":"getHealthCheckProperties","parameterTypes":[] }, {"name":"getHealthCheckRegistry","parameterTypes":[] }, {"name":"getIdleTimeout","parameterTypes":[] }, {"name":"getInitializationFailTimeout","parameterTypes":[] }, {"name":"getJdbcUrl","parameterTypes":[] }, {"name":"getKeepaliveTime","parameterTypes":[] }, {"name":"getLeakDetectionThreshold","parameterTypes":[] }, {"name":"getMaxLifetime","parameterTypes":[] }, {"name":"getMaximumPoolSize","parameterTypes":[] }, {"name":"getMetricRegistry","parameterTypes":[] }, {"name":"getMetricsTrackerFactory","parameterTypes":[] }, {"name":"getMinimumIdle","parameterTypes":[] }, {"name":"getPassword","parameterTypes":[] }, {"name":"getPoolName","parameterTypes":[] }, {"name":"getScheduledExecutor","parameterTypes":[] }, {"name":"getSchema","parameterTypes":[] }, {"name":"getThreadFactory","parameterTypes":[] }, {"name":"getTransactionIsolation","parameterTypes":[] }, {"name":"getUsername","parameterTypes":[] }, {"name":"getValidationTimeout","parameterTypes":[] }, {"name":"isAllowPoolSuspension","parameterTypes":[] }, {"name":"isAutoCommit","parameterTypes":[] }, {"name":"isIsolateInternalQueries","parameterTypes":[] }, {"name":"isReadOnly","parameterTypes":[] }, {"name":"isRegisterMbeans","parameterTypes":[] }, {"name":"setAllowPoolSuspension","parameterTypes":["boolean"] }, {"name":"setAutoCommit","parameterTypes":["boolean"] }, {"name":"setCatalog","parameterTypes":["java.lang.String"] }, {"name":"setClass","parameterTypes":["java.lang.Class"] }, {"name":"setConnectionInitSql","parameterTypes":["java.lang.String"] }, {"name":"setConnectionTestQuery","parameterTypes":["java.lang.String"] }, {"name":"setConnectionTimeout","parameterTypes":["long"] }, {"name":"setDataSource","parameterTypes":["javax.sql.DataSource"] }, {"name":"setDataSourceClassName","parameterTypes":["java.lang.String"] }, {"name":"setDataSourceJNDI","parameterTypes":["java.lang.String"] }, {"name":"setDataSourceProperties","parameterTypes":["java.util.Properties"] }, {"name":"setDriverClassName","parameterTypes":["java.lang.String"] }, {"name":"setExceptionOverrideClassName","parameterTypes":["java.lang.String"] }, {"name":"setHealthCheckProperties","parameterTypes":["java.util.Properties"] }, {"name":"setHealthCheckRegistry","parameterTypes":["java.lang.Object"] }, {"name":"setIdleTimeout","parameterTypes":["long"] }, {"name":"setInitializationFailTimeout","parameterTypes":["long"] }, {"name":"setIsolateInternalQueries","parameterTypes":["boolean"] }, {"name":"setJdbcUrl","parameterTypes":["java.lang.String"] }, {"name":"setKeepaliveTime","parameterTypes":["long"] }, {"name":"setLeakDetectionThreshold","parameterTypes":["long"] }, {"name":"setMaxLifetime","parameterTypes":["long"] }, {"name":"setMaximumPoolSize","parameterTypes":["int"] }, {"name":"setMetricRegistry","parameterTypes":["java.lang.Object"] }, {"name":"setMetricsTrackerFactory","parameterTypes":["com.zaxxer.hikari.metrics.MetricsTrackerFactory"] }, {"name":"setMinimumIdle","parameterTypes":["int"] }, {"name":"setPassword","parameterTypes":["java.lang.String"] }, {"name":"setPoolName","parameterTypes":["java.lang.String"] }, {"name":"setReadOnly","parameterTypes":["boolean"] }, {"name":"setRegisterMbeans","parameterTypes":["boolean"] }, {"name":"setScheduledExecutor","parameterTypes":["java.util.concurrent.ScheduledExecutorService"] }, {"name":"setSchema","parameterTypes":["java.lang.String"] }, {"name":"setThreadFactory","parameterTypes":["java.util.concurrent.ThreadFactory"] }, {"name":"setTransactionIsolation","parameterTypes":["java.lang.String"] }, {"name":"setUsername","parameterTypes":["java.lang.String"] }, {"name":"setValidationTimeout","parameterTypes":["long"] }] }, { "name":"com.zaxxer.hikari.HikariDataSource", "queryAllPublicMethods":true, "fields":[{"name":"dataSourceProperties"}, {"name":"jdbcUrl"}], - "methods":[{"name":"","parameterTypes":[] }, {"name":"isClosed","parameterTypes":[] }, {"name":"isRunning","parameterTypes":[] }] + "methods":[{"name":"","parameterTypes":[] }, {"name":"getAllowPoolSuspension","parameterTypes":[] }, {"name":"getAutoCommit","parameterTypes":[] }, {"name":"getIsolateInternalQueries","parameterTypes":[] }, {"name":"getReadOnly","parameterTypes":[] }, {"name":"getRegisterMbeans","parameterTypes":[] }, {"name":"isClosed","parameterTypes":[] }, {"name":"isRunning","parameterTypes":[] }] }, { "name":"com.zaxxer.hikari.pool.PoolEntry", @@ -281,37 +247,12 @@ }, { "name":"groovy.lang.Buildable", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"groovy.lang.Closure", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true, - "methods":[{"name":"getProperty","parameterTypes":["java.lang.String"] }] -}, -{ - "name":"groovy.lang.Closure$1", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true -}, -{ - "name":"groovy.lang.Closure$1BeanInfo" -}, -{ - "name":"groovy.lang.Closure$1Customizer" -}, -{ - "name":"groovy.lang.ClosureBeanInfo" -}, -{ - "name":"groovy.lang.ClosureCustomizer" + "queryAllDeclaredMethods":true }, { "name":"groovy.lang.EmptyRange" @@ -331,45 +272,19 @@ }, { "name":"groovy.lang.GString", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true, - "methods":[{"name":"build","parameterTypes":["groovy.lang.GroovyObject"] }, {"name":"charAt","parameterTypes":["int"] }, {"name":"compareTo","parameterTypes":["java.lang.Object"] }, {"name":"getStrings","parameterTypes":[] }, {"name":"length","parameterTypes":[] }, {"name":"subSequence","parameterTypes":["int","int"] }, {"name":"toString","parameterTypes":[] }, {"name":"writeTo","parameterTypes":["java.io.Writer"] }] -}, -{ - "name":"groovy.lang.GString$1", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true -}, -{ - "name":"groovy.lang.GString$1BeanInfo" -}, -{ - "name":"groovy.lang.GString$1Customizer" -}, -{ - "name":"groovy.lang.GStringBeanInfo" -}, -{ - "name":"groovy.lang.GStringCustomizer" + "methods":[{"name":"build","parameterTypes":["groovy.lang.GroovyObject"] }, {"name":"charAt","parameterTypes":["int"] }, {"name":"compareTo","parameterTypes":["java.lang.Object"] }, {"name":"length","parameterTypes":[] }, {"name":"subSequence","parameterTypes":["int","int"] }, {"name":"toString","parameterTypes":[] }, {"name":"writeTo","parameterTypes":["java.io.Writer"] }] }, { "name":"groovy.lang.GroovyCallable", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"groovy.lang.GroovyObject", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true, - "methods":[{"name":"getProperty","parameterTypes":["java.lang.String"] }, {"name":"invokeMethod","parameterTypes":["java.lang.String","java.lang.Object"] }] + "queryAllDeclaredConstructors":true }, { "name":"groovy.lang.GroovyObjectSupport", @@ -427,20 +342,17 @@ }, { "name":"groovy.lang.MetaMethod", - "queryAllDeclaredMethods":true, - "methods":[{"name":"doMethodInvoke","parameterTypes":["java.lang.Object","java.lang.Object[]"] }] + "queryAllDeclaredMethods":true }, { "name":"groovy.lang.MetaObjectProtocol", "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "methods":[{"name":"getProperty","parameterTypes":["java.lang.Object","java.lang.String"] }, {"name":"invokeConstructor","parameterTypes":["java.lang.Object[]"] }, {"name":"invokeMethod","parameterTypes":["java.lang.Object","java.lang.String","java.lang.Object[]"] }, {"name":"invokeStaticMethod","parameterTypes":["java.lang.Object","java.lang.String","java.lang.Object[]"] }] + "queryAllPublicMethods":true }, { "name":"groovy.lang.MetaProperty", - "queryAllDeclaredMethods":true, - "methods":[{"name":"getProperty","parameterTypes":["java.lang.Object"] }] + "queryAllDeclaredMethods":true }, { "name":"groovy.lang.MutableMetaClass", @@ -473,10 +385,8 @@ }, { "name":"groovy.lang.Writable", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"groovy.lang.groovydoc.Groovydoc" @@ -484,35 +394,26 @@ { "name":"groovy.runtime.metaclass.CustomMetaClassCreationHandle" }, -{ - "name":"groovy.runtime.metaclass.Script1$_run_closure1MetaClass" -}, { "name":"groovy.runtime.metaclass.Script1MetaClass" }, { - "name":"groovy.runtime.metaclass.groovy.lang.BindingMetaClass" -}, -{ - "name":"groovy.runtime.metaclass.groovy.lang.Closure$1MetaClass" + "name":"groovy.runtime.metaclass.Script2MetaClass" }, { - "name":"groovy.runtime.metaclass.groovy.lang.ExpandoMetaClassMetaClass" + "name":"groovy.runtime.metaclass.Script3MetaClass" }, { - "name":"groovy.runtime.metaclass.groovy.lang.GString$1MetaClass" + "name":"groovy.runtime.metaclass.Script4MetaClass" }, { - "name":"groovy.runtime.metaclass.groovy.lang.GroovyShellMetaClass" -}, -{ - "name":"groovy.runtime.metaclass.groovy.util.ExpandoMetaClass" + "name":"groovy.runtime.metaclass.groovy.lang.BindingMetaClass" }, { - "name":"groovy.runtime.metaclass.java.lang.IntegerMetaClass" + "name":"groovy.runtime.metaclass.groovy.lang.ExpandoMetaClassMetaClass" }, { - "name":"groovy.runtime.metaclass.org.codehaus.groovy.runtime.GStringImplMetaClass" + "name":"groovy.runtime.metaclass.groovy.lang.GroovyShellMetaClass" }, { "name":"groovy.transform.Internal", @@ -521,19 +422,6 @@ { "name":"groovy.util.BufferedIterator" }, -{ - "name":"groovy.util.Expando", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true -}, -{ - "name":"groovy.util.ExpandoBeanInfo" -}, -{ - "name":"groovy.util.ExpandoCustomizer" -}, { "name":"java.beans.PropertyVetoException" }, @@ -625,11 +513,9 @@ }, { "name":"java.io.Serializable", - "allDeclaredFields":true, "allDeclaredClasses":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.io.Writer", @@ -657,10 +543,8 @@ }, { "name":"java.lang.CharSequence", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.lang.Character" @@ -670,7 +554,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[{"name":"forName","parameterTypes":["java.lang.String","boolean","java.lang.ClassLoader"] }, {"name":"getModule","parameterTypes":[] }, {"name":"getPermittedSubclasses","parameterTypes":[] }, {"name":"isSealed","parameterTypes":[] }] + "methods":[{"name":"getPermittedSubclasses","parameterTypes":[] }, {"name":"isSealed","parameterTypes":[] }] }, { "name":"java.lang.ClassLoader", @@ -678,17 +562,13 @@ }, { "name":"java.lang.Cloneable", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.lang.Comparable", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true, "methods":[{"name":"compareTo","parameterTypes":["java.lang.Object"] }] }, { @@ -708,21 +588,7 @@ "name":"java.lang.Float" }, { - "name":"java.lang.FunctionalInterface", - "queryAllDeclaredMethods":true -}, -{ - "name":"java.lang.Integer", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true -}, -{ - "name":"java.lang.IntegerBeanInfo" -}, -{ - "name":"java.lang.IntegerCustomizer" + "name":"java.lang.Integer" }, { "name":"java.lang.Iterable", @@ -737,23 +603,10 @@ "name":"java.lang.Math", "methods":[{"name":"floorDiv","parameterTypes":["long","long"] }, {"name":"floorMod","parameterTypes":["long","long"] }, {"name":"max","parameterTypes":["int","int"] }, {"name":"min","parameterTypes":["int","int"] }] }, -{ - "name":"java.lang.Module", - "methods":[{"name":"getDescriptor","parameterTypes":[] }] -}, { "name":"java.lang.Number", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, "methods":[{"name":"longValue","parameterTypes":[] }] }, -{ - "name":"java.lang.NumberBeanInfo" -}, -{ - "name":"java.lang.NumberCustomizer" -}, { "name":"java.lang.Object", "allDeclaredFields":true, @@ -779,10 +632,7 @@ }, { "name":"java.lang.Runnable", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.lang.RuntimePermission" @@ -792,9 +642,6 @@ }, { "name":"java.lang.String", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllDeclaredConstructors":true, "methods":[{"name":"toUpperCase","parameterTypes":[] }] }, { @@ -816,17 +663,12 @@ }, { "name":"java.lang.constant.Constable", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.lang.constant.ConstantDesc", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.lang.invoke.TypeDescriptor", @@ -966,10 +808,6 @@ "queryAllDeclaredMethods":true, "methods":[{"name":"clear","parameterTypes":[] }, {"name":"containsKey","parameterTypes":["java.lang.Object"] }, {"name":"containsValue","parameterTypes":["java.lang.Object"] }, {"name":"entrySet","parameterTypes":[] }, {"name":"equals","parameterTypes":["java.lang.Object"] }, {"name":"get","parameterTypes":["java.lang.Object"] }, {"name":"hashCode","parameterTypes":[] }, {"name":"isEmpty","parameterTypes":[] }, {"name":"keySet","parameterTypes":[] }, {"name":"put","parameterTypes":["java.lang.Object","java.lang.Object"] }, {"name":"putAll","parameterTypes":["java.util.Map"] }, {"name":"remove","parameterTypes":["java.lang.Object"] }, {"name":"size","parameterTypes":[] }, {"name":"values","parameterTypes":[] }] }, -{ - "name":"java.util.ArrayList", - "methods":[{"name":"","parameterTypes":["java.util.Collection"] }] -}, { "name":"java.util.Arrays", "methods":[{"name":"asList","parameterTypes":["java.lang.Object[]"] }] @@ -1002,10 +840,6 @@ "name":"java.util.Enumeration", "queryAllPublicMethods":true }, -{ - "name":"java.util.HashSet", - "methods":[{"name":"","parameterTypes":["java.util.Collection"] }] -}, { "name":"java.util.Iterator", "queryAllPublicMethods":true, @@ -1095,10 +929,7 @@ }, { "name":"java.util.concurrent.Callable", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.util.concurrent.ForkJoinTask", @@ -1224,10 +1055,6 @@ "name":"jdk.internal.vm.annotation.IntrinsicCandidate", "queryAllDeclaredMethods":true }, -{ - "name":"jdk.internal.vm.annotation.Stable", - "queryAllDeclaredMethods":true -}, { "name":"org.apache.calcite.DataContext", "methods":[{"name":"get","parameterTypes":["java.lang.String"] }, {"name":"getQueryProvider","parameterTypes":[] }, {"name":"getRootSchema","parameterTypes":[] }] @@ -2006,7 +1833,8 @@ "allDeclaredClasses":true, "queryAllDeclaredMethods":true, "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllDeclaredConstructors":true, + "methods":[{"name":"","parameterTypes":[] }, {"name":"testReadWriteSplittingInLocalTransactions","parameterTypes":[] }] }, { "name":"org.apache.shardingsphere.infra.nativetest.jdbc.features.ShadowTest", @@ -2027,7 +1855,14 @@ "methods":[{"name":"","parameterTypes":[] }, {"name":"testShardingInLocalTransactions","parameterTypes":[] }] }, { - "name":"org.apache.shardingsphere.infra.nativetest.jdbc.features.TestQueryAssistedShardingEncryptAlgorithm", + "name":"org.apache.shardingsphere.infra.nativetest.jdbc.features.algorithm.ClassBasedInlineShardingAlgorithmFixture", + "allDeclaredClasses":true, + "queryAllDeclaredMethods":true, + "queryAllPublicMethods":true, + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.shardingsphere.infra.nativetest.jdbc.features.algorithm.TestQueryAssistedShardingEncryptAlgorithm", "allDeclaredClasses":true, "queryAllDeclaredMethods":true, "queryAllPublicMethods":true, @@ -2267,7 +2102,40 @@ "name":"org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfigurationCustomizer" }, { - "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration" + "name":"org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance.RandomReadQueryLoadBalanceAlgorithm", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance.RoundRobinReadQueryLoadBalanceAlgorithm", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance.WeightReadQueryLoadBalanceAlgorithm", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration", + "allDeclaredFields":true, + "queryAllPublicMethods":true, + "methods":[{"name":"","parameterTypes":[] }, {"name":"setDataSources","parameterTypes":["java.util.Map"] }] +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfigurationBeanInfo" +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfigurationCustomizer" +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceRuleConfiguration", + "allDeclaredFields":true, + "queryAllPublicMethods":true, + "methods":[{"name":"","parameterTypes":[] }, {"name":"getLoadBalancerName","parameterTypes":[] }, {"name":"getReadDataSourceNames","parameterTypes":[] }, {"name":"getTransactionalReadQueryStrategy","parameterTypes":[] }, {"name":"getWriteDataSourceName","parameterTypes":[] }, {"name":"setReadDataSourceNames","parameterTypes":["java.util.List"] }, {"name":"setWriteDataSourceName","parameterTypes":["java.lang.String"] }] +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceRuleConfigurationBeanInfo" +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceRuleConfigurationCustomizer" }, { "name":"org.apache.shardingsphere.shadow.algorithm.shadow.column.ColumnRegexMatchedShadowAlgorithm", @@ -2369,6 +2237,16 @@ "name":"org.apache.shardingsphere.sharding.algorithm.sharding.range.VolumeBasedRangeShardingAlgorithm", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm", + "allDeclaredClasses":true, + "queryAllPublicMethods":true +}, +{ + "name":"org.apache.shardingsphere.sharding.spi.ShardingAlgorithm", + "allDeclaredClasses":true, + "queryAllPublicMethods":true +}, { "name":"org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration", "allDeclaredFields":true, @@ -2520,10 +2398,6 @@ "name":"org.apiguardian.api.API", "queryAllPublicMethods":true }, -{ - "name":"org.codehaus.groovy.reflection.stdclasses.CachedSAMClass", - "methods":[{"name":"coerceToSAM","parameterTypes":["groovy.lang.Closure","java.lang.reflect.Method","java.lang.Class"] }] -}, { "name":"org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport", "queryAllDeclaredMethods":true @@ -2533,32 +2407,7 @@ "queryAllDeclaredMethods":true }, { - "name":"org.codehaus.groovy.runtime.GStringImpl", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true -}, -{ - "name":"org.codehaus.groovy.runtime.GStringImplBeanInfo" -}, -{ - "name":"org.codehaus.groovy.runtime.GStringImplCustomizer" -}, -{ - "name":"org.codehaus.groovy.runtime.GeneratedClosure", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true -}, -{ - "name":"org.codehaus.groovy.runtime.GroovyCategorySupport", - "methods":[{"name":"hasCategoryInCurrentThread","parameterTypes":[] }] -}, -{ - "name":"org.codehaus.groovy.runtime.InvokerHelper", - "methods":[{"name":"getMetaClass","parameterTypes":["java.lang.Object"] }] + "name":"org.codehaus.groovy.runtime.GStringImpl" }, { "name":"org.codehaus.groovy.runtime.NullObject" @@ -2567,10 +2416,6 @@ "name":"org.codehaus.groovy.runtime.callsite.CallSite", "queryAllPublicMethods":true }, -{ - "name":"org.codehaus.groovy.runtime.dgm$560", - "methods":[{"name":"","parameterTypes":["java.lang.String","org.codehaus.groovy.reflection.CachedClass","java.lang.Class","java.lang.Class[]"] }] -}, { "name":"org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv", "methods":[{"name":"","parameterTypes":[] }] @@ -2659,14 +2504,6 @@ "name":"org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayPutAtMetaMethod", "methods":[{"name":"","parameterTypes":[] }] }, -{ - "name":"org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation", - "methods":[{"name":"castToType","parameterTypes":["java.lang.Object","java.lang.Class"] }] -}, -{ - "name":"org.codehaus.groovy.runtime.typehandling.GroovyCastException", - "methods":[{"name":"","parameterTypes":["java.lang.Object","java.lang.Class"] }] -}, { "name":"org.codehaus.groovy.vmplugin.v10.PluginDefaultGroovyMethods", "queryAllDeclaredMethods":true @@ -2675,14 +2512,6 @@ "name":"org.codehaus.groovy.vmplugin.v16.Java16", "methods":[{"name":"","parameterTypes":[] }] }, -{ - "name":"org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures", - "methods":[{"name":"invokeGroovyObjectInvoker","parameterTypes":["groovy.lang.MissingMethodException","java.lang.Object","java.lang.String","java.lang.Object[]"] }, {"name":"isNull","parameterTypes":["java.lang.Object"] }, {"name":"isSameMetaClass","parameterTypes":["groovy.lang.MetaClass","java.lang.Object"] }, {"name":"sameClass","parameterTypes":["java.lang.Class","java.lang.Object"] }, {"name":"sameClasses","parameterTypes":["java.lang.Class[]","java.lang.Object[]"] }, {"name":"setBeanProperties","parameterTypes":["groovy.lang.MetaClass","java.lang.Object","java.util.Map"] }, {"name":"unwrap","parameterTypes":["groovy.lang.GroovyRuntimeException"] }, {"name":"unwrap","parameterTypes":["java.lang.Object"] }] -}, -{ - "name":"org.codehaus.groovy.vmplugin.v8.IndyInterface", - "methods":[{"name":"fromCache","parameterTypes":["java.lang.invoke.MutableCallSite","java.lang.Class","java.lang.String","int","java.lang.Boolean","java.lang.Boolean","java.lang.Boolean","java.lang.Object","java.lang.Object[]"] }, {"name":"selectMethod","parameterTypes":["java.lang.invoke.MutableCallSite","java.lang.Class","java.lang.String","int","java.lang.Boolean","java.lang.Boolean","java.lang.Boolean","java.lang.Object","java.lang.Object[]"] }] -}, { "name":"org.codehaus.groovy.vmplugin.v8.PluginDefaultGroovyMethods", "queryAllDeclaredMethods":true @@ -2706,30 +2535,10 @@ { "name":"org.junit.internal.AssumptionViolatedException" }, -{ - "name":"org.junit.jupiter.api.Disabled", - "queryAllPublicMethods":true -}, { "name":"org.junit.jupiter.api.Test", "queryAllPublicMethods":true }, -{ - "name":"org.junit.jupiter.api.condition.DisabledIfSystemProperty", - "queryAllPublicMethods":true -}, -{ - "name":"org.junit.jupiter.api.condition.DisabledIfSystemPropertyCondition", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"org.junit.jupiter.api.condition.DisabledInNativeImage", - "queryAllPublicMethods":true -}, -{ - "name":"org.junit.jupiter.api.extension.ExtendWith", - "queryAllPublicMethods":true -}, { "name":"org.junit.platform.commons.annotation.Testable", "queryAllPublicMethods":true @@ -2795,4 +2604,4 @@ { "name":"sun.security.x509.CertificateExtensions" } -] +] \ No newline at end of file diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/resource-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/resource-config.json index 58c0bb96ac32e9..304b53eda19fd6 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/resource-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/resource-config.json @@ -84,6 +84,10 @@ "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.mode.manager.ContextManagerBuilder\\E" }, { "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository\\E" + }, { + "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.readwritesplitting.route.standard.filter.ReadDataSourcesFilter\\E" + }, { + "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm\\E" }, { "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.shadow.spi.ShadowAlgorithm\\E" }, { @@ -110,12 +114,10 @@ "pattern":"\\QMETA-INF/services/org.junit.platform.engine.TestEngine\\E" }, { "pattern":"\\QMETA-INF/services/org.junit.platform.launcher.TestExecutionListener\\E" - }, { - "pattern":"\\QMETA-INF/services/org.slf4j.spi.SLF4JServiceProvider\\E" - }, { - "pattern":"\\Qlogback.xml\\E" }, { "pattern":"\\Qorg/h2/util/data.zip\\E" + }, { + "pattern":"\\Qorg/slf4j/impl/StaticLoggerBinder.class\\E" }, { "pattern":"\\Qsaffron.properties\\E" }, { @@ -124,6 +126,8 @@ "pattern":"\\Qyaml/encrypt.yaml\\E" }, { "pattern":"\\Qyaml/mask.yaml\\E" + }, { + "pattern":"\\Qyaml/readwrite-splitting.yaml\\E" }, { "pattern":"\\Qyaml/shadow.yaml\\E" }, { @@ -132,4 +136,4 @@ "pattern":"java.base:\\Qjdk/internal/icu/impl/data/icudt67b/nfkc.nrm\\E" }]}, "bundles":[] -} +} \ No newline at end of file diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/serialization-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/serialization-config.json index fc967f7f8d99a4..495d0c61486ecd 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/serialization-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/serialization-config.json @@ -8,4 +8,4 @@ ], "proxies":[ ] -} +} \ No newline at end of file diff --git a/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/sql/JDBCRepositorySQLLoader.java b/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/sql/JDBCRepositorySQLLoader.java index efabbb5301d922..3158be5a80464b 100644 --- a/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/sql/JDBCRepositorySQLLoader.java +++ b/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/sql/JDBCRepositorySQLLoader.java @@ -105,11 +105,34 @@ private static JDBCRepositorySQL loadFromDirectory(final URL url, final String t return loadFromDirectoryLegacy(url, type); } else { try (FileSystem ignored = FileSystems.newFileSystem(URI.create("resource:/"), Collections.emptyMap())) { - return loadFromDirectoryLegacy(url, type); + return loadFromDirectoryInNativeImage(url, type); } } } + private static JDBCRepositorySQL loadFromDirectoryInNativeImage(final URL url, final String type) throws URISyntaxException, IOException { + final JDBCRepositorySQL[] result = new JDBCRepositorySQL[1]; + Files.walkFileTree(Paths.get(url.toURI()), new SimpleFileVisitor() { + + @SneakyThrows(JAXBException.class) + @Override + public FileVisitResult visitFile(final Path file, final BasicFileAttributes attributes) throws IOException { + if (file.toString().endsWith(FILE_EXTENSION)) { + JDBCRepositorySQL provider = (JDBCRepositorySQL) JAXBContext.newInstance(JDBCRepositorySQL.class).createUnmarshaller().unmarshal(Files.newInputStream(file.toAbsolutePath())); + if (provider.isDefault()) { + result[0] = provider; + } + if (Objects.equals(provider.getType(), type)) { + result[0] = provider; + return FileVisitResult.TERMINATE; + } + } + return FileVisitResult.CONTINUE; + } + }); + return result[0]; + } + private static JDBCRepositorySQL loadFromDirectoryLegacy(final URL url, final String type) throws URISyntaxException, IOException { final JDBCRepositorySQL[] result = new JDBCRepositorySQL[1]; Files.walkFileTree(Paths.get(url.toURI()), new SimpleFileVisitor() {