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 2020/01/14 05:33:36 UTC

[GitHub] [incubator-shardingsphere] tmjGitAccount opened a new issue #3964: Hintmanager databaseShardingOnly problem

tmjGitAccount opened a new issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964
 
 
   ## Bug Report
   
   Please answer these questions before submitting your issue. Thanks!
   ### Which version of ShardingSphere did you use?
   **4.0.0**
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   Sharding-JDBC
   ### Expected behavior
   i can hint databases with sth outside my database, for example , i want to get the hint key from my http header ,then route by the key.
   ### Actual behavior
   it route to all my datasources
   ### Reason analyze (If you can)
   maybe the hintmanager has wrong code 
   
   this code is in hintmanager,i use **setDatabaseShardingValue** method to config my shardkey,
   here, it put an empty key for the sharding values. 
   ***
   public void setDatabaseShardingValue(final Comparable<?> value) {
           databaseShardingValues.clear();
           tableShardingValues.clear();
           databaseShardingValues.put("", value);
           databaseShardingOnly = true;
       }
   ***
   but when i followed it in the **getDatabaseShardingValues** method, it gets the shardingValues
   by the logicTable, so I can not get the shardingvalues which i configed.
   ***
       public static Collection<Comparable<?>> getDatabaseShardingValues(final String logicTable) {
           return null == HINT_MANAGER_HOLDER.get() ? Collections.<Comparable<?>>emptyList() : HINT_MANAGER_HOLDER.get().databaseShardingValues.get(logicTable);
       }
   ***
   
   then  in the **routeDataSources** method of  **StandardRoutingEngine** 
   ***
   private Collection<String> routeDataSources(final TableRule tableRule, final List<RouteValue> databaseShardingValues) {
           if (databaseShardingValues.isEmpty()) {
               return tableRule.getActualDatasourceNames();
           }
           Collection<String> result = new LinkedHashSet<>(shardingRule.getDatabaseShardingStrategy(tableRule).doSharding(tableRule.getActualDatasourceNames(), databaseShardingValues));
           Preconditions.checkState(!result.isEmpty(), "no database route info");
           Preconditions.checkState(tableRule.getActualDatasourceNames().containsAll(result), 
                   "Some routed data sources do not belong to configured data sources. routed data sources: `%s`, configured data sources: `%s`", result, tableRule.getActualDatasourceNames());
           return result;
       }
   ***
   the databaseShardingValues is empty , so it returns all the actualDatasources, not only the datasource i conifged.
   
   could you please provide an example for this situation?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] darcydai commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
