public abstract class AbstractServiceDiscovery extends Object implements ServiceDiscovery
COMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY| Constructor and Description |
|---|
AbstractServiceDiscovery(ApplicationModel applicationModel,
URL registryURL) |
AbstractServiceDiscovery(String serviceName,
URL registryURL) |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Destroy the
ServiceDiscovery |
ServiceInstance |
getLocalInstance() |
MetadataInfo |
getLocalMetadata() |
MetadataInfo |
getRemoteMetadata(String revision) |
MetadataInfo |
getRemoteMetadata(String revision,
List<ServiceInstance> instances) |
URL |
getUrl() |
boolean |
isDestroy() |
List<URL> |
lookup(URL url)
Query the registered data that matches the conditions.
|
void |
register() |
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.
|
void |
unregister() |
void |
unregister(URL url)
Unregister
|
void |
unsubscribe(URL url,
NotifyListener listener)
Unsubscribe
|
void |
update()
Update assumes that DefaultServiceInstance and its attributes will never get updated once created.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddServiceInstancesChangedListener, createListener, getDelay, getInstances, getServices, removeServiceInstancesChangedListener, toStringcompareTo, getPrioritypublic AbstractServiceDiscovery(ApplicationModel applicationModel, URL registryURL)
public void register()
throws RuntimeException
register in interface ServiceDiscoveryRuntimeExceptionpublic void update()
throws RuntimeException
update in interface ServiceDiscoveryRuntimeExceptionpublic void unregister()
throws RuntimeException
unregister in interface ServiceDiscoveryRuntimeExceptionpublic final ServiceInstance getLocalInstance()
getLocalInstance in interface ServiceDiscoverypublic MetadataInfo getLocalMetadata()
getLocalMetadata in interface ServiceDiscoverypublic MetadataInfo getRemoteMetadata(String revision, List<ServiceInstance> instances)
getRemoteMetadata in interface ServiceDiscoverypublic MetadataInfo getRemoteMetadata(String revision)
getRemoteMetadata in interface ServiceDiscoverypublic final void destroy()
throws Exception
ServiceDiscoveryServiceDiscoverydestroy in interface ServiceDiscoveryException - If met with errorpublic final boolean isDestroy()
isDestroy in interface ServiceDiscoverypublic void register(URL url)
RegistryService
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 in interface RegistryServiceurl - 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=kylinpublic void unregister(URL url)
RegistryService
Unregistering 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 in interface RegistryServiceurl - 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=kylinpublic void subscribe(URL url, NotifyListener listener)
RegistryService
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 in interface RegistryServiceurl - 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 emptypublic void unsubscribe(URL url, NotifyListener listener)
RegistryService
Unsubscribing is required to support the contract:
1. If you don't subscribe, ignore it directly.
2. Unsubscribe by full URL match.
unsubscribe in interface RegistryServiceurl - 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 emptypublic List<URL> lookup(URL url)
RegistryServicelookup in interface RegistryServiceurl - 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=kylinorg.apache.dubbo.registry.NotifyListener#notify(List) .NotifyListener.notify(List)public URL getUrl()
getUrl in interface ServiceDiscoveryCopyright © 2011–2022 The Apache Software Foundation. All rights reserved.