@SPI(value="zookeeper") public interface ServiceDiscovery extends Prioritized
COMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY| Modifier and Type | Method and Description |
|---|---|
default void |
addServiceInstancesChangedListener(ServiceInstancesChangedListener listener)
Add an instance of
ServiceInstancesChangedListener for specified service |
void |
destroy()
Destroy the
ServiceDiscovery |
default void |
dispatchServiceInstancesChangedEvent(ServiceInstancesChangedEvent event)
Dispatch the
ServiceInstancesChangedEvent |
default void |
dispatchServiceInstancesChangedEvent(String serviceName)
Dispatch the
ServiceInstancesChangedEvent |
default void |
dispatchServiceInstancesChangedEvent(String serviceName,
Collection<ServiceInstance> serviceInstances)
Dispatch the
ServiceInstancesChangedEvent |
default void |
dispatchServiceInstancesChangedEvent(String serviceName,
String... otherServiceNames)
Dispatch the
ServiceInstancesChangedEvent |
default int |
getDefaultPageSize()
Get the default size of pagination query
|
default Map<String,Page<ServiceInstance>> |
getInstances(Iterable<String> serviceNames,
int offset,
int requestSize)
batch-get all
service instances by the specified service names |
default List<ServiceInstance> |
getInstances(String serviceName)
Gets all
service instances by the specified service name. |
default Page<ServiceInstance> |
getInstances(String serviceName,
int offset,
int pageSize)
Gets the
pagination of service instances by the specified service name. |
default 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 |
register(ServiceInstance serviceInstance)
Registers an instance of
ServiceInstance. |
String |
toString()
A human-readable description of the implementation
|
void |
unregister(ServiceInstance serviceInstance)
Unregisters an instance of
ServiceInstance. |
void |
update(ServiceInstance serviceInstance)
Updates the registered
ServiceInstance. |
compareTo, getPriorityvoid initialize(URL registryURL) throws Exception
ServiceDiscoveryvoid destroy()
throws Exception
ServiceDiscoveryException - If met with errorvoid register(ServiceInstance serviceInstance) throws RuntimeException
ServiceInstance.serviceInstance - an instance of ServiceInstance to be registeredRuntimeException - if failedvoid update(ServiceInstance serviceInstance) throws RuntimeException
ServiceInstance.serviceInstance - the registered ServiceInstanceRuntimeException - if failedvoid unregister(ServiceInstance serviceInstance) throws RuntimeException
ServiceInstance.serviceInstance - an instance of ServiceInstance to be deregisteredRuntimeException - if faileddefault int getDefaultPageSize()
default List<ServiceInstance> getInstances(String serviceName) throws NullPointerException
service instances by the specified service name.serviceName - the service nameListNullPointerException - if serviceName is null is nulldefault Page<ServiceInstance> getInstances(String serviceName, int offset, int pageSize) throws NullPointerException, IllegalArgumentException
pagination of service instances by the specified service name.
It's equal to getInstances(String, int, int, boolean) with healthyOnly == trueserviceName - the service nameoffset - the offset of request , the number "0" indicates first pagepageSize - the number of request, the max value indicates the range is unlimitedPage objectNullPointerException - if serviceName is null is nullIllegalArgumentException - if offset or pageSize is negative numberUnsupportedOperationException - if not supporteddefault Page<ServiceInstance> getInstances(String serviceName, int offset, int pageSize, boolean healthyOnly) throws NullPointerException, IllegalArgumentException, UnsupportedOperationException
pagination 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 null is nullIllegalArgumentException - if offset or pageSize is negative numberUnsupportedOperationException - if not supporteddefault Map<String,Page<ServiceInstance>> getInstances(Iterable<String> serviceNames, int offset, int requestSize) throws NullPointerException, IllegalArgumentException
service instances by the specified service namesserviceNames - the multiple service namesoffset - the offset of request , the number "0" indicates first pagerequestSize - the number of request, the max value indicates the range is unlimitedMap whose key is the service name and value is
the pagination of service instancesNullPointerException - if serviceName is null is nullIllegalArgumentException - if offset or requestSize is negative numberUnsupportedOperationException - if not supporteddefault void addServiceInstancesChangedListener(ServiceInstancesChangedListener listener) throws NullPointerException, IllegalArgumentException
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. If the registry observes the change, It's suggested that the implementation could invoke
dispatchServiceInstancesChangedEvent(String) method or variants
listener - an instance of ServiceInstancesChangedListenerNullPointerExceptionIllegalArgumentExceptionEventPublishingServiceDiscovery,
EventDispatcherdefault void dispatchServiceInstancesChangedEvent(String serviceName)
ServiceInstancesChangedEventserviceName - the name of service whose service instances have been changeddefault void dispatchServiceInstancesChangedEvent(String serviceName, String... otherServiceNames)
ServiceInstancesChangedEventserviceName - the name of service whose service instances have been changedotherServiceNames - the names of other servicesdefault void dispatchServiceInstancesChangedEvent(String serviceName, Collection<ServiceInstance> serviceInstances)
ServiceInstancesChangedEventserviceName - the name of service whose service instances have been changedserviceInstances - the service instances have been changeddefault void dispatchServiceInstancesChangedEvent(ServiceInstancesChangedEvent event)
ServiceInstancesChangedEventevent - the ServiceInstancesChangedEventCopyright © 2011–2019 The Apache Software Foundation. All rights reserved.