feat: support use database as a registry#4595
Conversation
less dependency, config, startup fail, more reliability,
Codecov Report
@@ Coverage Diff @@
## master #4595 +/- ##
============================================
+ Coverage 46.48% 47.23% +0.75%
- Complexity 1568 1649 +81
============================================
Files 332 347 +15
Lines 10367 10631 +264
Branches 1043 1053 +10
============================================
+ Hits 4819 5022 +203
- Misses 5252 5306 +54
- Partials 296 303 +7
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
nobodyiam
left a comment
There was a problem hiding this comment.
BTW, the program failed to start by running com.ctrip.framework.apollo.assembly.ApolloApplication, see the error message below.
However, it works after I removed the class ApolloRegistryAutoConfiguration. What's the use of this class?
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method registryService in com.ctrip.framework.apollo.biz.registry.configuration.ApolloRegistryClientAutoConfiguration required a bean of type 'com.ctrip.framework.apollo.biz.repository.RegistryRepository' that could not be found.
Action:
Consider defining a bean of type 'com.ctrip.framework.apollo.biz.repository.RegistryRepository' in your configuration.
...ice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/RegistryController.java
Outdated
Show resolved
Hide resolved
apollo-adminservice/src/main/resources/application-database-discovery.properties
Show resolved
Hide resolved
apollo-adminservice/src/main/resources/application-database-discovery.properties
Outdated
Show resolved
Hide resolved
...o-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientImpl.java
Outdated
Show resolved
Hide resolved
...o-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientImpl.java
Outdated
Show resolved
Hide resolved
...trip/framework/apollo/biz/registry/configuration/support/ApolloRegistryClientProperties.java
Show resolved
Hide resolved
...p/framework/apollo/biz/registry/configuration/support/ApolloRegistryDiscoveryProperties.java
Outdated
Show resolved
Hide resolved
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/RegistryRepository.java
Outdated
Show resolved
Hide resolved
apollo-configservice/src/main/resources/application-database-discovery.properties
Show resolved
Hide resolved
This error log still occur in my machine, I will try to fix it. |
I think |
…hat could not be found
|
Should let user can manual register an instance that always be healthy? Or we just keep registry simple without the manual register function? |
...o-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientImpl.java
Outdated
Show resolved
Hide resolved
...o-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientImpl.java
Outdated
Show resolved
Hide resolved
...k/apollo/biz/registry/configuration/support/ApolloServiceRegistryClearApplicationRunner.java
Outdated
Show resolved
Hide resolved
...o/biz/registry/configuration/support/ApolloServiceRegistryDeregisterApplicationListener.java
Outdated
Show resolved
Hide resolved
...ollo/biz/registry/configuration/support/ApolloServiceRegistryHeartbeatApplicationRunner.java
Outdated
Show resolved
Hide resolved
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ServiceRegistryService.java
Show resolved
Hide resolved
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ServiceRegistryService.java
Show resolved
Hide resolved
.../apollo/biz/registry/configuration/ApolloServiceRegistryAutoConfigurationNotEnabledTest.java
Show resolved
Hide resolved
...ollo/biz/registry/configuration/support/ApolloServiceRegistryHeartbeatApplicationRunner.java
Outdated
Show resolved
Hide resolved
...o/biz/registry/configuration/support/ApolloServiceRegistryDeregisterApplicationListener.java
Outdated
Show resolved
Hide resolved
...o/biz/registry/configuration/support/ApolloServiceRegistryDeregisterApplicationListener.java
Outdated
Show resolved
Hide resolved
I don't whether this use case is valid, is there an actual scenario? |
like profile Some instances can be clearup, but other instances always exists whenever they have heartbeat or not. |
-Dapollo.service.registry.metadata.a=1
-Dapollo.service.registry.metadata.isAutoRegister=true
generate {"a":"1","isAutoRegister":"true"} in database
|
Ok~. I add a table column if someone add config apollo.service.registry.metadata.a=1
apollo.service.registry.metadata.isAutoRegister=truethen will generate value in table's column Is it ok? |
nobodyiam
left a comment
There was a problem hiding this comment.
This looks good to me now. Please help to update the CHANGES.md and add some documentation.
When I write document, I notice that the file application-database-discovery.properties will be packaged in to .jar file. If someone want to change to Is there another way to do it without rebuild the whole project? Can we add it to |
The |
Agree that.
And there is another thing about |
|
There are some feature need to support later:
left them in another pr? |
I think we could use the first feature to enable the second feature, e.g. when the database failed, we could still use the service instance in the memory cache. |
Co-authored-by: Jason Song <nobodyiam@gmail.com>
…rator pattern, memory cache

What's the purpose of this PR
Use database as a registry.
less dependency, config, startup fail,
maybe more reliability,
Which issue(s) this PR fixes:
Fixes #4583
Brief changelog
A simple try to implement a registry by database.
Eureka is still default registry, this feature is active by spring boot's profile.
Write the main code in
apollo-bizmodule with spring boot auto configuration for configservice and adminservice.Create a new table
Registryin configdb to save the service instance's information.There 4 column with table
Registry:apollo-configserviceorapollo-adminservice.http://127.0.0.1:8080/directly, maybe it's more simple.Here are some concept:
dataChangeLastModifiedTimeif it exists.Unit test, changelog and document will be added when this pr's direction is correct.
Follow this checklist to help us incorporate your contribution quickly and easily:
mvn clean testto make sure this pull request doesn't break anything.CHANGESlog.