darcydai commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-575922419
 
 
   > maybe I have the same problem, in my case (springboot), I configuration is
   > 
   > ```
   > spring.shardingsphere.datasource.names=house,shenyang,beijing
   > 
   > spring.shardingsphere.datasource.house.type=com.zaxxer.hikari.HikariDataSource
   > spring.shardingsphere.datasource.house.driver-class-name=com.mysql.jdbc.Driver
   > spring.shardingsphere.datasource.house.jdbc-url=jdbc:mysql://localhost:21010/db_house?useSSL=false&useUnicode=true&characterEncoding=utf8
   > spring.shardingsphere.datasource.house.username=root
   > spring.shardingsphere.datasource.house.password=aA111111
   > 
   > spring.shardingsphere.datasource.shenyang.type=com.zaxxer.hikari.HikariDataSource
   > spring.shardingsphere.datasource.shenyang.driver-class-name=com.mysql.jdbc.Driver
   > spring.shardingsphere.datasource.shenyang.jdbc-url=jdbc:mysql://localhost:21010/db_shenyang?useSSL=false&useUnicode=true&characterEncoding=utf8
   > spring.shardingsphere.datasource.shenyang.username=root
   > spring.shardingsphere.datasource.shenyang.password=aA111111
   > 
   > spring.shardingsphere.datasource.beijing.type=com.zaxxer.hikari.HikariDataSource
   > spring.shardingsphere.datasource.beijing.driver-class-name=com.mysql.jdbc.Driver
   > spring.shardingsphere.datasource.beijing.jdbc-url=jdbc:mysql://localhost:21010/db_beijing?useSSL=false&useUnicode=true&characterEncoding=utf8
   > spring.shardingsphere.datasource.beijing.username=root
   > spring.shardingsphere.datasource.beijing.password=aA111111
   > spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.mh.house.sharding.CityBaseHintShardingAlgorithm
   > ```
   > 
   > but the method trace never enters my defined CityBaseHintShardingAlgorithm.
   
   and version is 4.0.0

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-574584713
 
 
   @tmjGitAccount , Can you provide your full sharding configuration?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-581716825
 
 
   @tmjGitAccount @darcydai 
   
   Can you provide your SQL and algorithm 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-581717998
 
 
   > @KomachiSion
   > 
   > ```yaml
   > spring:
   >   shardingsphere:
   >     props:
   >       sql:
   >         show: true
   >     sharding:
   >       default-database-strategy:
   >         hint:
   >           algorithm-class-name: com.a.b.c.OrderShardingAlgorithm
   >     datasource:
   >       names: dsa,dsb
   >       dsa:
   >         pool-name: dsa
   >         type: com.zaxxer.hikari.HikariDataSource
   >         driverClassName: com.mysql.jdbc.Driver
   >         jdbcUrl: xxx
   >         username: xxx
   >         password: xxx
   >       dsb:
   >         pool-name: dsb
   >         type: com.zaxxer.hikari.HikariDataSource
   >         driverClassName: com.mysql.jdbc.Driver
   >         jdbcUrl: xxx
   >         username: xxx
   >         password: xxx
   > ```
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] tmjGitAccount commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
tmjGitAccount commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-584456807
 
 
   > @tmjGitAccount @darcydai
   > I try to reproduce problem by configuration you provided, and I found that there are no `tableRule` so that ShardingSphere use unicast routing instead of hint routing. May you provide more information makes me reproduce problem?
   > 
   > If no more response, I will close this issue and think this is a usage issue
   
   add this config may reproduce ?
   default-table-strategy:
           hint:
             algorithm-class-name: com.a.b.c.OrderShardingAlgorithm
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] darcydai commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
darcydai commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-575922280
 
 
   maybe I have the same problem, in my case (springboot), I configuration is
   
   ```
   spring.shardingsphere.datasource.names=house,shenyang,beijing
   
   spring.shardingsphere.datasource.house.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.house.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.house.jdbc-url=jdbc:mysql://localhost:21010/db_house?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.house.username=root
   spring.shardingsphere.datasource.house.password=aA111111
   
   spring.shardingsphere.datasource.shenyang.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.shenyang.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.shenyang.jdbc-url=jdbc:mysql://localhost:21010/db_shenyang?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.shenyang.username=root
   spring.shardingsphere.datasource.shenyang.password=aA111111
   
   spring.shardingsphere.datasource.beijing.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.beijing.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.beijing.jdbc-url=jdbc:mysql://localhost:21010/db_beijing?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.beijing.username=root
   spring.shardingsphere.datasource.beijing.password=aA111111
   spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.mh.house.sharding.CityBaseHintShardingAlgorithm
   ```
   
   but the method trace never enters my defined  CityBaseHintShardingAlgorithm.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] darcydai commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
darcydai commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-575921675
 
 
   maybe I have the same problem, in my case , I configuration is 
    `spring.shardingsphere.datasource.names=house,shenyang,beijing
   
   spring.shardingsphere.datasource.house.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.house.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.house.jdbc-url=jdbc:mysql://localhost:21010/db_house?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.house.username=root
   spring.shardingsphere.datasource.house.password=aA111111
   
   spring.shardingsphere.datasource.shenyang.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.shenyang.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.shenyang.jdbc-url=jdbc:mysql://localhost:21010/db_shenyang?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.shenyang.username=root
   spring.shardingsphere.datasource.shenyang.password=aA111111
   
   spring.shardingsphere.datasource.beijing.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.beijing.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.beijing.jdbc-url=jdbc:mysql://localhost:21010/db_beijing?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.beijing.username=root
   spring.shardingsphere.datasource.beijing.password=aA111111
   spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.mh.house.sharding.CityBaseHintShardingAlgorithm
   `  
   
   but the method trace never enters my defined HintShardingAlgorithm ->CityBaseHintShardingAlgorithm.
   
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] tmjGitAccount opened a new issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
tmjGitAccount opened a new issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964
 
 
   ## Bug Report
   
   Please answer these questions before submitting your issue. Thanks!
   ### Which version of ShardingSphere did you use?
   **4.0.0**
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   Sharding-JDBC
   ### Expected behavior
   i can hint databases with sth outside my database, for example , i want to get the hint key from my http header ,then route by the key.
   ### Actual behavior
   it route to all my datasources
   ### Reason analyze (If you can)
   maybe the hintmanager has wrong code 
   
   this code is in hintmanager,i use **setDatabaseShardingValue** method to config my shardkey,
   here, it put an empty key for the sharding values. 
   
   ***
       public void setDatabaseShardingValue(final Comparable<?> value) {
           databaseShardingValues.clear();
           tableShardingValues.clear();
           databaseShardingValues.put("", value);
           databaseShardingOnly = true;
       }
   ***
   but when i followed it in the **getDatabaseShardingValues** method, it gets the shardingValues
   by the logicTable, so I can not get the shardingvalues which i configed.
   
   ***
       public static Collection<Comparable<?>> getDatabaseShardingValues(final String logicTable) {
           return null == HINT_MANAGER_HOLDER.get() ? Collections.<Comparable<?>>emptyList() : HINT_MANAGER_HOLDER.get().databaseShardingValues.get(logicTable);
       }
   ***
   
   then  in the **routeDataSources** method of  **StandardRoutingEngine** 
   
   ***
       private Collection<String> routeDataSources(final TableRule tableRule, final List<RouteValue> databaseShardingValues) {
           if (databaseShardingValues.isEmpty()) {
               return tableRule.getActualDatasourceNames();
           }
           Collection<String> result = new LinkedHashSet<>(shardingRule.getDatabaseShardingStrategy(tableRule).doSharding(tableRule.getActualDatasourceNames(), databaseShardingValues));
           Preconditions.checkState(!result.isEmpty(), "no database route info");
           Preconditions.checkState(tableRule.getActualDatasourceNames().containsAll(result), 
                   "Some routed data sources do not belong to configured data sources. routed data sources: `%s`, configured data sources: `%s`", result, tableRule.getActualDatasourceNames());
           return result;
       }
   ***
   the databaseShardingValues is empty , so it returns all the actualDatasources, not only the datasource i conifged.
   
   could you please provide an example for this situation?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] terrymanu closed issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-584441115
 
 
   @tmjGitAccount @darcydai 
   I try to reproduce problem by configuration you provided, and I found that there are no `tableRule` so that ShardingSphere use unicast routing instead of hint routing. May you provide more information makes me reproduce problem?
   
   If no more response, I will close this issue and think this is a usage issue

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] darcydai commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
darcydai commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-575921857
 
 
   maybe I have the same problem, in my case , I configuration is
   
   `  
   spring.shardingsphere.datasource.names=house,shenyang,beijing
   
   spring.shardingsphere.datasource.house.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.house.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.house.jdbc-url=jdbc:mysql://localhost:21010/db_house?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.house.username=root
   spring.shardingsphere.datasource.house.password=aA111111
   
   spring.shardingsphere.datasource.shenyang.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.shenyang.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.shenyang.jdbc-url=jdbc:mysql://localhost:21010/db_shenyang?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.shenyang.username=root
   spring.shardingsphere.datasource.shenyang.password=aA111111
   
   spring.shardingsphere.datasource.beijing.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.beijing.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.beijing.jdbc-url=jdbc:mysql://localhost:21010/db_beijing?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.beijing.username=root
   spring.shardingsphere.datasource.beijing.password=aA111111
   spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.mh.house.sharding.CityBaseHintShardingAlgorithm  
   `
   but the method trace never enters my defined HintShardingAlgorithm ->CityBaseHintShardingAlgorithm.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] tmjGitAccount commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
tmjGitAccount commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-574947233
 
 
   @KomachiSion 
   
   spring:
     shardingsphere:
       props:
         sql:
           show: true
       sharding:
         default-database-strategy:
           hint:
             algorithm-class-name: com.a.b.c.OrderShardingAlgorithm
       datasource:
         names: dsa,dsb
         dsa:
           pool-name: dsa
           type: com.zaxxer.hikari.HikariDataSource
           driverClassName: com.mysql.jdbc.Driver
           jdbcUrl: xxx
           username: xxx
           password: xxx
         dsb:
           pool-name: dsb
           type: com.zaxxer.hikari.HikariDataSource
           driverClassName: com.mysql.jdbc.Driver
           jdbcUrl: xxx
           username: xxx
           password: xxx
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion edited a comment on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
KomachiSion edited a comment on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-581717998
 
 
   > @KomachiSion
   > 
   > ```yaml
   > spring:
   >   shardingsphere:
   >     props:
   >       sql:
   >         show: true
   >     sharding:
   >       default-database-strategy:
   >         hint:
   >           algorithm-class-name: com.a.b.c.OrderShardingAlgorithm
   >     datasource:
   >       names: dsa,dsb
   >       dsa:
   >         pool-name: dsa
   >         type: com.zaxxer.hikari.HikariDataSource
   >         driverClassName: com.mysql.jdbc.Driver
   >         jdbcUrl: xxx
   >         username: xxx
   >         password: xxx
   >       dsb:
   >         pool-name: dsb
   >         type: com.zaxxer.hikari.HikariDataSource
   >         driverClassName: com.mysql.jdbc.Driver
   >         jdbcUrl: xxx
   >         username: xxx
   >         password: xxx
   > ```
   
   Did you shard tables? If no sharding table info, the routing will use Unicast routing.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] darcydai removed a comment on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
