com.alibaba.dubbo.registry.integration
Class RegistryDirectory<T>

java.lang.Object
  extended by com.alibaba.dubbo.rpc.cluster.directory.AbstractDirectory<T>
      extended by com.alibaba.dubbo.registry.integration.RegistryDirectory<T>
All Implemented Interfaces:
Node, NotifyListener, Directory<T>

public class RegistryDirectory<T>
extends AbstractDirectory<T>
implements NotifyListener

RegistryDirectory

Author:
william.liangf, chao.liuc

Constructor Summary
RegistryDirectory(Class<T> serviceType, URL url)
           
 
Method Summary
 void destroy()
          destroy.
 List<Invoker<T>> doList(Invocation invocation)
           
 Class<T> getInterface()
          get service type.
 Map<String,List<Invoker<T>>> getMethodInvokerMap()
          Haomin: added for test purpose
 URL getUrl()
          get url.
 Map<String,Invoker<T>> getUrlInvokerMap()
          Haomin: added for test purpose
 boolean isAvailable()
          is available.
 void notify(List<URL> urls)
          当收到服务变更通知时触发。
 void setProtocol(Protocol protocol)
           
 void setRegistry(Registry registry)
           
 void subscribe(URL url)
           
static List<Configurator> toConfigurators(List<URL> urls)
          将overrideURL转换为map,供重新refer时使用.
 
Methods inherited from class com.alibaba.dubbo.rpc.cluster.directory.AbstractDirectory
getConsumerUrl, getRouters, isDestroyed, list, setConsumerUrl
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegistryDirectory

public RegistryDirectory(Class<T> serviceType,
                         URL url)
Method Detail

toConfigurators

public static List<Configurator> toConfigurators(List<URL> urls)
将overrideURL转换为map,供重新refer时使用. 每次下发全部规则,全部重新组装计算

Parameters:
urls - 契约:
1.override://0.0.0.0/...(或override://ip:port...?anyhost=true)¶1=value1...表示全局规则(对所有的提供者全部生效)
2.override://ip:port...?anyhost=false 特例规则(只针对某个提供者生效)
3.不支持override://规则... 需要注册中心自行计算.
4.不带参数的override://0.0.0.0/ 表示清除override
Returns:

setProtocol

public void setProtocol(Protocol protocol)

setRegistry

public void setRegistry(Registry registry)

subscribe

public void subscribe(URL url)

destroy

public void destroy()
Description copied from interface: Node
destroy.

Specified by:
destroy in interface Node
Overrides:
destroy in class AbstractDirectory<T>

notify

public void notify(List<URL> urls)
Description copied from interface: NotifyListener
当收到服务变更通知时触发。

通知需处理契约:
1. 总是以服务接口和数据类型为维度全量通知,即不会通知一个服务的同类型的部分数据,用户不需要对比上一次通知结果。
2. 订阅时的第一次通知,必须是一个服务的所有类型数据的全量通知。
3. 中途变更时,允许不同类型的数据分开通知,比如:providers, consumers, routers, overrides,允许只通知其中一种类型,但该类型的数据必须是全量的,不是增量的。
4. 如果一种类型的数据为空,需通知一个empty协议并带category参数的标识性URL数据。
5. 通知者(即注册中心实现)需保证通知的顺序,比如:单线程推送,队列串行化,带版本对比。

Specified by:
notify in interface NotifyListener
Parameters:
urls - 已注册信息列表,总不为空,含义同RegistryService.lookup(URL)的返回值。

doList

public List<Invoker<T>> doList(Invocation invocation)

getInterface

public Class<T> getInterface()
Description copied from interface: Directory
get service type.

Specified by:
getInterface in interface Directory<T>
Returns:
service type.

getUrl

public URL getUrl()
Description copied from interface: Node
get url.

Specified by:
getUrl in interface Node
Overrides:
getUrl in class AbstractDirectory<T>
Returns:
url.

isAvailable

public boolean isAvailable()
Description copied from interface: Node
is available.

Specified by:
isAvailable in interface Node
Returns:
available.

getUrlInvokerMap

public Map<String,Invoker<T>> getUrlInvokerMap()
Haomin: added for test purpose


getMethodInvokerMap

public Map<String,List<Invoker<T>>> getMethodInvokerMap()
Haomin: added for test purpose



Copyright © 2012–2017 Alibaba. All rights reserved.