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/10/11 10:31:28 UTC

[GitHub] [shardingsphere] huang714669 opened a new issue, #21503: Springboot how to set acutualDataNodes dynamically

huang714669 opened a new issue, #21503:
URL: https://github.com/apache/shardingsphere/issues/21503

   hi,
   I am using Sharding-JDBC with a version 5.1.2, and I am wondering if it supports to update actualDataNodes runtime in springboot, if does, how to do 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.apache.org

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


[GitHub] [shardingsphere] linghengqian commented on issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #21503:
URL: https://github.com/apache/shardingsphere/issues/21503#issuecomment-1275514291

   - The `actualDataNodes` and `shardingAlgorithm` are not at the same level. In order to serve DistSQL, each version of `ContextManager` has been refactored and abstracted to a certain extent. This is why you will find out why unit tests of DistSQL hardly touch `ContextManager`.  `actualDataNodes` is essentially a `Groovy` expression. If you don't like `Groovy`, you can directly construct an `ArrayList` and convert it to a string.  
   
   - I'm just assuming you can translate the above reply into `English`, because that's inconvenient for others to search for this 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.

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

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


[GitHub] [shardingsphere] huang714669 commented on issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
huang714669 commented on issue #21503:
URL: https://github.com/apache/shardingsphere/issues/21503#issuecomment-1275455062

   thankyou lingheng, could you please tell me how to get shardingRule by ContextManager, so I can modify actualDataNodes 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.

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 issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #21503:
URL: https://github.com/apache/shardingsphere/issues/21503#issuecomment-1284380024

   - FYI, this article is now published at https://github.com/apache/shardingsphere/discussions/12258#discussioncomment-3917927. Hope my essay will help you.


-- 
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] huang714669 commented on issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
huang714669 commented on issue #21503:
URL: https://github.com/apache/shardingsphere/issues/21503#issuecomment-1275500869

   多谢,期待你的博客?请问ContextManager测试用例哪里能看到?
   如果改actualDataNodes,是不是contextManager.metaDataContexts.metaData里面configurations.actualDataNodes和tableRules.actualDataNodes都需要修改?
   tableRules.actualDataNodes是集合,可以直接添加。
   configurations.actualDataNodes是字符串,如果表后缀不是非连续的数字,怎么构造这个字符串?


-- 
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 issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #21503:
URL: https://github.com/apache/shardingsphere/issues/21503#issuecomment-1277460142

   - I'm not a Committer, you can close this issue directly, and some friends will regularly check the closed issue and mark it as issue. I'm really working on that new article, but I really can't get it out that fast, the ShardingSphere 5.2.1 milestone closes tomorrow, and I still have a few TODO lists on hand that are related or not. 


-- 
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] huang714669 closed issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
huang714669 closed issue #21503: Springboot how to set acutualDataNodes dynamically
URL: https://github.com/apache/shardingsphere/issues/21503


-- 
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 issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #21503:
URL: https://github.com/apache/shardingsphere/issues/21503#issuecomment-1274612701

   -  Your question is duplicated by https://github.com/apache/shardingsphere/issues/21492 and is essentially a type of problem. Closed issues have many such issues.
   - If you don't use DistSQL, you can directly modify the internal metadata of the data source's `ContextManager`, change it at will, and call methods to refresh the metadata. For this section, you can directly refer to DistSQL unit testing and writing DistSQL articles. I do have some journal posts detailing the process, but unfortunately it's not in English and can't give you a reference.


-- 
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] huang714669 commented on issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
huang714669 commented on issue #21503:
URL: https://github.com/apache/shardingsphere/issues/21503#issuecomment-1275548544

   update the among message to english?
   I have updated actualDataNodes both in `configurations.actualDataNodes` and `tableRules.actualDataNodes`, by use  reflection to update the ContextManager successfully. But when execute doSharding() method, it seems the availableTargetNames still be the old value, so this  is because  `shardingAlgorithm` will not use the config in `ContextManager`?
   
   Does shardingshpere provide a more automic way to generate tables if not exsits?In this way, we can do sharding without config `actualDataNodes `; shardingsphere will help to generate accordingly table if it not created


-- 
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] huang714669 commented on issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
huang714669 commented on issue #21503:
URL: https://github.com/apache/shardingsphere/issues/21503#issuecomment-1275505545

   还有个问题,我实现了StandardShardingAlgorithm实现自定义sharding算法,如果通过springboot定时任务刷新contextManager,doSharding()方法里面可以拿到最新的actualDataNodes吗?


-- 
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] huang714669 commented on issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
huang714669 commented on issue #21503:
URL: https://github.com/apache/shardingsphere/issues/21503#issuecomment-1277455651

   thank you! it's clear to me now, please kindly close this ticket!


-- 
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 issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #21503:
URL: https://github.com/apache/shardingsphere/issues/21503#issuecomment-1275481450

   - I just assume you can understand Chinese.  I will organize an integrated blog post and publish it in https://github.com/apache/shardingsphere/discussions/12258 in the next few days.  For how to get the ShardingRule, you can refer to all the unit tests related to `ContextManager`. After taking out the `ContextManager` instance through reflection, you can limit the scope of the taken out Rule through different methods.


-- 
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 issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #21503:
URL: https://github.com/apache/shardingsphere/issues/21503#issuecomment-1275555937

   - `shardingAlgorithm` will use the metadata of `ContextManager`, but you have to consider that it is easy to have a little misunderstanding, all algorithm classes should be `final classes` or close to `final classes` in design.  This means that if you directly return the `shardingAlgorithm` class of the original metadata to the new metadata class, the `init()` function commonly used by subinterfaces of `shardingAlgorithm` will not be called.  This means that you need to manually build a new `shardingAlgorithm` and explicitly call the `init()` function to initialize some of the internal properties you need.  This is actually the underlying manifestation of `ShardingSphere JDBC`, and this step is handled by another listener when `DistSQL` is executed.  
   
   - This is indeed a big black box, because each version of the `ContextManager` is designed a little differently. 🤣


-- 
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] huang714669 commented on issue #21503: Springboot how to set acutualDataNodes dynamically

Posted by GitBox <gi...@apache.org>.
huang714669 commented on issue #21503:
URL: https://github.com/apache/shardingsphere/issues/21503#issuecomment-1277472042

   very appreciate!


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