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/04/21 10:41:18 UTC
[GitHub] [shardingsphere] joinhappy81 opened a new issue #5252: In version 4.0.1, HintManager getInstance (). SetDatabaseShardingValue () can't use, don't enter DataSourceTypeHintShardingAlgorithm
joinhappy81 opened a new issue #5252:
URL: https://github.com/apache/shardingsphere/issues/5252
In version 4.0.1, HintManager getInstance (). SetDatabaseShardingValue () can't use, don't enter DataSourceTypeHintShardingAlgorithm,I just want to switch database, not tables
m1: !!org.apache.shardingsphere.orchestration.yaml.config.YamlDataSourceConfiguration
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
properties:
driverClassName: com.mysql.cj.jdbc.Driver
jdbcUrl: jdbc:mysql://127.0.0.1:3306/order_db_1?useSSL=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true&serverTimezone=GMT
username: root
password: admin888
connectionTimeout: 30000
minimumIdle: 5
maximumPoolSize: 15
idleTimeout: 30000
maxLifetime: 120000
autoCommit: true
m2: !!org.apache.shardingsphere.orchestration.yaml.config.YamlDataSourceConfiguration
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
properties:
driverClassName: com.mysql.cj.jdbc.Driver
jdbcUrl: jdbc:mysql://127.0.0.1:3306/order_db_2?useSSL=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true&serverTimezone=GMT
username: root
password: admin888
connectionTimeout: 30000
minimumIdle: 5
maximumPoolSize: 15
idleTimeout: 30000
maxLifetime: 120000
autoCommit: true
config:
sharding:
defaultDatabaseStrategy:
hint:
algorithmClassName: cn.com.hatech.sharding.config.DataSourceTypeHintShardingAlgorithm
public class DataSourceTypeHintShardingAlgorithm implements HintShardingAlgorithm<String> {
@Override
public Collection<String> doSharding(Collection<String> availableTargetNames, HintShardingValue<String> shardingValue) {
if (!CollectionUtils.isEmpty(shardingValue.getValues())) {
log.info("当前所选择的数据源是:{}",shardingValue.getValues());
return availableTargetNames.stream().filter(availableTargetName ->
shardingValue.getValues().contains(availableTargetName)).collect(Collectors.toList());
}
return 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
[GitHub] [shardingsphere] kimmking commented on issue #5252: In version 4.0.1, HintManager getInstance (). SetDatabaseShardingValue () can't use, don't enter DataSourceTypeHintShardingAlgorithm
Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #5252:
URL: https://github.com/apache/shardingsphere/issues/5252#issuecomment-617481322
what's your sql??
----------------------------------------------------------------
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
[GitHub] [shardingsphere] joinhappy81 commented on issue #5252: In version 4.0.1, HintManager getInstance (). SetDatabaseShardingValue () can't use, don't enter DataSourceTypeHintShardingAlgorithm
Posted by GitBox <gi...@apache.org>.
joinhappy81 commented on issue #5252:
URL: https://github.com/apache/shardingsphere/issues/5252#issuecomment-617724475
but in the vestion 4.0.0-RC2 can executed sharding algorithm
first, use 'HintManager getInstance (). SetDatabaseShardingValue ("m1") ' switch the m1 datasource
second, executed the sql ‘select * from user’
----------------------------------------------------------------
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
[GitHub] [shardingsphere] kimmking commented on issue #5252: In version 4.0.1, HintManager getInstance (). SetDatabaseShardingValue () can't use, don't enter DataSourceTypeHintShardingAlgorithm
Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #5252:
URL: https://github.com/apache/shardingsphere/issues/5252#issuecomment-617825088
Duplicated with #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
[GitHub] [shardingsphere] kimmking commented on issue #5252: In version 4.0.1, HintManager getInstance (). SetDatabaseShardingValue () can't use, don't enter DataSourceTypeHintShardingAlgorithm
Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #5252:
URL: https://github.com/apache/shardingsphere/issues/5252#issuecomment-617570782
‘select * from user’ hasn't any sharding key, so sharding algorithm is not executed.
----------------------------------------------------------------
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
[GitHub] [shardingsphere] kimmking commented on issue #5252: In version 4.0.1, HintManager getInstance (). SetDatabaseShardingValue () can't use, don't enter DataSourceTypeHintShardingAlgorithm
Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #5252:
URL: https://github.com/apache/shardingsphere/issues/5252#issuecomment-617824872
@joinhappy81 OK, I know now.
It's a bug of empty table rules, and will being fix in a new 4.1.0 version, that will be released this week.
----------------------------------------------------------------
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
[GitHub] [shardingsphere] joinhappy81 commented on issue #5252: In version 4.0.1, HintManager getInstance (). SetDatabaseShardingValue () can't use, don't enter DataSourceTypeHintShardingAlgorithm
Posted by GitBox <gi...@apache.org>.
joinhappy81 commented on issue #5252:
URL: https://github.com/apache/shardingsphere/issues/5252#issuecomment-617733230
I think my question is the same as the following
https://github.com/apache/shardingsphere/issues/3964
Is this a bug? When will it be fixed? Is there a solution in the current environment (version 4.0.1)?
----------------------------------------------------------------
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
[GitHub] [shardingsphere] joinhappy81 commented on issue #5252: In version 4.0.1, HintManager getInstance (). SetDatabaseShardingValue () can't use, don't enter DataSourceTypeHintShardingAlgorithm
Posted by GitBox <gi...@apache.org>.
joinhappy81 commented on issue #5252:
URL: https://github.com/apache/shardingsphere/issues/5252#issuecomment-617499156
in the m1,m2 has a table
CREATE TABLE `user` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`username` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '用户名',
`password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '密码',
`datasource_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '数据源信息ID',
`create_time` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
`type` smallint(4) NULL DEFAULT NULL COMMENT '用户类型 1:租户 2:普通用户',
`status` smallint(4) NULL DEFAULT NULL COMMENT '用户状态 1:正常 0:删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户' ROW_FORMAT = Dynamic;
the sql is: select * from user
I want HintManager getInstance (). SetDatabaseShardingValue ("m1") switch m1 and HintManager getInstance (). SetDatabaseShardingValue ("m2") switch m2
----------------------------------------------------------------
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