Class ServiceDiscoveryRegistry
- All Implemented Interfaces:
Node,Registry,RegistryService
ServiceDiscoveryRegistry is a very special Registry implementation, which is used to bridge the old interface-level service discovery model with the new service discovery model introduced in 3.0 in a compatible manner.
It fully complies with the extension specification of the Registry SPI, but is different from the specific implementation of zookeeper and Nacos, because it does not interact with any real third-party registry, but only with the relevant components of ServiceDiscovery in the process. In short, it bridges the old interface model and the new service discovery model:
- register() aggregates interface level data into MetadataInfo by mainly interacting with MetadataService. - subscribe() triggers the whole subscribe process of the application level service discovery model. - Maps interface to applications depending on ServiceNameMapping. - Starts the new service discovery listener (InstanceListener) and makes NotifierListeners part of the InstanceListener.
-
Constructor Summary
ConstructorsConstructorDescriptionServiceDiscoveryRegistry(URL registryURL, ApplicationModel applicationModel) -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()voiddoRegister(URL url) voiddoSubscribe(URL url, NotifyListener listener) voiddoUnregister(URL url) voiddoUnsubscribe(URL url, NotifyListener listener) getAppSubscription(String key) booleanbooleanQuery the registered data that matches the conditions.final voidRegister data, such as : provider service, consumer address, route rule, override rule and other data.voidfinal voidsubscribe(URL url, NotifyListener listener) Subscribe to eligible registered data and automatically push when the registered data is changed.static booleanSupports or not ?final voidunregister(URL url) Unregisterfinal voidunsubscribe(URL url, NotifyListener listener) UnsubscribeMethods inherited from class org.apache.dubbo.registry.support.FailbackRegistry
reExportRegister, reExportUnregister, removeFailedRegisteredTask, removeFailedSubscribed, removeFailedSubscribedTask, removeFailedUnregisteredTask, removeFailedUnsubscribedTaskMethods inherited from class org.apache.dubbo.registry.support.AbstractRegistry
doSaveProperties, getCacheFile, getCacheProperties, getCacheUrls, getLastCacheChanged, getNotified, getRegistered, getSubscribed, getUrl, toString
-
Constructor Details
-
ServiceDiscoveryRegistry
-
-
Method Details
-
getServiceDiscovery
-
register
Description copied from interface:RegistryServiceRegister data, such as : provider service, consumer address, route rule, override rule and other data.Registering is required to support the contract:
1. When the URL sets the check=false parameter. When the registration fails, the exception is not thrown and retried in the background. Otherwise, the exception will be thrown.
2. When URL sets the dynamic=false parameter, it needs to be stored persistently, otherwise, it should be deleted automatically when the registrant has an abnormal exit.
3. When the URL sets category=routers, it means classified storage, the default category is providers, and the data can be notified by the classified section.
4. When the registry is restarted, network jitter, data can not be lost, including automatically deleting data from the broken line.
5. Allow URLs which have the same URL but different parameters to coexist,they can't cover each other.- Specified by:
registerin interfaceRegistryService- Overrides:
registerin classFailbackRegistry- Parameters:
url- Registration information , is not allowed to be empty, e.g: dubbo://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0invalid input: '&application'=kylin
-
doRegister
- Specified by:
doRegisterin classFailbackRegistry
-
unregister
Description copied from interface:RegistryServiceUnregisterUnregistering is required to support the contract:
1. If it is the persistent stored data of dynamic=false, the registration data can not be found, then the IllegalStateException is thrown, otherwise it is ignored.
2. Unregister according to the full url match.- Specified by:
unregisterin interfaceRegistryService- Overrides:
unregisterin classFailbackRegistry- Parameters:
url- Registration information , is not allowed to be empty, e.g: dubbo://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0invalid input: '&application'=kylin
-
doUnregister
- Specified by:
doUnregisterin classFailbackRegistry
-
subscribe
Description copied from interface:RegistryServiceSubscribe to eligible registered data and automatically push when the registered data is changed.Subscribing need to support contracts:
1. When the URL sets the check=false parameter. When the registration fails, the exception is not thrown and retried in the background.
2. When URL sets category=routers, it only notifies the specified classification data. Multiple classifications are separated by commas, and allows asterisk to match, which indicates that all categorical data are subscribed.
3. Allow interface, group, version, and classifier as a conditional query, e.g.: interface=org.apache.dubbo.foo.BarServiceinvalid input: '&version'=1.0.0
4. And the query conditions allow the asterisk to be matched, subscribe to all versions of all the packets of all interfaces, e.g. :interface=*invalid input: '&group'=*invalid input: '&version'=*invalid input: '&classifier'=*
5. When the registry is restarted and network jitter, it is necessary to automatically restore the subscription request.
6. Allow URLs which have the same URL but different parameters to coexist,they can't cover each other.
7. The subscription process must be blocked, when the first notice is finished and then returned.- Specified by:
subscribein interfaceRegistryService- Overrides:
subscribein classFailbackRegistry- Parameters:
url- Subscription condition, not allowed to be empty, e.g. consumer://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0invalid input: '&application'=kylinlistener- A listener of the change event, not allowed to be empty
-
doSubscribe
- Specified by:
doSubscribein classFailbackRegistry
-
unsubscribe
Description copied from interface:RegistryServiceUnsubscribeUnsubscribing is required to support the contract:
1. If you don't subscribe, ignore it directly.
2. Unsubscribe by full URL match.- Specified by:
unsubscribein interfaceRegistryService- Overrides:
unsubscribein classFailbackRegistry- Parameters:
url- Subscription condition, not allowed to be empty, e.g. consumer://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0invalid input: '&application'=kylinlistener- A listener of the change event, not allowed to be empty
-
doUnsubscribe
- Specified by:
doUnsubscribein classFailbackRegistry
-
lookup
Description copied from interface:RegistryServiceQuery the registered data that matches the conditions. Corresponding to the push mode of the subscription, this is the pull mode and returns only one result.- Specified by:
lookupin interfaceRegistryService- Overrides:
lookupin classAbstractRegistry- Parameters:
url- Query condition, is not allowed to be empty, e.g. consumer://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0invalid input: '&application'=kylin- Returns:
- The registered information list, which may be empty, the meaning is the same as the parameters of
NotifyListener.notify(List<URL>). - See Also:
-
isAvailable
public boolean isAvailable() -
destroy
public void destroy()- Specified by:
destroyin interfaceNode- Overrides:
destroyin classFailbackRegistry
-
isServiceDiscovery
public boolean isServiceDiscovery() -
supports
Supports or not ?- Parameters:
registryURL- theurlof registry- Returns:
- if supported, return
true, orfalse
-
getServiceListeners
-
getAppSubscription
-
removeAppSubscriptionLock
-