接口 ServiceDiscovery
-
- 所有超级接口:
Comparable<Prioritized>,Prioritized
@SPI("zookeeper") public interface ServiceDiscovery extends Prioritized
The common operations of Service Discovery- 从以下版本开始:
- 2.7.5
-
-
字段概要
-
从接口继承的字段 org.apache.dubbo.common.lang.Prioritized
COMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY
-
-
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 default voidaddServiceInstancesChangedListener(ServiceInstancesChangedListener listener)Add an instance ofServiceInstancesChangedListenerfor specified servicevoiddestroy()Destroy theServiceDiscoverydefault voiddispatchServiceInstancesChangedEvent(String serviceName)Dispatch theServiceInstancesChangedEventdefault voiddispatchServiceInstancesChangedEvent(String serviceName, String... otherServiceNames)Dispatch theServiceInstancesChangedEventdefault voiddispatchServiceInstancesChangedEvent(String serviceName, List<ServiceInstance> serviceInstances)Dispatch theServiceInstancesChangedEventdefault voiddispatchServiceInstancesChangedEvent(ServiceInstancesChangedEvent event)Dispatch theServiceInstancesChangedEventdefault intgetDefaultPageSize()Get the default size of pagination querydefault Map<String,Page<ServiceInstance>>getInstances(Iterable<String> serviceNames, int offset, int requestSize)batch-get allservice instancesby the specified service namesdefault List<ServiceInstance>getInstances(String serviceName)Gets allservice instancesby the specified service name.default Page<ServiceInstance>getInstances(String serviceName, int offset, int pageSize)Gets thepaginationofservice instancesby the specified service name.default Page<ServiceInstance>getInstances(String serviceName, int offset, int pageSize, boolean healthyOnly)Get thepaginationofservice instancesby the specified service name.ServiceInstancegetLocalInstance()Set<String>getServices()Gets all service namesdefault URLgetUrl()voidinitialize(URL registryURL)Initializes theServiceDiscoveryvoidregister(ServiceInstance serviceInstance)Registers an instance ofServiceInstance.default voidremoveServiceInstancesChangedListener(ServiceInstancesChangedListener listener)unsubscribe to instances change event.StringtoString()A human-readable description of the implementationvoidunregister(ServiceInstance serviceInstance)Unregisters an instance ofServiceInstance.voidupdate(ServiceInstance serviceInstance)Updates the registeredServiceInstance.-
从接口继承的方法 org.apache.dubbo.common.lang.Prioritized
compareTo, getPriority
-
-
-
-
方法详细资料
-
initialize
void initialize(URL registryURL) throws Exception
Initializes theServiceDiscovery
-
destroy
void destroy() throws ExceptionDestroy theServiceDiscovery- 抛出:
Exception- If met with error
-
register
void register(ServiceInstance serviceInstance) throws RuntimeException
Registers an instance ofServiceInstance.- 参数:
serviceInstance- an instance ofServiceInstanceto be registered- 抛出:
RuntimeException- if failed
-
update
void update(ServiceInstance serviceInstance) throws RuntimeException
Updates the registeredServiceInstance.- 参数:
serviceInstance- the registeredServiceInstance- 抛出:
RuntimeException- if failed
-
unregister
void unregister(ServiceInstance serviceInstance) throws RuntimeException
Unregisters an instance ofServiceInstance.- 参数:
serviceInstance- an instance ofServiceInstanceto be unregistered- 抛出:
RuntimeException- if failed
-
getDefaultPageSize
default int getDefaultPageSize()
Get the default size of pagination query- 返回:
- the default value is 100
-
getInstances
default List<ServiceInstance> getInstances(String serviceName) throws NullPointerException
Gets allservice instancesby the specified service name.- 参数:
serviceName- the service name- 返回:
- non-null
List - 抛出:
NullPointerException- ifserviceNameisnull
-
getInstances
default Page<ServiceInstance> getInstances(String serviceName, int offset, int pageSize) throws NullPointerException, IllegalArgumentException
Gets thepaginationofservice instancesby the specified service name. It's equal togetInstances(String, int, int, boolean)withhealthyOnly == true- 参数:
serviceName- the service nameoffset- the offset of request , the number "0" indicates first pagepageSize- the number of request, themax valueindicates the range is unlimited- 返回:
- non-null
Pageobject - 抛出:
NullPointerException- ifserviceNameisnullIllegalArgumentException- ifoffsetorpageSizeis negative numberUnsupportedOperationException- if not supported
-
getInstances
default Page<ServiceInstance> getInstances(String serviceName, int offset, int pageSize, boolean healthyOnly) throws NullPointerException, IllegalArgumentException, UnsupportedOperationException
Get thepaginationofservice instancesby the specified service name. IfhealthyOnly == true, filter healthy instances only.- 参数:
serviceName- the service nameoffset- the offset of request , the number "0" indicates first pagepageSize- the number of request, themax valueindicates the range is unlimitedhealthyOnly- iftrue, filter healthy instances only- 返回:
- non-null
Pageobject - 抛出:
NullPointerException- ifserviceNameisnullIllegalArgumentException- ifoffsetorpageSizeis negative numberUnsupportedOperationException- if not supported
-
getInstances
default Map<String,Page<ServiceInstance>> getInstances(Iterable<String> serviceNames, int offset, int requestSize) throws NullPointerException, IllegalArgumentException
batch-get allservice instancesby the specified service names- 参数:
serviceNames- the multiple service namesoffset- the offset of request , the number "0" indicates first pagerequestSize- the number of request, themax valueindicates the range is unlimited- 返回:
- non-null read-only
Mapwhose key is the service name and value is thepaginationofservice instances - 抛出:
NullPointerException- ifserviceNameisnullIllegalArgumentException- ifoffsetorrequestSizeis negative numberUnsupportedOperationException- if not supported
-
addServiceInstancesChangedListener
default void addServiceInstancesChangedListener(ServiceInstancesChangedListener listener) throws NullPointerException, IllegalArgumentException
Add an instance ofServiceInstancesChangedListenerfor specified serviceDefault, current method will be invoked by
the ServiceDiscoveryRegistry on the subscription, and it's mandatory toaddtheServiceInstancesChangedListenerargument intoEventDispatcherwhether 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 invokedispatchServiceInstancesChangedEvent(String)method or variants- 参数:
listener- an instance ofServiceInstancesChangedListener- 抛出:
NullPointerExceptionIllegalArgumentException- 另请参阅:
EventPublishingServiceDiscovery,EventDispatcher
-
removeServiceInstancesChangedListener
default void removeServiceInstancesChangedListener(ServiceInstancesChangedListener listener) throws IllegalArgumentException
unsubscribe to instances change event.- 参数:
listener-- 抛出:
IllegalArgumentException
-
dispatchServiceInstancesChangedEvent
default void dispatchServiceInstancesChangedEvent(String serviceName)
Dispatch theServiceInstancesChangedEvent- 参数:
serviceName- the name of service whose service instances have been changed
-
dispatchServiceInstancesChangedEvent
default void dispatchServiceInstancesChangedEvent(String serviceName, String... otherServiceNames)
Dispatch theServiceInstancesChangedEvent- 参数:
serviceName- the name of service whose service instances have been changedotherServiceNames- the names of other services
-
dispatchServiceInstancesChangedEvent
default void dispatchServiceInstancesChangedEvent(String serviceName, List<ServiceInstance> serviceInstances)
Dispatch theServiceInstancesChangedEvent- 参数:
serviceName- the name of service whose service instances have been changedserviceInstances- the service instances have been changed
-
dispatchServiceInstancesChangedEvent
default void dispatchServiceInstancesChangedEvent(ServiceInstancesChangedEvent event)
Dispatch theServiceInstancesChangedEvent- 参数:
event- theServiceInstancesChangedEvent
-
getUrl
default URL getUrl()
-
getLocalInstance
ServiceInstance getLocalInstance()
-
-