类 ServiceDiscoveryRegistry
- java.lang.Object
-
- org.apache.dubbo.registry.client.ServiceDiscoveryRegistry
-
- 所有已实现的接口:
Node
,Registry
,RegistryService
public class ServiceDiscoveryRegistry extends Object implements Registry
Being different to the traditional registry,ServiceDiscoveryRegistry
that is a new service-orientedRegistry
based onServiceDiscovery
, it will not interact in the external registry directly, but store theurls
that Dubbo services exported and referenced intoWritableMetadataService
whenregister(URL)
andsubscribe(URL, NotifyListener)
methods are executed. After that the exportedurls
can be get fromMetadataService.getExportedURLs()
and its variant methods. In contrast,MetadataService.getSubscribedURLs()
method offers the subscribedURLs
.Every
ServiceDiscoveryRegistry
object has its ownServiceDiscovery
instance that was initialized underthe construction
. As the primary argument of constructor , theURL
of connection the registry decides what the kind of ServiceDiscovery is. Generally, each protocol associates with a kind ofServiceDiscovery
's implementation if present, or theFileSystemServiceDiscovery
will be the default one. Obviously, it's also allowed to extendServiceDiscovery
usingthe Dubbo SPI
. In contrast, currentservice instance
will not be registered to the registry whether any Dubbo service is exported or not.- 从以下版本开始:
- 2.7.5
- 另请参阅:
ServiceDiscovery
,FailbackRegistry
,WritableMetadataService
-
-
构造器概要
构造器 构造器 说明 ServiceDiscoveryRegistry(URL registryURL)
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 static ServiceDiscoveryRegistry
create(URL registryURL)
Create an instance ofServiceDiscoveryRegistry
if supportedvoid
destroy()
destroy.void
doRegister(URL url)
void
doSubscribe(URL url, NotifyListener listener)
void
doUnregister(URL url)
void
doUnsubscribe(URL url, NotifyListener listener)
ServiceDiscovery
getServiceDiscovery()
Map<String,ServiceInstancesChangedListener>
getServiceListeners()
URL
getUrl()
get url.boolean
isAvailable()
is available.List<URL>
lookup(URL url)
Query the registered data that matches the conditions.void
register(URL url)
Register data, such as : provider service, consumer address, route rule, override rule and other data.void
subscribe(URL url, NotifyListener listener)
Subscribe to eligible registered data and automatically push when the registered data is changed.static boolean
supports(URL registryURL)
Supports or not ?void
unregister(URL url)
Unregistervoid
unsubscribe(URL url, NotifyListener listener)
Unsubscribe-
从接口继承的方法 org.apache.dubbo.registry.Registry
getDelay, reExportRegister, reExportUnregister
-
-
-
-
构造器详细资料
-
ServiceDiscoveryRegistry
public ServiceDiscoveryRegistry(URL registryURL)
-
-
方法详细资料
-
getServiceDiscovery
public ServiceDiscovery getServiceDiscovery()
-
register
public final void register(URL url)
从接口复制的说明:RegistryService
Register 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.- 指定者:
register
在接口中RegistryService
- 参数:
url
- Registration information , is not allowed to be empty, e.g: dubbo://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0&application=kylin
-
doRegister
public void doRegister(URL url)
-
unregister
public final void unregister(URL url)
从接口复制的说明:RegistryService
UnregisterUnregistering 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.- 指定者:
unregister
在接口中RegistryService
- 参数:
url
- Registration information , is not allowed to be empty, e.g: dubbo://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0&application=kylin
-
doUnregister
public void doUnregister(URL url)
-
subscribe
public final void subscribe(URL url, NotifyListener listener)
从接口复制的说明:RegistryService
Subscribe 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.BarService&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=*&group=*&version=*&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.- 指定者:
subscribe
在接口中RegistryService
- 参数:
url
- Subscription condition, not allowed to be empty, e.g. consumer://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0&application=kylinlistener
- A listener of the change event, not allowed to be empty
-
doSubscribe
public void doSubscribe(URL url, NotifyListener listener)
-
unsubscribe
public final void unsubscribe(URL url, NotifyListener listener)
从接口复制的说明:RegistryService
UnsubscribeUnsubscribing is required to support the contract:
1. If don't subscribe, ignore it directly.
2. Unsubscribe by full URL match.- 指定者:
unsubscribe
在接口中RegistryService
- 参数:
url
- Subscription condition, not allowed to be empty, e.g. consumer://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0&application=kylinlistener
- A listener of the change event, not allowed to be empty
-
doUnsubscribe
public void doUnsubscribe(URL url, NotifyListener listener)
-
lookup
public List<URL> lookup(URL url)
从接口复制的说明:RegistryService
Query 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.- 指定者:
lookup
在接口中RegistryService
- 参数:
url
- Query condition, is not allowed to be empty, e.g. consumer://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0&application=kylin- 返回:
- The registered information list, which may be empty, the meaning is the same as the parameters of
org.apache.dubbo.registry.NotifyListener#notify(List
.) - 另请参阅:
NotifyListener.notify(List)
-
isAvailable
public boolean isAvailable()
从接口复制的说明:Node
is available.- 指定者:
isAvailable
在接口中Node
- 返回:
- available.
-
create
public static ServiceDiscoveryRegistry create(URL registryURL)
Create an instance ofServiceDiscoveryRegistry
if supported- 参数:
registryURL
- theurl
of registry- 返回:
null
if not supported
-
supports
public static boolean supports(URL registryURL)
Supports or not ?- 参数:
registryURL
- theurl
of registry- 返回:
- if supported, return
true
, orfalse
-
getServiceListeners
public Map<String,ServiceInstancesChangedListener> getServiceListeners()
-
-