数据源配到Apollo程序正常运行,但是Apollo中并没有增加相应的配置项。
用了两种 方式 ,但在控制台配置限流后,都没有同步到Apollo中
一种是 :
借助 Sentinel 的 InitFunc SPI 扩展接口。只需要实现自己的 InitFunc 接口,在 init 方法中编写注册数据源的逻辑 运行时日志已显示:
Start 13:35:54.200 [Thread-1] INFO com.ctrip.framework.foundation.internals.provider.DefaultApplicationProvider - App ID is set to d2336a18247739aa by app.id property from System Property 13:35:54.204 [Thread-1] INFO com.ctrip.framework.foundation.internals.provider.DefaultServerProvider - Loading /opt/settings/server.properties 13:35:54.206 [Thread-1] INFO com.ctrip.framework.foundation.internals.provider.DefaultServerProvider - Environment is set to [DEV] by JVM system property 'env'. 13:35:54.206 [Thread-1] INFO com.ctrip.framework.foundation.internals.provider.DefaultServerProvider - Data Center is set to [local] by JVM system property 'idc'. 13:35:54.229 [Thread-1] INFO com.ctrip.framework.apollo.internals.DefaultMetaServerProvider - Located meta services from apollo.meta configuration: http://10.168.100.11:10034! 13:35:54.230 [Thread-1] WARN com.ctrip.framework.apollo.core.utils.ResourceUtils - No available properties: apollo-env.properties 13:35:54.231 [Thread-1] INFO com.ctrip.framework.apollo.core.MetaDomainConsts - Located meta server address http://10.168.100.11:10034 for env DEV from com.ctrip.framework.apollo.internals.DefaultMetaServerProvider End
另一种方式:
创建 ApolloDataSource 并将其注册至对应的 RuleManager 上即可
运行时显示: 13:42:40.323 [main] INFO com.ctrip.framework.foundation.internals.provider.DefaultApplicationProvider - App ID is set to d2336a18247739cd by app.id property from System Property 13:42:40.327 [main] INFO com.ctrip.framework.foundation.internals.provider.DefaultServerProvider - Loading /opt/settings/server.properties 13:42:40.329 [main] INFO com.ctrip.framework.foundation.internals.provider.DefaultServerProvider - Environment is set to [dev] by property 'env' in server.properties. 13:42:40.329 [main] DEBUG com.ctrip.framework.foundation.internals.provider.DefaultServerProvider - Data Center is set to null. Because it is not available in either (1) JVM system property 'idc', (2) OS env variable 'IDC' nor (3) property 'idc' from the properties InputStream. 13:42:40.362 [main] INFO com.ctrip.framework.apollo.internals.DefaultMetaServerProvider - Located meta services from apollo.meta configuration: http://10.168.100.11:10034! 13:42:40.368 [main] WARN com.ctrip.framework.apollo.core.utils.ResourceUtils - No available properties: apollo-env.properties 13:42:40.369 [main] INFO com.ctrip.framework.apollo.core.MetaDomainConsts - Located meta server address http://10.168.100.11:10034 for env DEV from com.ctrip.framework.apollo.internals.DefaultMetaServerProvider 13:42:40.398 [main] DEBUG com.ctrip.framework.apollo.internals.RemoteConfigRepository - Loading config from http://10.168.100.11:10034/configs/d2336a18247739aa/default/application?ip=10.167.3.11 13:42:40.406 [main] DEBUG com.ctrip.framework.apollo.internals.RemoteConfigRepository - Loaded config for application: ApolloConfig{appId='d2336a18247739aa', cluster='default', namespaceName='application', configurations={test.key=test.value}, releaseKey='20190220111333-18b71d03d5d2f0c8'} 13:42:40.407 [main] DEBUG com.ctrip.framework.apollo.internals.RemoteConfigRepository - Remote Config refreshed! 13:42:40.407 [main] DEBUG com.ctrip.framework.apollo.internals.RemoteConfigRepository - Schedule periodic refresh with interval: 5 MINUTES 13:42:40.408 [Apollo-RemoteConfigLongPollService-1] DEBUG com.ctrip.framework.apollo.internals.RemoteConfigLongPollService - Long polling will start in 2000 ms. INFO: log base dir is: /Users/name/logs/csp/ INFO: log name use pid is: false
原提问者GitHub用户188
您必须重构dashboard才能将规则推送到您的配置中心。您可以参考以下指南:
https://github.com/alibaba/Sentinel/wiki/%E5%9C%A8%E7%94%9F%E4%BA%A7%E7%8E%AF%E5%A2%83%E4%B8%AD%E4%BD%BF%E7%94%A8-Sentinel#push%E6%A8%A1%E5%BC%8F
https://github.com/alibaba/Sentinel/wiki/Sentinel-%E6%8E%A7%E5%88%B6%E5%8F%B0%EF%BC%88%E9%9B%86%E7%BE%A4%E6%B5%81%E6%8E%A7%E7%AE%A1%E7%90%86%EF%BC%89#%E8%A7%84%E5%88%99%E9%85%8D%E7%BD%AE
原回答者GitHub用户sczyh30
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。