接口 ServiceDiscovery
-
- 所有超级接口:
Comparable<Prioritized>,Prioritized
- 所有已知实现类:
AbstractServiceDiscovery,DNSServiceDiscovery,FileSystemServiceDiscovery,KubernetesServiceDiscovery,MulticastServiceDiscovery,MultipleServiceDiscovery,NacosServiceDiscovery,SelfHostMetaServiceDiscovery,XdsServiceDiscovery,ZookeeperServiceDiscovery
@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 servicedefault ServiceInstancesChangedListenercreateListener(Set<String> serviceNames)voiddestroy()Destroy theServiceDiscoverydefault voiddispatchServiceInstancesChangedEvent(String serviceName)default voiddispatchServiceInstancesChangedEvent(String serviceName, String... otherServiceNames)default voiddispatchServiceInstancesChangedEvent(String serviceName, List<ServiceInstance> serviceInstances)default voiddispatchServiceInstancesChangedEvent(ServiceInstancesChangedEvent event)default intgetDefaultPageSize()Get the default size of pagination querydefault longgetDelay()default 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 theServiceDiscoverybooleanisDestroy()voidregister(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
-
isDestroy
boolean isDestroy()
-
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
-
dispatchServiceInstancesChangedEvent
default void dispatchServiceInstancesChangedEvent(String serviceName)
-
dispatchServiceInstancesChangedEvent
default void dispatchServiceInstancesChangedEvent(String serviceName, String... otherServiceNames)
-
dispatchServiceInstancesChangedEvent
default void dispatchServiceInstancesChangedEvent(String serviceName, List<ServiceInstance> serviceInstances)
-
dispatchServiceInstancesChangedEvent
default void dispatchServiceInstancesChangedEvent(ServiceInstancesChangedEvent event)
-
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, 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
-
removeServiceInstancesChangedListener
default void removeServiceInstancesChangedListener(ServiceInstancesChangedListener listener) throws IllegalArgumentException
unsubscribe to instances change event.- 参数:
listener-- 抛出:
IllegalArgumentException
-
createListener
default ServiceInstancesChangedListener createListener(Set<String> serviceNames)
-
getUrl
default URL getUrl()
-
getLocalInstance
ServiceInstance getLocalInstance()
-
getDelay
default long getDelay()
-
-