public class MultipleRegistryServiceDiscovery extends AbstractServiceDiscovery
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
REGISTRY_PREFIX_KEY |
COMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY| 构造器和说明 |
|---|
MultipleRegistryServiceDiscovery() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addServiceInstancesChangedListener(ServiceInstancesChangedListener listener)
Add an instance of
ServiceInstancesChangedListener for specified service
Default, current method will be invoked by the ServiceDiscoveryRegistry on the subscription, and it's mandatory to
add the ServiceInstancesChangedListener argument
into EventDispatcher whether the subclass implements same approach or not, thus this method is used to
trigger or adapt the vendor's change notification mechanism typically, like Zookeeper Watcher,
Nacos EventListener. |
void |
destroy()
Destroy the
ServiceDiscovery |
void |
doRegister(ServiceInstance serviceInstance)
It should be implement in kinds of service discovers.
|
void |
doUpdate(ServiceInstance serviceInstance)
It should be implement in kinds of service discovers.
|
Page<ServiceInstance> |
getInstances(String serviceName,
int offset,
int pageSize,
boolean healthyOnly)
Get the
pagination of service instances by the specified service name. |
ServiceInstance |
getLocalInstance() |
Set<String> |
getServices()
Gets all service names
|
URL |
getUrl() |
void |
initialize(URL registryURL)
Initializes the
ServiceDiscovery |
void |
unregister(ServiceInstance serviceInstance)
Unregisters an instance of
ServiceInstance. |
register, updatedispatchServiceInstancesChangedEvent, dispatchServiceInstancesChangedEvent, dispatchServiceInstancesChangedEvent, dispatchServiceInstancesChangedEvent, getDefaultPageSize, getInstances, getInstances, getInstances, removeServiceInstancesChangedListener, toStringcompareTo, getPrioritypublic void initialize(URL registryURL) throws Exception
ServiceDiscoveryServiceDiscoverypublic URL getUrl()
public void destroy()
throws Exception
ServiceDiscoveryServiceDiscoveryException - If met with errorpublic void doRegister(ServiceInstance serviceInstance)
AbstractServiceDiscoverydoRegister 在类中 AbstractServiceDiscoverypublic void doUpdate(ServiceInstance serviceInstance)
AbstractServiceDiscoverydoUpdate 在类中 AbstractServiceDiscoverypublic void unregister(ServiceInstance serviceInstance) throws RuntimeException
ServiceDiscoveryServiceInstance.serviceInstance - an instance of ServiceInstance to be unregisteredRuntimeException - if failedpublic void addServiceInstancesChangedListener(ServiceInstancesChangedListener listener) throws NullPointerException, IllegalArgumentException
ServiceDiscoveryServiceInstancesChangedListener for specified service
Default, current method will be invoked by the ServiceDiscoveryRegistry on the subscription, and it's mandatory to
add the ServiceInstancesChangedListener argument
into EventDispatcher whether the subclass implements same approach or not, thus this method is used to
trigger or adapt the vendor's change notification mechanism typically, like Zookeeper Watcher,
Nacos EventListener. If the registry observes the change, It's suggested that the implementation could invoke
ServiceDiscovery.dispatchServiceInstancesChangedEvent(String) method or variants
listener - an instance of ServiceInstancesChangedListenerNullPointerExceptionIllegalArgumentExceptionEventPublishingServiceDiscovery,
EventDispatcherpublic Page<ServiceInstance> getInstances(String serviceName, int offset, int pageSize, boolean healthyOnly) throws NullPointerException, IllegalArgumentException, UnsupportedOperationException
ServiceDiscoverypagination of service instances by the specified service name.
If healthyOnly == true, filter healthy instances only.serviceName - the service nameoffset - the offset of request , the number "0" indicates first pagepageSize - the number of request, the max value indicates the range is unlimitedhealthyOnly - if true , filter healthy instances onlyPage objectNullPointerException - if serviceName is nullIllegalArgumentException - if offset or pageSize is negative numberUnsupportedOperationException - if not supportedpublic Set<String> getServices()
ServiceDiscoverySetpublic ServiceInstance getLocalInstance()
getLocalInstance 在接口中 ServiceDiscoverygetLocalInstance 在类中 AbstractServiceDiscoveryCopyright © 2011–2021 The Apache Software Foundation. All rights reserved.