-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why must actualDataNodes be specified? Some requirements are to add dynamic special characters to the basic table name. #32734
Comments
|
rules:
- !SHARDING
tables:
t_order_mysql:
actualDataNodes: <MYSQL>'localhost:3306', 'test_database', 'my_user', 'user_password'
t_order_postgresql:
actualDataNodes: <POSTGRESQL>'postgres1:5432', 'test_database', 'postgres', 'mysecretpassword', 'schema_name', 1
t_order_sqlite:
actualDataNodes: <SQLITE>'sqlite.db'
t_order_hdfs:
actualDataNodes: <HDFS>'hdfs://hdfs1:9000/data/path/test', 'name String' |
This is what I call a rabbit hole. A more humorous external unit test is in #32591. ShardingSphere relies on the sharding algorithm to resolve the physical table name from the logical table name, even if the actual-data-nodes do not explicitly list all tables. This is a humorous rabbit hole, and I don't see what needs to be done to plug the rabbit hole. |
可是我就是要分片算法从逻辑表名直接分析物理表名,即使没有在actual-data-nodes指定, 但是我这里这样的话,会显示表名不存在。 但是如果我在actual-data-nodes指定的话(但是我无法全部指定,因为我是动态的,数据量大的,不可能加载到这里面,容易oom),才可以继续执行。 |
|
Main方法` public static void main(String[] args) throws SQLException { // HikariDataSource dataSource2 = new HikariDataSource();
} private static ShardingTableRuleConfiguration chargeReceivableRuleConfig() { 分库算法(其实只有库,直接外部传入,相当于直接写死)`public class AplDefaultDatabaseShardingAlgorithm implements private String databaseName; public void init(Properties properties) { @OverRide @OverRide @OverRide 分表算法 (基础表名+租户ID对应的租户Code)`public class OrgParamStandardShardingAlgorithm implements StandardShardingAlgorithm<Comparable<?>> { public void init(Properties properties) { @OverRide @OverRide OrgUtils`public class OrgUtils { public static String getOrgCode(Long orgId) { 由于Main方法没有指定 actualDataNodes(租户ID无法精确指定,需要从sql分片键中动态获取,并且每个租户id都有一个相对应的表),出现如下错误
sharding-jdbc的版本
这种情况我该如何做到不指定actual-data-nodes,能够正常运行 |
|
|
就最开始我想要不指定acutal-data-nodes,随着发现,可以最开始乱指定一个,然后通过自定义分片算法 doSharding方法,动态生成的表名add到入参1集合里面(该集合是一个LinkedhashSet),然后就可以绕过你们的判断(判断dosharding返回的表名是否在你们的入参1集合里面),如果这个集合设定可修改的,那你们为什么要进行判定(我没有去看你们的源码,只是猜测)? |
|
|
|
For English only, other languages will not accept. |
|
For example, xxx_orgCode, orgCode is an unpredictable or indeterminate number.
The text was updated successfully, but these errors were encountered: