public class ZookeeperServiceDiscovery extends Object implements ServiceDiscovery, EventListener<ServiceInstancesChangedEvent>
ServiceDiscovery implementation based on
Apache Curator X DiscoveryCOMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY| 构造器和说明 |
|---|
ZookeeperServiceDiscovery() |
| 限定符和类型 | 方法和说明 |
|---|---|
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 |
List<ServiceInstance> |
getInstances(String serviceName)
Gets all
service instances by the specified service name. |
Page<ServiceInstance> |
getInstances(String serviceName,
int offset,
int pageSize,
boolean healthyOnly)
Get the
pagination of service instances by the specified service name. |
Set<String> |
getServices()
Gets all service names
|
void |
initialize(URL registryURL)
Initializes the
ServiceDiscovery |
void |
onEvent(ServiceInstancesChangedEvent event)
Handle a
Dubbo Event when it's be published |
void |
register(ServiceInstance serviceInstance)
Registers an instance of
ServiceInstance. |
void |
unregister(ServiceInstance serviceInstance)
Unregisters an instance of
ServiceInstance. |
void |
update(ServiceInstance serviceInstance)
Updates the registered
ServiceInstance. |
dispatchServiceInstancesChangedEvent, dispatchServiceInstancesChangedEvent, dispatchServiceInstancesChangedEvent, dispatchServiceInstancesChangedEvent, getDefaultPageSize, getInstances, getInstances, toStringfindEventType, findEventType, findEventType, getPrioritycompareTopublic void initialize(URL registryURL) throws Exception
ServiceDiscoveryServiceDiscoveryinitialize 在接口中 ServiceDiscoveryregistryURL - the url to connect service registryException - If met with errorpublic void destroy()
throws Exception
ServiceDiscoveryServiceDiscoverydestroy 在接口中 ServiceDiscoveryException - If met with errorpublic void register(ServiceInstance serviceInstance) throws RuntimeException
ServiceDiscoveryServiceInstance.register 在接口中 ServiceDiscoveryserviceInstance - an instance of ServiceInstance to be registeredRuntimeException - if failedpublic void update(ServiceInstance serviceInstance) throws RuntimeException
ServiceDiscoveryServiceInstance.update 在接口中 ServiceDiscoveryserviceInstance - the registered ServiceInstanceRuntimeException - if failedpublic void unregister(ServiceInstance serviceInstance) throws RuntimeException
ServiceDiscoveryServiceInstance.unregister 在接口中 ServiceDiscoveryserviceInstance - an instance of ServiceInstance to be deregisteredRuntimeException - if failedpublic Set<String> getServices()
ServiceDiscoverygetServices 在接口中 ServiceDiscoverySetpublic List<ServiceInstance> getInstances(String serviceName) throws NullPointerException
ServiceDiscoveryservice instances by the specified service name.getInstances 在接口中 ServiceDiscoveryserviceName - the service nameListNullPointerException - if serviceName is null is nullpublic Page<ServiceInstance> getInstances(String serviceName, int offset, int pageSize, boolean healthyOnly)
ServiceDiscoverypagination of service instances by the specified service name.
If healthyOnly == true, filter healthy instances only.getInstances 在接口中 ServiceDiscoveryserviceName - 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 objectpublic 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
addServiceInstancesChangedListener 在接口中 ServiceDiscoverylistener - an instance of ServiceInstancesChangedListenerNullPointerExceptionIllegalArgumentExceptionEventPublishingServiceDiscovery,
EventDispatcherpublic void onEvent(ServiceInstancesChangedEvent event)
EventListenerDubbo Event when it's be publishedevent - a Dubbo EventCopyright © 2011–2020 The Apache Software Foundation. All rights reserved.