darcydai removed a comment on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-575921776
 
 
   maybe I have the same problem, in my case , I configuration is
   
   `spring.shardingsphere.datasource.names=house,shenyang,beijing
   
   spring.shardingsphere.datasource.house.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.house.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.house.jdbc-url=jdbc:mysql://localhost:21010/db_house?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.house.username=root
   spring.shardingsphere.datasource.house.password=aA111111
   
   spring.shardingsphere.datasource.shenyang.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.shenyang.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.shenyang.jdbc-url=jdbc:mysql://localhost:21010/db_shenyang?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.shenyang.username=root
   spring.shardingsphere.datasource.shenyang.password=aA111111
   
   spring.shardingsphere.datasource.beijing.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.beijing.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.beijing.jdbc-url=jdbc:mysql://localhost:21010/db_beijing?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.beijing.username=root
   spring.shardingsphere.datasource.beijing.password=aA111111
   spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.mh.house.sharding.CityBaseHintShardingAlgorithm`
   but the method trace never enters my defined HintShardingAlgorithm ->CityBaseHintShardingAlgorithm.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] darcydai commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
darcydai commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-575921776
 
 
   maybe I have the same problem, in my case , I configuration is
   
   `spring.shardingsphere.datasource.names=house,shenyang,beijing
   
   spring.shardingsphere.datasource.house.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.house.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.house.jdbc-url=jdbc:mysql://localhost:21010/db_house?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.house.username=root
   spring.shardingsphere.datasource.house.password=aA111111
   
   spring.shardingsphere.datasource.shenyang.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.shenyang.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.shenyang.jdbc-url=jdbc:mysql://localhost:21010/db_shenyang?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.shenyang.username=root
   spring.shardingsphere.datasource.shenyang.password=aA111111
   
   spring.shardingsphere.datasource.beijing.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.beijing.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.beijing.jdbc-url=jdbc:mysql://localhost:21010/db_beijing?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.beijing.username=root
   spring.shardingsphere.datasource.beijing.password=aA111111
   spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.mh.house.sharding.CityBaseHintShardingAlgorithm`
   but the method trace never enters my defined HintShardingAlgorithm ->CityBaseHintShardingAlgorithm.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] tmjGitAccount edited a comment on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
tmjGitAccount edited a comment on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-574947233
 
 
   @KomachiSion 
   
   ```yaml
   spring:
     shardingsphere:
       props:
         sql:
           show: true
       sharding:
         default-database-strategy:
           hint:
             algorithm-class-name: com.a.b.c.OrderShardingAlgorithm
       datasource:
         names: dsa,dsb
         dsa:
           pool-name: dsa
           type: com.zaxxer.hikari.HikariDataSource
           driverClassName: com.mysql.jdbc.Driver
           jdbcUrl: xxx
           username: xxx
           password: xxx
         dsb:
           pool-name: dsb
           type: com.zaxxer.hikari.HikariDataSource
           driverClassName: com.mysql.jdbc.Driver
           jdbcUrl: xxx
           username: xxx
           password: xxx
   ```
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-584465029
 
 
   @tmjGitAccount I will try again.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] darcydai removed a comment on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
