You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "FlyingZC (via GitHub)" <gi...@apache.org> on 2023/02/06 03:30:45 UTC

[GitHub] [shardingsphere] FlyingZC opened a new pull request, #24014: Reduce the number of readwrite-splitting algorithms(#23974)

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

   For #23974.
   
   Changes proposed in this pull request:
     - Add `TransactionReadQueryStrategyAware` interface to reduce the repetitive logic in readwrite-splitting algorithms
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [x] I have self-reviewed the commit code.
   - [x] I have (or in comment I request) added corresponding labels for the pull request.
   - [x] 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.
   - [x] 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] codecov-commenter commented on pull request #24014: Reduce the number of readwrite-splitting algorithms(#23974)

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #24014:
URL: https://github.com/apache/shardingsphere/pull/24014#issuecomment-1418482699

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/24014?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 [#24014](https://codecov.io/gh/apache/shardingsphere/pull/24014?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (87ca050) into [master](https://codecov.io/gh/apache/shardingsphere/commit/946080bc60610bec379b52b07de6a25842977fc2?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (946080b) will **decrease** coverage by `0.06%`.
   > The diff coverage is `81.25%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #24014      +/-   ##
   ============================================
   - Coverage     50.07%   50.01%   -0.06%     
   + Complexity     1562     1560       -2     
   ============================================
     Files          3238     3238              
     Lines         53246    53143     -103     
     Branches       9798     9775      -23     
   ============================================
   - Hits          26662    26579      -83     
   + Misses        24232    24224       -8     
   + Partials       2352     2340      -12     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/24014?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../api/transaction/TransactionReadQueryStrategy.java](https://codecov.io/gh/apache/shardingsphere/pull/24014?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvcmVhZHdyaXRlLXNwbGl0dGluZy9hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3JlYWR3cml0ZXNwbGl0dGluZy9hcGkvdHJhbnNhY3Rpb24vVHJhbnNhY3Rpb25SZWFkUXVlcnlTdHJhdGVneS5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...transaction/TransactionReadQueryStrategyAware.java](https://codecov.io/gh/apache/shardingsphere/pull/24014?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvcmVhZHdyaXRlLXNwbGl0dGluZy9hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3JlYWR3cml0ZXNwbGl0dGluZy9hcGkvdHJhbnNhY3Rpb24vVHJhbnNhY3Rpb25SZWFkUXVlcnlTdHJhdGVneUF3YXJlLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...er/ReadwriteSplittingRuleConfigurationChecker.java](https://codecov.io/gh/apache/shardingsphere/pull/24014?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvcmVhZHdyaXRlLXNwbGl0dGluZy9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9yZWFkd3JpdGVzcGxpdHRpbmcvY2hlY2tlci9SZWFkd3JpdGVTcGxpdHRpbmdSdWxlQ29uZmlndXJhdGlvbkNoZWNrZXIuamF2YQ==) | `52.77% <25.00%> (ø)` | |
   | [...adbalance/RandomReadQueryLoadBalanceAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/24014?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvcmVhZHdyaXRlLXNwbGl0dGluZy9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9yZWFkd3JpdGVzcGxpdHRpbmcvYWxnb3JpdGhtL2xvYWRiYWxhbmNlL1JhbmRvbVJlYWRRdWVyeUxvYWRCYWxhbmNlQWxnb3JpdGhtLmphdmE=) | `100.00% <100.00%> (ø)` | |
   | [...lance/RoundRobinReadQueryLoadBalanceAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/24014?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvcmVhZHdyaXRlLXNwbGl0dGluZy9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9yZWFkd3JpdGVzcGxpdHRpbmcvYWxnb3JpdGhtL2xvYWRiYWxhbmNlL1JvdW5kUm9iaW5SZWFkUXVlcnlMb2FkQmFsYW5jZUFsZ29yaXRobS5qYXZh) | `100.00% <100.00%> (ø)` | |
   | [...adbalance/WeightReadQueryLoadBalanceAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/24014?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvcmVhZHdyaXRlLXNwbGl0dGluZy9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9yZWFkd3JpdGVzcGxpdHRpbmcvYWxnb3JpdGhtL2xvYWRiYWxhbmNlL1dlaWdodFJlYWRRdWVyeUxvYWRCYWxhbmNlQWxnb3JpdGhtLmphdmE=) | `76.78% <100.00%> (+2.27%)` | :arrow_up: |
   | [...handler/distsql/ral/hint/enums/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/24014?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: |
   | [...single/metadata/SingleSchemaMetaDataDecorator.java](https://codecov.io/gh/apache/shardingsphere/pull/24014?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL3NpbmdsZS9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaW5nbGUvbWV0YWRhdGEvU2luZ2xlU2NoZW1hTWV0YURhdGFEZWNvcmF0b3IuamF2YQ==) | `100.00% <0.00%> (ø)` | |
   | [...e/schema/decorator/reviser/ColumnReviseEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/24014?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5mcmEvY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9kYXRhYmFzZS9zY2hlbWEvZGVjb3JhdG9yL3JldmlzZXIvQ29sdW1uUmV2aXNlRW5naW5lLmphdmE=) | | |
   | [...se/schema/decorator/reviser/ColumnNameReviser.java](https://codecov.io/gh/apache/shardingsphere/pull/24014?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5mcmEvY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9kYXRhYmFzZS9zY2hlbWEvZGVjb3JhdG9yL3JldmlzZXIvQ29sdW1uTmFtZVJldmlzZXIuamF2YQ==) | | |
   | ... and [8 more](https://codecov.io/gh/apache/shardingsphere/pull/24014?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] strongduanmu commented on a diff in pull request #24014: Reduce the number of readwrite-splitting algorithms(#23974)

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on code in PR #24014:
URL: https://github.com/apache/shardingsphere/pull/24014#discussion_r1097014887


##########
features/readwrite-splitting/api/src/main/java/org/apache/shardingsphere/readwritesplitting/api/transaction/TransactionReadQueryStrategyAware.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.readwritesplitting.api.transaction;
+
+import org.apache.shardingsphere.infra.context.transaction.TransactionConnectionContext;
+
+import java.util.List;
+
+/**
+ * Transaction read query strategy aware.
+ */
+public interface TransactionReadQueryStrategyAware {
+    
+    String TRANSACTION_READ_QUERY_STRATEGY = "transactionReadQueryStrategy";
+    
+    /**
+     * Get data source name in transaction.
+     *
+     * @param name read query logic data source name
+     * @param writeDataSourceName name of write data source
+     * @param readDataSourceNames names of read data sources
+     * @param context context
+     * @param transactionReadQueryStrategy read query strategy in transaction
+     * @return name of selected data source
+     */
+    default String routeInTransaction(final String name, final String writeDataSourceName, final List<String> readDataSourceNames,

Review Comment:
   Can we move this logic to util class?



-- 
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] strongduanmu merged pull request #24014: Reduce the number of readwrite-splitting algorithms(#23974)

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu merged PR #24014:
URL: https://github.com/apache/shardingsphere/pull/24014


-- 
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] FlyingZC commented on a diff in pull request #24014: Reduce the number of readwrite-splitting algorithms(#23974)

Posted by "FlyingZC (via GitHub)" <gi...@apache.org>.
FlyingZC commented on code in PR #24014:
URL: https://github.com/apache/shardingsphere/pull/24014#discussion_r1097116523


##########
features/readwrite-splitting/api/src/main/java/org/apache/shardingsphere/readwritesplitting/api/transaction/TransactionReadQueryStrategyAware.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.readwritesplitting.api.transaction;
+
+import org.apache.shardingsphere.infra.context.transaction.TransactionConnectionContext;
+
+import java.util.List;
+
+/**
+ * Transaction read query strategy aware.
+ */
+public interface TransactionReadQueryStrategyAware {
+    
+    String TRANSACTION_READ_QUERY_STRATEGY = "transactionReadQueryStrategy";
+    
+    /**
+     * Get data source name in transaction.
+     *
+     * @param name read query logic data source name
+     * @param writeDataSourceName name of write data source
+     * @param readDataSourceNames names of read data sources
+     * @param context context
+     * @param transactionReadQueryStrategy read query strategy in transaction
+     * @return name of selected data source
+     */
+    default String routeInTransaction(final String name, final String writeDataSourceName, final List<String> readDataSourceNames,

Review Comment:
   Ok,I will correct this.



-- 
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