You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/12/29 18:42:12 UTC

[GitHub] [shardingsphere] linghengqian opened a new pull request, #23176: Add StandalonePersistRepository implementation of R2DBC_MariaDB

linghengqian opened a new pull request, #23176:
URL: https://github.com/apache/shardingsphere/pull/23176

   Fixes #19766.
   
   Changes proposed in this pull request:
     - Add StandalonePersistRepository implementation of R2DBC_MariaDB.
     - This is a draft that is not yet ready.
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [ ] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [ ] I have self-reviewed the commit code.
   - [ ] I have (or in comment I request) added corresponding labels for the pull request.
   - [ ] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [ ] I have added corresponding unit tests for my changes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN commented on pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#issuecomment-1367823620

   @zhaojinchao95 Please follow this, thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059312307


##########
mode/type/standalone/repository/provider/jdbc/mysql/src/test/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/mysql/MysqlJDBCRepositoryProviderTest.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.shardingsphere.mode.repository.standalone.jdbc.mysql;
+
+import org.apache.shardingsphere.mode.repository.standalone.jdbc.JDBCRepository;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Properties;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class MysqlJDBCRepositoryProviderTest {
+    
+    private final JDBCRepository repository = new JDBCRepository();
+    
+    @Before
+    public void setUp() {
+        Properties props = new Properties();
+        props.setProperty("jdbcUrl", "jdbc:tc:mysql:8.0.31:///config");
+        props.setProperty("username", "sa");
+        props.setProperty("password", "");
+        props.setProperty("provider", "MYSQL");
+        repository.init(props);
+    }
+    
+    @After
+    public void stop() {
+        repository.close();
+    }
+    
+    @Test
+    public void assertPersistAndGet() {
+        repository.persist("/testPath/test1", "test1_content");
+        assertThat(repository.getDirectly("/testPath/test1"), is("test1_content"));
+        repository.persist("/testPath/test1", "modify_content");
+        assertThat(repository.getDirectly("/testPath/test1"), is("modify_content"));
+    }
+    
+    @Test
+    public void assertPersistAndGetChildrenKeys() {
+        repository.persist("/testPath/test1", "test1_content");
+        repository.persist("/testPath/test2", "test2_content");
+        List<String> childrenKeys = repository.getChildrenKeys("/testPath");
+        assertThat(childrenKeys.get(0), is("test2"));
+        assertThat(childrenKeys.get(1), is("test1"));
+    }

Review Comment:
   - It seems that MySQL and H2Database have different default ResultSet sorting methods, but I don't think this is a problem.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059382876


##########
mode/type/standalone/repository/provider/jdbc/mysql/pom.xml:
##########
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.shardingsphere</groupId>
+        <artifactId>shardingsphere-standalone-mode-repository-jdbc</artifactId>
+        <version>5.3.1-SNAPSHOT</version>
+    </parent>
+    
+    <artifactId>shardingsphere-standalone-mode-repository-jdbc-mysql</artifactId>
+    
+    <properties>
+        <testcontainers.version>1.17.6</testcontainers.version>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-jdbc-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+            <scope>compile</scope>
+        </dependency>

Review Comment:
   - Do I need to set HikariCP to test scope?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059335087


##########
mode/type/standalone/repository/provider/jdbc/mysql/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/mysql/MysqlJDBCRepositoryProvider.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.mode.repository.standalone.jdbc.mysql;
+
+import org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider;
+
+/**
+ * MySQL JDBC repository provider.
+ */
+public final class MysqlJDBCRepositoryProvider implements JDBCRepositoryProvider {

Review Comment:
   Rename MysqlJDBCRepositoryProvider to MySQLJDBCRepositoryProvider



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059400590


##########
mode/type/standalone/repository/provider/jdbc/mysql/pom.xml:
##########
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.shardingsphere</groupId>
+        <artifactId>shardingsphere-standalone-mode-repository-jdbc</artifactId>
+        <version>5.3.1-SNAPSHOT</version>
+    </parent>
+    
+    <artifactId>shardingsphere-standalone-mode-repository-jdbc-mysql</artifactId>
+    
+    <properties>
+        <testcontainers.version>1.17.6</testcontainers.version>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-jdbc-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testcontainers</groupId>

Review Comment:
   It's not allowed, maybe can you use `mock`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059430521


##########
mode/type/standalone/repository/provider/jdbc/mysql/pom.xml:
##########
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.shardingsphere</groupId>
+        <artifactId>shardingsphere-standalone-mode-repository-jdbc</artifactId>
+        <version>5.3.1-SNAPSHOT</version>
+    </parent>
+    
+    <artifactId>shardingsphere-standalone-mode-repository-jdbc-mysql</artifactId>
+    
+    <properties>
+        <testcontainers.version>1.17.6</testcontainers.version>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-jdbc-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testcontainers</groupId>

Review Comment:
   - I removed this dependency and added to MySQLJDBCRepositoryProviderTest that requires a Mock.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059589222


##########
src/resources/checkstyle_ci.xml:
##########
@@ -54,7 +54,7 @@
         <module name="ParameterName" />
         <module name="CatchParameterName" />
         <module name="AbbreviationAsWordInName">
-            <property name="allowedAbbreviationLength" value="6" />
+            <property name="allowedAbbreviationLength" value="12" />

Review Comment:
   - Solved.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059396176


##########
mode/type/standalone/repository/provider/jdbc/mysql/pom.xml:
##########
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.shardingsphere</groupId>
+        <artifactId>shardingsphere-standalone-mode-repository-jdbc</artifactId>
+        <version>5.3.1-SNAPSHOT</version>
+    </parent>
+    
+    <artifactId>shardingsphere-standalone-mode-repository-jdbc-mysql</artifactId>
+    
+    <properties>
+        <testcontainers.version>1.17.6</testcontainers.version>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-jdbc-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testcontainers</groupId>

Review Comment:
   - This is because the MySQLJDBCRepositoryProviderTest created real MySQL instance. This is to align the test case for the implementation of H2Database.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN commented on a diff in pull request #23176: Add StandalonePersistRepository implementation of R2DBC_MariaDB

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059269705


##########
mode/type/standalone/repository/provider/r2dbc-mariadb/src/main/java/org/apache/shardingsphere/mode/repository/standalone/r2dbc/mariadb/R2DBCMariaDBRepository.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.mode.repository.standalone.r2dbc.mariadb;
+
+import com.google.common.base.Strings;
+import io.r2dbc.pool.ConnectionPool;
+import io.r2dbc.pool.ConnectionPoolConfiguration;
+import io.r2dbc.spi.Connection;
+import io.r2dbc.spi.ConnectionFactories;
+import io.r2dbc.spi.ConnectionFactory;
+import io.r2dbc.spi.ConnectionFactoryOptions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+
+/**
+ * R2DBC MariaDB repository.
+ */
+@Slf4j
+public class R2DBCMariaDBRepository implements StandalonePersistRepository {
+    
+    private static final String SEPARATOR = "/";
+    
+    private ConnectionPool connectionPool;
+    
+    @Override
+    public void init(final Properties props) {
+        ConnectionFactoryOptions connectionFactoryOptions = ConnectionFactoryOptions.builder()
+                .option(ConnectionFactoryOptions.DRIVER, "pool")
+                .option(ConnectionFactoryOptions.PROTOCOL, "mariadb")
+                .option(ConnectionFactoryOptions.HOST, props.getProperty("host"))
+                .option(ConnectionFactoryOptions.PORT, Integer.parseInt(props.getProperty("port")))
+                .option(ConnectionFactoryOptions.USER, props.getProperty("user"))
+                .option(ConnectionFactoryOptions.PASSWORD, props.getProperty("password"))
+                .option(ConnectionFactoryOptions.DATABASE, props.getProperty("database"))
+                .build();
+        ConnectionFactory connectionFactory = ConnectionFactories.get(connectionFactoryOptions);
+        ConnectionPoolConfiguration connectionPoolConfiguration = ConnectionPoolConfiguration.builder(connectionFactory).build();
+        connectionPool = new ConnectionPool(connectionPoolConfiguration);
+        Mono.usingWhen(connectionPool.create(),
+                connection -> Mono.from(connection.createBatch()
+                        .add("DROP TABLE IF EXISTS `repository`")
+                        .add("CREATE TABLE IF NOT EXISTS `repository`(id varchar(36) PRIMARY KEY, `key` TEXT, `value` TEXT, parent TEXT)")
+                        .execute()),
+                Connection::close)
+                .block();
+    }
+    
+    @Override
+    public String getDirectly(final String key) {
+        return Mono.usingWhen(connectionPool.create(),
+                connection -> Mono.from(connection.createStatement("SELECT `value` FROM `repository` WHERE `key` = ?")
+                        .bind(0, key)
+                        .execute())
+                        .flatMap(result -> Mono.from(result.map((row, rowMetadata) -> row.get("value", String.class))))
+                        .doOnError(throwable -> log.error("Get {} data by key: {} failed", getType(), key, throwable)),
+                Connection::close)
+                .block();

Review Comment:
   About license, we have already introduced MySQL JDBC driver as test scope. Our code just using standard JDBC interface. MySQL JDBC driver could be introduced by user themselves, just like how ShardingSphere-Proxy distribution did.
   
   Could we just add a `MySQLJDBCRepositoryProvider` which implements `org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider`?
   
   About the second question, I'm not familiar with it, sorry.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN commented on a diff in pull request #23176: Add StandalonePersistRepository implementation of R2DBC_MariaDB

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059213823


##########
mode/type/standalone/repository/provider/r2dbc-mariadb/src/main/java/org/apache/shardingsphere/mode/repository/standalone/r2dbc/mariadb/R2DBCMariaDBRepository.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.mode.repository.standalone.r2dbc.mariadb;
+
+import com.google.common.base.Strings;
+import io.r2dbc.pool.ConnectionPool;
+import io.r2dbc.pool.ConnectionPoolConfiguration;
+import io.r2dbc.spi.Connection;
+import io.r2dbc.spi.ConnectionFactories;
+import io.r2dbc.spi.ConnectionFactory;
+import io.r2dbc.spi.ConnectionFactoryOptions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+
+/**
+ * R2DBC MariaDB repository.
+ */
+@Slf4j
+public class R2DBCMariaDBRepository implements StandalonePersistRepository {
+    
+    private static final String SEPARATOR = "/";
+    
+    private ConnectionPool connectionPool;
+    
+    @Override
+    public void init(final Properties props) {
+        ConnectionFactoryOptions connectionFactoryOptions = ConnectionFactoryOptions.builder()
+                .option(ConnectionFactoryOptions.DRIVER, "pool")
+                .option(ConnectionFactoryOptions.PROTOCOL, "mariadb")
+                .option(ConnectionFactoryOptions.HOST, props.getProperty("host"))
+                .option(ConnectionFactoryOptions.PORT, Integer.parseInt(props.getProperty("port")))
+                .option(ConnectionFactoryOptions.USER, props.getProperty("user"))
+                .option(ConnectionFactoryOptions.PASSWORD, props.getProperty("password"))
+                .option(ConnectionFactoryOptions.DATABASE, props.getProperty("database"))
+                .build();
+        ConnectionFactory connectionFactory = ConnectionFactories.get(connectionFactoryOptions);
+        ConnectionPoolConfiguration connectionPoolConfiguration = ConnectionPoolConfiguration.builder(connectionFactory).build();
+        connectionPool = new ConnectionPool(connectionPoolConfiguration);
+        Mono.usingWhen(connectionPool.create(),
+                connection -> Mono.from(connection.createBatch()
+                        .add("DROP TABLE IF EXISTS `repository`")
+                        .add("CREATE TABLE IF NOT EXISTS `repository`(id varchar(36) PRIMARY KEY, `key` TEXT, `value` TEXT, parent TEXT)")
+                        .execute()),
+                Connection::close)
+                .block();
+    }
+    
+    @Override
+    public String getDirectly(final String key) {
+        return Mono.usingWhen(connectionPool.create(),
+                connection -> Mono.from(connection.createStatement("SELECT `value` FROM `repository` WHERE `key` = ?")
+                        .bind(0, key)
+                        .execute())
+                        .flatMap(result -> Mono.from(result.map((row, rowMetadata) -> row.get("value", String.class))))
+                        .doOnError(throwable -> log.error("Get {} data by key: {} failed", getType(), key, throwable)),
+                Connection::close)
+                .block();

Review Comment:
   If we have to block the thread, why not just use the standard JDBC driver?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] codecov-commenter commented on pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#issuecomment-1367856177

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/23176?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#23176](https://codecov.io/gh/apache/shardingsphere/pull/23176?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (281f1fa) into [master](https://codecov.io/gh/apache/shardingsphere/commit/11b45120a8cc23368ff0c659be8c62333bc87545?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (11b4512) will **decrease** coverage by `0.17%`.
   > The diff coverage is `90.00%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #23176      +/-   ##
   ============================================
   - Coverage     49.92%   49.75%   -0.18%     
   - Complexity     2437     2442       +5     
   ============================================
     Files          4119     4017     -102     
     Lines         57705    57450     -255     
     Branches       9116     9113       -3     
   ============================================
   - Hits          28809    28582     -227     
   + Misses        26363    26333      -30     
   - Partials       2533     2535       +2     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/23176?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...dalone/jdbc/mysql/MysqlJDBCRepositoryProvider.java](https://codecov.io/gh/apache/shardingsphere/pull/23176/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bW9kZS90eXBlL3N0YW5kYWxvbmUvcmVwb3NpdG9yeS9wcm92aWRlci9qZGJjL215c3FsL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL3JlcG9zaXRvcnkvc3RhbmRhbG9uZS9qZGJjL215c3FsL015c3FsSkRCQ1JlcG9zaXRvcnlQcm92aWRlci5qYXZh) | `90.00% <90.00%> (ø)` | |
   | [...nce/metadata/jdbc/JDBCInstanceMetaDataBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/23176/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5mcmEvY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9pbnN0YW5jZS9tZXRhZGF0YS9qZGJjL0pEQkNJbnN0YW5jZU1ldGFEYXRhQnVpbGRlci5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...e/metadata/proxy/ProxyInstanceMetaDataBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/23176/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5mcmEvY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9pbnN0YW5jZS9tZXRhZGF0YS9wcm94eS9Qcm94eUluc3RhbmNlTWV0YURhdGFCdWlsZGVyLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...ontext/parser/dialect/impl/H2OptimizerBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/23176/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL3NxbC1mZWRlcmF0aW9uL29wdGltaXplci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsZmVkZXJhdGlvbi9vcHRpbWl6ZXIvY29udGV4dC9wYXJzZXIvZGlhbGVjdC9pbXBsL0gyT3B0aW1pemVyQnVpbGRlci5qYXZh) | `25.00% <0.00%> (-75.00%)` | :arrow_down: |
   | [...handler/distsql/ral/hint/enums/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/23176/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2Rpc3RzcWwvcmFsL2hpbnQvZW51bXMvSGludFNvdXJjZVR5cGUuamF2YQ==) | `0.00% <0.00%> (-42.86%)` | :arrow_down: |
   | [...a/instance/metadata/jdbc/JDBCInstanceMetaData.java](https://codecov.io/gh/apache/shardingsphere/pull/23176/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5mcmEvY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9pbnN0YW5jZS9tZXRhZGF0YS9qZGJjL0pEQkNJbnN0YW5jZU1ldGFEYXRhLmphdmE=) | `58.33% <0.00%> (-41.67%)` | :arrow_down: |
   | [...instance/metadata/proxy/ProxyInstanceMetaData.java](https://codecov.io/gh/apache/shardingsphere/pull/23176/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5mcmEvY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9pbnN0YW5jZS9tZXRhZGF0YS9wcm94eS9Qcm94eUluc3RhbmNlTWV0YURhdGEuamF2YQ==) | `60.00% <0.00%> (-40.00%)` | :arrow_down: |
   | [...se/schema/loader/common/DefaultDataTypeLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/23176/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5mcmEvY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9kYXRhYmFzZS9zY2hlbWEvbG9hZGVyL2NvbW1vbi9EZWZhdWx0RGF0YVR5cGVMb2FkZXIuamF2YQ==) | `75.00% <0.00%> (-25.00%)` | :arrow_down: |
   | [...header/query/impl/OpenGaussQueryHeaderBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/23176/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9yZXNwb25zZS9oZWFkZXIvcXVlcnkvaW1wbC9PcGVuR2F1c3NRdWVyeUhlYWRlckJ1aWxkZXIuamF2YQ==) | `75.00% <0.00%> (-25.00%)` | :arrow_down: |
   | [...er/jdbc/builder/StatementExecutionUnitBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/23176/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5mcmEvZXhlY3V0b3Ivc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2luZnJhL2V4ZWN1dG9yL3NxbC9wcmVwYXJlL2RyaXZlci9qZGJjL2J1aWxkZXIvU3RhdGVtZW50RXhlY3V0aW9uVW5pdEJ1aWxkZXIuamF2YQ==) | `0.00% <0.00%> (-25.00%)` | :arrow_down: |
   | ... and [325 more](https://codecov.io/gh/apache/shardingsphere/pull/23176/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059397921


##########
mode/type/standalone/repository/provider/jdbc/mysql/pom.xml:
##########
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.shardingsphere</groupId>
+        <artifactId>shardingsphere-standalone-mode-repository-jdbc</artifactId>
+        <version>5.3.1-SNAPSHOT</version>
+    </parent>
+    
+    <artifactId>shardingsphere-standalone-mode-repository-jdbc-mysql</artifactId>
+    
+    <properties>
+        <testcontainers.version>1.17.6</testcontainers.version>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-jdbc-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+            <scope>compile</scope>
+        </dependency>

Review Comment:
   - This is just a dependency for testing, and I will remove it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 commented on pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 commented on PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#issuecomment-1367839641

   > @zhaojinchao95 Please follow this, thanks.
   
   OK, thx.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059430521


##########
mode/type/standalone/repository/provider/jdbc/mysql/pom.xml:
##########
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.shardingsphere</groupId>
+        <artifactId>shardingsphere-standalone-mode-repository-jdbc</artifactId>
+        <version>5.3.1-SNAPSHOT</version>
+    </parent>
+    
+    <artifactId>shardingsphere-standalone-mode-repository-jdbc-mysql</artifactId>
+    
+    <properties>
+        <testcontainers.version>1.17.6</testcontainers.version>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-jdbc-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testcontainers</groupId>

Review Comment:
   - I removed this dependency and added to MySQLJDBCRepositoryProviderTest that requires Mock.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059328688


##########
mode/type/standalone/repository/provider/jdbc/mysql/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/mysql/MysqlJDBCRepositoryProvider.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.mode.repository.standalone.jdbc.mysql;
+
+import org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider;
+
+/**
+ * MySQL JDBC repository provider.
+ */
+public class MysqlJDBCRepositoryProvider implements JDBCRepositoryProvider {

Review Comment:
   > Maybe MysqlJDBCRepositoryProvider need to rename MySQLJDBCRepositoryProvider
   
   - This would violate the checkstyle rule, which requires no more than seven uppercase letters in a word.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059327051


##########
mode/type/standalone/repository/provider/jdbc/mysql/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/mysql/MysqlJDBCRepositoryProvider.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.mode.repository.standalone.jdbc.mysql;
+
+import org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider;
+
+/**
+ * MySQL JDBC repository provider.
+ */
+public class MysqlJDBCRepositoryProvider implements JDBCRepositoryProvider {

Review Comment:
   Maybe MysqlJDBCRepositoryProvider need to rename MySQLJDBCRepositoryProvider



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add StandalonePersistRepository implementation of R2DBC_MariaDB

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059236386


##########
mode/type/standalone/repository/provider/r2dbc-mariadb/src/main/java/org/apache/shardingsphere/mode/repository/standalone/r2dbc/mariadb/R2DBCMariaDBRepository.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.mode.repository.standalone.r2dbc.mariadb;
+
+import com.google.common.base.Strings;
+import io.r2dbc.pool.ConnectionPool;
+import io.r2dbc.pool.ConnectionPoolConfiguration;
+import io.r2dbc.spi.Connection;
+import io.r2dbc.spi.ConnectionFactories;
+import io.r2dbc.spi.ConnectionFactory;
+import io.r2dbc.spi.ConnectionFactoryOptions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+
+/**
+ * R2DBC MariaDB repository.
+ */
+@Slf4j
+public class R2DBCMariaDBRepository implements StandalonePersistRepository {
+    
+    private static final String SEPARATOR = "/";
+    
+    private ConnectionPool connectionPool;
+    
+    @Override
+    public void init(final Properties props) {
+        ConnectionFactoryOptions connectionFactoryOptions = ConnectionFactoryOptions.builder()
+                .option(ConnectionFactoryOptions.DRIVER, "pool")
+                .option(ConnectionFactoryOptions.PROTOCOL, "mariadb")
+                .option(ConnectionFactoryOptions.HOST, props.getProperty("host"))
+                .option(ConnectionFactoryOptions.PORT, Integer.parseInt(props.getProperty("port")))
+                .option(ConnectionFactoryOptions.USER, props.getProperty("user"))
+                .option(ConnectionFactoryOptions.PASSWORD, props.getProperty("password"))
+                .option(ConnectionFactoryOptions.DATABASE, props.getProperty("database"))
+                .build();
+        ConnectionFactory connectionFactory = ConnectionFactories.get(connectionFactoryOptions);
+        ConnectionPoolConfiguration connectionPoolConfiguration = ConnectionPoolConfiguration.builder(connectionFactory).build();
+        connectionPool = new ConnectionPool(connectionPoolConfiguration);
+        Mono.usingWhen(connectionPool.create(),
+                connection -> Mono.from(connection.createBatch()
+                        .add("DROP TABLE IF EXISTS `repository`")
+                        .add("CREATE TABLE IF NOT EXISTS `repository`(id varchar(36) PRIMARY KEY, `key` TEXT, `value` TEXT, parent TEXT)")
+                        .execute()),
+                Connection::close)
+                .block();
+    }
+    
+    @Override
+    public String getDirectly(final String key) {
+        return Mono.usingWhen(connectionPool.create(),
+                connection -> Mono.from(connection.createStatement("SELECT `value` FROM `repository` WHERE `key` = ?")
+                        .bind(0, key)
+                        .execute())
+                        .flatMap(result -> Mono.from(result.map((row, rowMetadata) -> row.get("value", String.class))))
+                        .doOnError(throwable -> log.error("Get {} data by key: {} failed", getType(), key, throwable)),
+                Connection::close)
+                .block();

Review Comment:
   - Does this mean setting MySQL's JDBC driver to maven test scope to avoid GPL LICENSE issues? Or must we avoid using the GPL LICENSE? 
   
   - I have checked the processing of the implementation of H2Database. Can testcontainers be used for regular tests? The init function seems to have to actually have a data source.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059588052


##########
src/resources/checkstyle_ci.xml:
##########
@@ -54,7 +54,7 @@
         <module name="ParameterName" />
         <module name="CatchParameterName" />
         <module name="AbbreviationAsWordInName">
-            <property name="allowedAbbreviationLength" value="6" />
+            <property name="allowedAbbreviationLength" value="12" />

Review Comment:
   Adjustment `value=8` is ok?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059391912


##########
mode/type/standalone/repository/provider/jdbc/mysql/pom.xml:
##########
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.shardingsphere</groupId>
+        <artifactId>shardingsphere-standalone-mode-repository-jdbc</artifactId>
+        <version>5.3.1-SNAPSHOT</version>
+    </parent>
+    
+    <artifactId>shardingsphere-standalone-mode-repository-jdbc-mysql</artifactId>
+    
+    <properties>
+        <testcontainers.version>1.17.6</testcontainers.version>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-jdbc-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testcontainers</groupId>

Review Comment:
   Why add `org.testcontainers` dependency ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 merged pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 merged PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059361848


##########
mode/type/standalone/repository/provider/jdbc/mysql/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/mysql/MysqlJDBCRepositoryProvider.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.mode.repository.standalone.jdbc.mysql;
+
+import org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider;
+
+/**
+ * MySQL JDBC repository provider.
+ */
+public final class MysqlJDBCRepositoryProvider implements JDBCRepositoryProvider {

Review Comment:
   - I doubled the allowedAbbreviationLength Property of the AbbreviationAsWordInName Moudle. Resolved.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059392519


##########
mode/type/standalone/repository/provider/jdbc/mysql/pom.xml:
##########
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.shardingsphere</groupId>
+        <artifactId>shardingsphere-standalone-mode-repository-jdbc</artifactId>
+        <version>5.3.1-SNAPSHOT</version>
+    </parent>
+    
+    <artifactId>shardingsphere-standalone-mode-repository-jdbc-mysql</artifactId>
+    
+    <properties>
+        <testcontainers.version>1.17.6</testcontainers.version>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-jdbc-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+            <scope>compile</scope>
+        </dependency>

Review Comment:
   Is it necessary?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059309506


##########
mode/type/standalone/repository/provider/r2dbc-mariadb/src/main/java/org/apache/shardingsphere/mode/repository/standalone/r2dbc/mariadb/R2DBCMariaDBRepository.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.mode.repository.standalone.r2dbc.mariadb;
+
+import com.google.common.base.Strings;
+import io.r2dbc.pool.ConnectionPool;
+import io.r2dbc.pool.ConnectionPoolConfiguration;
+import io.r2dbc.spi.Connection;
+import io.r2dbc.spi.ConnectionFactories;
+import io.r2dbc.spi.ConnectionFactory;
+import io.r2dbc.spi.ConnectionFactoryOptions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+
+/**
+ * R2DBC MariaDB repository.
+ */
+@Slf4j
+public class R2DBCMariaDBRepository implements StandalonePersistRepository {
+    
+    private static final String SEPARATOR = "/";
+    
+    private ConnectionPool connectionPool;
+    
+    @Override
+    public void init(final Properties props) {
+        ConnectionFactoryOptions connectionFactoryOptions = ConnectionFactoryOptions.builder()
+                .option(ConnectionFactoryOptions.DRIVER, "pool")
+                .option(ConnectionFactoryOptions.PROTOCOL, "mariadb")
+                .option(ConnectionFactoryOptions.HOST, props.getProperty("host"))
+                .option(ConnectionFactoryOptions.PORT, Integer.parseInt(props.getProperty("port")))
+                .option(ConnectionFactoryOptions.USER, props.getProperty("user"))
+                .option(ConnectionFactoryOptions.PASSWORD, props.getProperty("password"))
+                .option(ConnectionFactoryOptions.DATABASE, props.getProperty("database"))
+                .build();
+        ConnectionFactory connectionFactory = ConnectionFactories.get(connectionFactoryOptions);
+        ConnectionPoolConfiguration connectionPoolConfiguration = ConnectionPoolConfiguration.builder(connectionFactory).build();
+        connectionPool = new ConnectionPool(connectionPoolConfiguration);
+        Mono.usingWhen(connectionPool.create(),
+                connection -> Mono.from(connection.createBatch()
+                        .add("DROP TABLE IF EXISTS `repository`")
+                        .add("CREATE TABLE IF NOT EXISTS `repository`(id varchar(36) PRIMARY KEY, `key` TEXT, `value` TEXT, parent TEXT)")
+                        .execute()),
+                Connection::close)
+                .block();
+    }
+    
+    @Override
+    public String getDirectly(final String key) {
+        return Mono.usingWhen(connectionPool.create(),
+                connection -> Mono.from(connection.createStatement("SELECT `value` FROM `repository` WHERE `key` = ?")
+                        .bind(0, key)
+                        .execute())
+                        .flatMap(result -> Mono.from(result.map((row, rowMetadata) -> row.get("value", String.class))))
+                        .doOnError(throwable -> log.error("Get {} data by key: {} failed", getType(), key, throwable)),
+                Connection::close)
+                .block();

Review Comment:
   - I looked back at what the original issue was trying to express, and I noticed that what he actually needed was something else. So I decided to delete the R2DBC implementation in the new commit.
   
   - As for testcontainers, I am referring to the specific Docker container Url of `jdbc:tc:mysql:8.0.31:///config`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059339295


##########
mode/type/standalone/repository/provider/jdbc/mysql/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/mysql/MysqlJDBCRepositoryProvider.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.mode.repository.standalone.jdbc.mysql;
+
+import org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider;
+
+/**
+ * MySQL JDBC repository provider.
+ */
+public final class MysqlJDBCRepositoryProvider implements JDBCRepositoryProvider {

Review Comment:
   > * This would violate the checkstyle rule, which requires no more than seven uppercase letters in a word.
   
   I think we need to investigate checkstyle rule and adjustment it, beacase the `MysqlJDBCRepositoryProvider` does not conform to specification



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add StandalonePersistRepository implementation of R2DBC_MariaDB

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059236386


##########
mode/type/standalone/repository/provider/r2dbc-mariadb/src/main/java/org/apache/shardingsphere/mode/repository/standalone/r2dbc/mariadb/R2DBCMariaDBRepository.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.mode.repository.standalone.r2dbc.mariadb;
+
+import com.google.common.base.Strings;
+import io.r2dbc.pool.ConnectionPool;
+import io.r2dbc.pool.ConnectionPoolConfiguration;
+import io.r2dbc.spi.Connection;
+import io.r2dbc.spi.ConnectionFactories;
+import io.r2dbc.spi.ConnectionFactory;
+import io.r2dbc.spi.ConnectionFactoryOptions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+
+/**
+ * R2DBC MariaDB repository.
+ */
+@Slf4j
+public class R2DBCMariaDBRepository implements StandalonePersistRepository {
+    
+    private static final String SEPARATOR = "/";
+    
+    private ConnectionPool connectionPool;
+    
+    @Override
+    public void init(final Properties props) {
+        ConnectionFactoryOptions connectionFactoryOptions = ConnectionFactoryOptions.builder()
+                .option(ConnectionFactoryOptions.DRIVER, "pool")
+                .option(ConnectionFactoryOptions.PROTOCOL, "mariadb")
+                .option(ConnectionFactoryOptions.HOST, props.getProperty("host"))
+                .option(ConnectionFactoryOptions.PORT, Integer.parseInt(props.getProperty("port")))
+                .option(ConnectionFactoryOptions.USER, props.getProperty("user"))
+                .option(ConnectionFactoryOptions.PASSWORD, props.getProperty("password"))
+                .option(ConnectionFactoryOptions.DATABASE, props.getProperty("database"))
+                .build();
+        ConnectionFactory connectionFactory = ConnectionFactories.get(connectionFactoryOptions);
+        ConnectionPoolConfiguration connectionPoolConfiguration = ConnectionPoolConfiguration.builder(connectionFactory).build();
+        connectionPool = new ConnectionPool(connectionPoolConfiguration);
+        Mono.usingWhen(connectionPool.create(),
+                connection -> Mono.from(connection.createBatch()
+                        .add("DROP TABLE IF EXISTS `repository`")
+                        .add("CREATE TABLE IF NOT EXISTS `repository`(id varchar(36) PRIMARY KEY, `key` TEXT, `value` TEXT, parent TEXT)")
+                        .execute()),
+                Connection::close)
+                .block();
+    }
+    
+    @Override
+    public String getDirectly(final String key) {
+        return Mono.usingWhen(connectionPool.create(),
+                connection -> Mono.from(connection.createStatement("SELECT `value` FROM `repository` WHERE `key` = ?")
+                        .bind(0, key)
+                        .execute())
+                        .flatMap(result -> Mono.from(result.map((row, rowMetadata) -> row.get("value", String.class))))
+                        .doOnError(throwable -> log.error("Get {} data by key: {} failed", getType(), key, throwable)),
+                Connection::close)
+                .block();

Review Comment:
   - Does this mean setting MySQL's JDBC driver to maven test scope to avoid GPL LICENSE issues? Or must we avoid using the GPL LICENSE? 
   
   - I have checked the processing of the implementation of H2Database. Can testcontainer be used for regular tests? The init function seems to have to actually have a data source.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059326668


##########
mode/type/standalone/repository/provider/jdbc/mysql/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/mysql/MysqlJDBCRepositoryProvider.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.mode.repository.standalone.jdbc.mysql;
+
+import org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider;
+
+/**
+ * MySQL JDBC repository provider.
+ */
+public class MysqlJDBCRepositoryProvider implements JDBCRepositoryProvider {

Review Comment:
   Add final please.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059335447


##########
mode/type/standalone/repository/provider/jdbc/mysql/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/mysql/MysqlJDBCRepositoryProvider.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.mode.repository.standalone.jdbc.mysql;
+
+import org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider;
+
+/**
+ * MySQL JDBC repository provider.
+ */
+public final class MysqlJDBCRepositoryProvider implements JDBCRepositoryProvider {

Review Comment:
   - This would violate the checkstyle rule, which requires no more than seven uppercase letters in a word.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059361848


##########
mode/type/standalone/repository/provider/jdbc/mysql/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/mysql/MysqlJDBCRepositoryProvider.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.mode.repository.standalone.jdbc.mysql;
+
+import org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider;
+
+/**
+ * MySQL JDBC repository provider.
+ */
+public final class MysqlJDBCRepositoryProvider implements JDBCRepositoryProvider {

Review Comment:
   - I doubled the allowedAbbreviationLength Property of the AbbreviationAsWordInName Moudle.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059315725


##########
mode/type/standalone/repository/provider/jdbc/mysql/src/test/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/mysql/MysqlJDBCRepositoryProviderTest.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.shardingsphere.mode.repository.standalone.jdbc.mysql;
+
+import org.apache.shardingsphere.mode.repository.standalone.jdbc.JDBCRepository;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Properties;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class MysqlJDBCRepositoryProviderTest {
+    
+    private final JDBCRepository repository = new JDBCRepository();
+    
+    @Before
+    public void setUp() {
+        Properties props = new Properties();
+        props.setProperty("jdbc_url", "jdbc:tc:mysql:8.0.31:///config");
+        props.setProperty("username", "sa");
+        props.setProperty("password", "");
+        props.setProperty("provider", "MYSQL");
+        repository.init(props);
+    }
+    
+    @After
+    public void stop() {
+        repository.close();
+    }
+    
+    @Test
+    public void assertPersistAndGet() {
+        repository.persist("/testPath/test1", "test1_content");
+        assertThat(repository.getDirectly("/testPath/test1"), is("test1_content"));
+        repository.persist("/testPath/test1", "modify_content");
+        assertThat(repository.getDirectly("/testPath/test1"), is("modify_content"));
+    }
+    
+    @Test
+    public void assertPersistAndGetChildrenKeys() {
+        repository.persist("/testPath/test1", "test1_content");
+        repository.persist("/testPath/test2", "test2_content");
+        List<String> childrenKeys = repository.getChildrenKeys("/testPath");
+        assertThat(childrenKeys.get(0), is("test2"));
+        assertThat(childrenKeys.get(1), is("test1"));
+    }

Review Comment:
   - It looks like MySQL's ResultSet is sorted differently by default than H2Database, which I think makes sense.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059330547


##########
mode/type/standalone/repository/provider/jdbc/mysql/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/mysql/MysqlJDBCRepositoryProvider.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.mode.repository.standalone.jdbc.mysql;
+
+import org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider;
+
+/**
+ * MySQL JDBC repository provider.
+ */
+public class MysqlJDBCRepositoryProvider implements JDBCRepositoryProvider {

Review Comment:
   > Add final please.
   
   - Resolved.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059378434


##########
mode/type/standalone/repository/provider/jdbc/mysql/src/test/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/mysql/MysqlJDBCRepositoryProviderTest.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.shardingsphere.mode.repository.standalone.jdbc.mysql;
+
+import org.apache.shardingsphere.mode.repository.standalone.jdbc.JDBCRepository;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Properties;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class MysqlJDBCRepositoryProviderTest {
+    
+    private final JDBCRepository repository = new JDBCRepository();
+    
+    @Before
+    public void setUp() {
+        Properties props = new Properties();
+        props.setProperty("jdbc_url", "jdbc:tc:mysql:8.0.31:///config");
+        props.setProperty("username", "sa");
+        props.setProperty("password", "");
+        props.setProperty("provider", "MYSQL");
+        repository.init(props);
+    }
+    
+    @After
+    public void stop() {
+        repository.close();
+    }
+    
+    @Test
+    public void assertPersistAndGet() {
+        repository.persist("/testPath/test1", "test1_content");
+        assertThat(repository.getDirectly("/testPath/test1"), is("test1_content"));
+        repository.persist("/testPath/test1", "modify_content");
+        assertThat(repository.getDirectly("/testPath/test1"), is("modify_content"));
+    }
+    
+    @Test
+    public void assertPersistAndGetChildrenKeys() {
+        repository.persist("/testPath/test1", "test1_content");
+        repository.persist("/testPath/test2", "test2_content");
+        List<String> childrenKeys = repository.getChildrenKeys("/testPath");
+        assertThat(childrenKeys.get(0), is("test2"));
+        assertThat(childrenKeys.get(1), is("test1"));
+    }

Review Comment:
   - I added order by restriction to selectByParentKeySQL.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #23176: Add JDBCRepositoryProvider implementation of MYSQL

Posted by GitBox <gi...@apache.org>.
linghengqian commented on code in PR #23176:
URL: https://github.com/apache/shardingsphere/pull/23176#discussion_r1059382876


##########
mode/type/standalone/repository/provider/jdbc/mysql/pom.xml:
##########
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.shardingsphere</groupId>
+        <artifactId>shardingsphere-standalone-mode-repository-jdbc</artifactId>
+        <version>5.3.1-SNAPSHOT</version>
+    </parent>
+    
+    <artifactId>shardingsphere-standalone-mode-repository-jdbc-mysql</artifactId>
+    
+    <properties>
+        <testcontainers.version>1.17.6</testcontainers.version>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-standalone-mode-repository-jdbc-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+            <scope>compile</scope>
+        </dependency>

Review Comment:
   - Do I need to set HikaeiCP to test scope?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org