darcydai removed a comment on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-575921857
 
 
   maybe I have the same problem, in my case , I configuration is
   
   `  
   spring.shardingsphere.datasource.names=house,shenyang,beijing
   
   spring.shardingsphere.datasource.house.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.house.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.house.jdbc-url=jdbc:mysql://localhost:21010/db_house?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.house.username=root
   spring.shardingsphere.datasource.house.password=aA111111
   
   spring.shardingsphere.datasource.shenyang.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.shenyang.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.shenyang.jdbc-url=jdbc:mysql://localhost:21010/db_shenyang?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.shenyang.username=root
   spring.shardingsphere.datasource.shenyang.password=aA111111
   
   spring.shardingsphere.datasource.beijing.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.beijing.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.beijing.jdbc-url=jdbc:mysql://localhost:21010/db_beijing?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.beijing.username=root
   spring.shardingsphere.datasource.beijing.password=aA111111
   spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.mh.house.sharding.CityBaseHintShardingAlgorithm  
   `
   but the method trace never enters my defined HintShardingAlgorithm ->CityBaseHintShardingAlgorithm.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] tmjGitAccount commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
tmjGitAccount commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-584464879
 
 
   > I have added, but I don't know your SQLs. I try my SQL, and it still is unicast routing.
   > 
   > So I need your SQLs and `OrderShardingAlgorithm`
   
   Here is my OrderShardingAlorithm.javaļ¼Œthe sql is just a very normal **select * from table**
   All I want is to route to different datasource by different header
   for example 
   1. if the httpheader  agency: a
     i want this sql be excuted in datasource dsa
   2. if the httpheader agency: b
    i want this sql be excuted in datasource dsb
   
   maybe could you please  provide me an example config for the purpose i want ?
   ```
   import lombok.NoArgsConstructor;
   import lombok.extern.slf4j.Slf4j;
   import org.apache.shardingsphere.api.sharding.hint.HintShardingAlgorithm;
   import org.apache.shardingsphere.api.sharding.hint.HintShardingValue;
   import org.springframework.stereotype.Component;
   import org.springframework.web.context.request.RequestAttributes;
   import org.springframework.web.context.request.RequestContextHolder;
   import org.springframework.web.context.request.ServletRequestAttributes;
   
   import javax.servlet.http.HttpServletRequest;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.List;
   import java.util.Optional;
   import java.util.stream.Collectors;
   
   
   @Slf4j
   @NoArgsConstructor
   @Component("orderShardingAlgorithm")
   public class OrderShardingAlgorithm implements HintShardingAlgorithm<String> {
   
       @Override
       public List<String> doSharding(final Collection<String> availableTargetNames, final HintShardingValue<String> shardingValue) {
           RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
           HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
           return Optional.ofNullable(request.getHeader("agency"))
                   .map(value -> availableTargetNames.stream().filter(v -> v.equals(value)).collect(Collectors.toList()))
                   .filter(value -> !value.isEmpty())
                   .orElse(new ArrayList<>(availableTargetNames));
   
       }
   }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-584457098
 
 
   I have added, but I don't know your SQLs. I try my SQL, and it still is unicast routing.
   
   So I need your SQLs and `OrderShardingAlgorithm`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-575500823
 
 
   I have some ideas for this issue.
   I will reproduce and feedback as soon as possible.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] darcydai removed a comment on issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
darcydai removed a comment on issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964#issuecomment-575921675
 
 
   maybe I have the same problem, in my case , I configuration is 
    `spring.shardingsphere.datasource.names=house,shenyang,beijing
   
   spring.shardingsphere.datasource.house.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.house.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.house.jdbc-url=jdbc:mysql://localhost:21010/db_house?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.house.username=root
   spring.shardingsphere.datasource.house.password=aA111111
   
   spring.shardingsphere.datasource.shenyang.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.shenyang.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.shenyang.jdbc-url=jdbc:mysql://localhost:21010/db_shenyang?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.shenyang.username=root
   spring.shardingsphere.datasource.shenyang.password=aA111111
   
   spring.shardingsphere.datasource.beijing.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.beijing.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.beijing.jdbc-url=jdbc:mysql://localhost:21010/db_beijing?useSSL=false&useUnicode=true&characterEncoding=utf8
   spring.shardingsphere.datasource.beijing.username=root
   spring.shardingsphere.datasource.beijing.password=aA111111
   spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.mh.house.sharding.CityBaseHintShardingAlgorithm
   `  
   
   but the method trace never enters my defined HintShardingAlgorithm ->CityBaseHintShardingAlgorithm.
   
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion closed issue #3964: Hintmanager databaseShardingOnly problem

Posted by GitBox <gi...@apache.org>.
KomachiSion closed issue #3964: Hintmanager  databaseShardingOnly problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3964
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services