标签:
base path
|_______ service A name
|__________ instance 1 id --> (serialized ServiceInstance)
|__________ instance 2 id --> (serialized ServiceInstance)
|__________ ...
|_______ service B name
|__________ instance 1 id --> (serialized ServiceInstance)
|__________ instance 2 id --> (serialized ServiceInstance)
|__________ ...
|_______ ...
/**
* Return an instance for a single use. <b>IMPORTANT: </b> users
* should not hold on to the instance returned. They should always get a fresh instance.
*
* @return the instance to use
* @throws Exception any errors
*/
public ServiceInstance<T> getInstance() throws Exception;
/**
* Return the current available set of instances <b>IMPORTANT: </b> users
* should not hold on to the instance returned. They should always get a fresh list.
*
* @return all known instances
* @throws Exception any errors
*/
public Collection<ServiceInstance<T>> getAllInstances() throws Exception;
/**
* Register/re-register a service 注册服务
*
* @param service service to add
* @throws Exception errors
*/
public void registerService(ServiceInstance<T> service) throws Exception;
/**
* Unregister/remove a service instance 取消注册服务
*
* @param service the service
* @throws Exception errors
*/
public void unregisterService(ServiceInstance<T> service) throws Exception;
/**
* Return the names of all known services
*
* @return list of service names
* @throws Exception errors
*/
public Collection<String> queryForNames() throws Exception;
/**
* Return all known instances for the given service
*
* @param name name of the service
* @return list of instances (or an empty list)
* @throws Exception errors
*/
public Collection<ServiceInstance<T>> queryForInstances(String name) throws Exception;
/**
* Return a service instance POJO
*
* @param name name of the service
* @param id ID of the instance
* @return the instance or <code>null</code> if not found
* @throws Exception errors
*/
public ServiceInstance<T> queryForInstance(String name, String id) throws Exception;
/**
* Return the current list of instances. NOTE: there is no guarantee of freshness. This is
* merely the last known list of instances. However, the list is updated via a ZooKeeper watcher
* so it should be fresh within a window of a second or two.
*
* @return the list
*/
public List<ServiceInstance<T>> getInstances();
/**
* Listener for changes to a service cache
*/
public interface ServiceCacheListener extends ConnectionStateListener
{
/**
* Called when the cache has changed (instances added/deleted, etc.)
*/
public void cacheChanged();
}
标签:
原文地址:http://www.cnblogs.com/LiZhiW/p/4928964.html