当前位置: 首页>>代码示例>>Java>>正文


Java RegistryDirectory类代码示例

本文整理汇总了Java中com.alibaba.dubbo.registry.integration.RegistryDirectory的典型用法代码示例。如果您正苦于以下问题:Java RegistryDirectory类的具体用法?Java RegistryDirectory怎么用?Java RegistryDirectory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RegistryDirectory类属于com.alibaba.dubbo.registry.integration包,在下文中一共展示了RegistryDirectory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createRegistry

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
public Registry createRegistry(URL url) {
    url = getRegistryURL(url);
    List<URL> urls = new ArrayList<URL>();
    urls.add(url.removeParameter(Constants.BACKUP_KEY));
    String backup = url.getParameter(Constants.BACKUP_KEY);
    if (backup != null && backup.length() > 0) {
        String[] addresses = Constants.COMMA_SPLIT_PATTERN.split(backup);
        for (String address : addresses) {
            urls.add(url.setAddress(address));
        }
    }
    RegistryDirectory<RegistryService> directory = new RegistryDirectory<RegistryService>(RegistryService.class, url.addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName()).addParameterAndEncoded(Constants.REFER_KEY, url.toParameterString()));
    Invoker<RegistryService> registryInvoker = cluster.join(directory);
    RegistryService registryService = proxyFactory.getProxy(registryInvoker);
    DubboRegistry registry = new DubboRegistry(registryInvoker, registryService);
    directory.setRegistry(registry);
    directory.setProtocol(protocol);
    directory.notify(urls);
    directory.subscribe(new URL(Constants.CONSUMER_PROTOCOL, NetUtils.getLocalHost(), 0, RegistryService.class.getName(), url.getParameters()));
    return registry;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:22,代码来源:DubboRegistryFactory.java

示例2: test_Notified_acceptProtocol2

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
@Test
public void test_Notified_acceptProtocol2() {
	URL errorPathUrl  = URL.valueOf("notsupport:/xxx");
	errorPathUrl = errorPathUrl.addParameterAndEncoded(Constants.REFER_KEY, "interface="+service + "&protocol=dubbo,injvm");
    RegistryDirectory registryDirectory = getRegistryDirectory(errorPathUrl);
    List<URL> serviceUrls = new ArrayList<URL>();
    URL dubbo1URL = URL.valueOf("dubbo://127.0.0.1:9098?lazy=true&methods=getXXX");
    URL dubbo2URL = URL.valueOf("injvm://127.0.0.1:9099?lazy=true&methods=getXXX");
    serviceUrls.add(dubbo1URL);
    serviceUrls.add(dubbo2URL);
    registryDirectory.notify(serviceUrls);

    invocation = new RpcInvocation();

    List<Invoker<DemoService>> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(2, invokers.size());
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:18,代码来源:RegistryDirectoryTest.java

示例3: testNofityOverrideUrls_Provider

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
/**
 * 测试针对某个provider的Override规则
 */
@Test
public void testNofityOverrideUrls_Provider(){
    RegistryDirectory registryDirectory = getRegistryDirectory();
    invocation = new RpcInvocation();
    
    List<URL> durls = new ArrayList<URL>();
    durls.add(SERVICEURL.setHost("10.20.30.140").addParameter("timeout", "1"));//一个一样,一个不一样
    durls.add(SERVICEURL2.setHost("10.20.30.141").addParameter("timeout", "2"));
    registryDirectory.notify(durls);
    
    durls = new ArrayList<URL>();
    durls.add(URL.valueOf("override://0.0.0.0?timeout=3"));
    durls.add(URL.valueOf("override://10.20.30.141:9092?timeout=4"));
    registryDirectory.notify(durls);
    
    List<Invoker<?>> invokers = registryDirectory.list(invocation);
    Invoker<?> aInvoker = invokers.get(0);
    Invoker<?> bInvoker = invokers.get(1);
    Assert.assertEquals("3",aInvoker.getUrl().getParameter("timeout"));
    Assert.assertEquals("4",bInvoker.getUrl().getParameter("timeout"));
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:25,代码来源:RegistryDirectoryTest.java

示例4: testNofityOverrideUrls_disabled_allProvider

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
/**
 * 测试override通过enable=false,禁用所有服务提供者
 * 预期:不能通过override禁用所有服务提供者.
 */
@Test
public void testNofityOverrideUrls_disabled_allProvider() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    invocation = new RpcInvocation();

    List<URL> durls = new ArrayList<URL>();
    durls.add(SERVICEURL.setHost("10.20.30.140"));
    durls.add(SERVICEURL.setHost("10.20.30.141"));
    registryDirectory.notify(durls);

    durls = new ArrayList<URL>();
    durls.add(URL.valueOf("override://0.0.0.0?" + Constants.ENABLED_KEY + "=false"));
    registryDirectory.notify(durls);

    List<Invoker<?>> invokers = registryDirectory.list(invocation);
    //不能通过override禁用所有服务提供者.
    Assert.assertEquals(2, invokers.size());
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:23,代码来源:RegistryDirectoryTest.java

示例5: test_Notified_acceptProtocol1

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
@Test
public void test_Notified_acceptProtocol1() {
	URL errorPathUrl  = URL.valueOf("notsupport:/xxx");
	errorPathUrl = errorPathUrl.addParameterAndEncoded(Constants.REFER_KEY, "interface="+service + "&protocol=dubbo");
    RegistryDirectory registryDirectory = getRegistryDirectory(errorPathUrl);
    List<URL> serviceUrls = new ArrayList<URL>();
    URL dubbo1URL = URL.valueOf("dubbo://127.0.0.1:9098?lazy=true&methods=getXXX");
    URL dubbo2URL = URL.valueOf("injvm://127.0.0.1:9098?lazy=true&methods=getXXX");
    serviceUrls.add(dubbo1URL);
    serviceUrls.add(dubbo2URL);
    registryDirectory.notify(serviceUrls);

    invocation = new RpcInvocation();

    List<Invoker<DemoService>> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(1, invokers.size());
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:18,代码来源:RegistryDirectoryTest.java

示例6: test_Notified_acceptProtocol0

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
@Test
public void test_Notified_acceptProtocol0() {
	URL errorPathUrl  = URL.valueOf("notsupport:/xxx?refer=" + URL.encode("interface="+service));
    RegistryDirectory registryDirectory = getRegistryDirectory(errorPathUrl);
    List<URL> serviceUrls = new ArrayList<URL>();
    URL dubbo1URL = URL.valueOf("dubbo://127.0.0.1:9098?lazy=true&methods=getXXX");
    URL dubbo2URL = URL.valueOf("injvm://127.0.0.1:9099?lazy=true&methods=getXXX");
    serviceUrls.add(dubbo1URL);
    serviceUrls.add(dubbo2URL);
    registryDirectory.notify(serviceUrls);

    invocation = new RpcInvocation();

    List<Invoker<DemoService>> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(2, invokers.size());
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:17,代码来源:RegistryDirectoryTest.java

示例7: test_NotifiedDubbo1

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
@Test
public void test_NotifiedDubbo1() {
    URL             errorPathUrl            = URL.valueOf("notsupport:/" + "xxx"+"?refer=" + URL.encode("interface="+service));
    RegistryDirectory registryDirectory = getRegistryDirectory(errorPathUrl);
    List<URL> serviceUrls = new ArrayList<URL>();
    URL Dubbo1URL = URL.valueOf("dubbo://127.0.0.1:9098?lazy=true");
    serviceUrls.add(Dubbo1URL.addParameter("methods", "getXXX"));
    registryDirectory.notify(serviceUrls);
    Assert.assertEquals(true, registryDirectory.isAvailable());

    invocation = new RpcInvocation();

    List<Invoker<DemoService>> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(1, invokers.size());

    invocation.setMethodName("getXXX");
    invokers = registryDirectory.list(invocation);
    Assert.assertEquals(1, invokers.size());
    Assert.assertEquals(DemoService.class.getName(), invokers.get(0).getUrl().getPath());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:21,代码来源:RegistryDirectoryTest.java

示例8: test_Notified1invokers

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
private void test_Notified1invokers(RegistryDirectory registryDirectory) {

        List<URL> serviceUrls = new ArrayList<URL>();
        serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1"));// .addParameter("refer.autodestroy", "true")
        registryDirectory.notify(serviceUrls);
        Assert.assertEquals(true, registryDirectory.isAvailable());

        invocation = new RpcInvocation();

        List invokers = registryDirectory.list(invocation);
        Assert.assertEquals(1, invokers.size());

        invocation.setMethodName("getXXX");
        invokers = registryDirectory.list(invocation);
        Assert.assertEquals(1, invokers.size());

        invocation.setMethodName("getXXX1");
        invokers = registryDirectory.list(invocation);
        Assert.assertEquals(1, invokers.size());

        invocation.setMethodName("getXXX2");
        invokers = registryDirectory.list(invocation);
        Assert.assertEquals(1, invokers.size());
    }
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:25,代码来源:RegistryDirectoryTest.java

示例9: test_Notified2invokers

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
private void test_Notified2invokers(RegistryDirectory registryDirectory) {
    List<URL> serviceUrls = new ArrayList<URL>();
    serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1"));
    serviceUrls.add(SERVICEURL2.addParameter("methods", "getXXX1,getXXX2"));
    serviceUrls.add(SERVICEURL2.addParameter("methods", "getXXX1,getXXX2"));

    registryDirectory.notify(serviceUrls);
    Assert.assertEquals(true, registryDirectory.isAvailable());

    invocation = new RpcInvocation();

    List invokers = registryDirectory.list(invocation);
    Assert.assertEquals(2, invokers.size());

    invocation.setMethodName("getXXX");
    invokers = registryDirectory.list(invocation);
    Assert.assertEquals(2, invokers.size());

    invocation.setMethodName("getXXX1");
    invokers = registryDirectory.list(invocation);
    Assert.assertEquals(2, invokers.size());

    invocation.setMethodName("getXXX2");
    invokers = registryDirectory.list(invocation);
    Assert.assertEquals(1, invokers.size());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:27,代码来源:RegistryDirectoryTest.java

示例10: testNotifyRouterUrls_Clean

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
@Test
public void testNotifyRouterUrls_Clean() {
    if (isScriptUnsupported) return;
    RegistryDirectory registryDirectory = getRegistryDirectory();
    URL routerurl = URL.valueOf(Constants.ROUTE_PROTOCOL + "://127.0.0.1:9096/").addParameter(Constants.ROUTER_KEY,
            "javascript").addParameter(Constants.RULE_KEY,
            "function test1(){}").addParameter(Constants.ROUTER_KEY,
            "script"); // FIX
    // BAD

    List<URL> serviceUrls = new ArrayList<URL>();
    // without ROUTER_KEY, the first router should not be created.
    serviceUrls.add(routerurl);
    registryDirectory.notify(serviceUrls);
    List routers = registryDirectory.getRouters();
    Assert.assertEquals(1 + 1, routers.size());

    serviceUrls.clear();
    serviceUrls.add(routerurl.addParameter(Constants.ROUTER_KEY, Constants.ROUTER_TYPE_CLEAR));
    registryDirectory.notify(serviceUrls);
    routers = registryDirectory.getRouters();
    Assert.assertEquals(0 + 1, routers.size());
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:24,代码来源:RegistryDirectoryTest.java

示例11: testParmeterRoute

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
/**
 * When the first arg of a method is String or Enum, Registry server can do parameter-value-based routing.
 */
@Test
public void testParmeterRoute() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    List<URL> serviceUrls = new ArrayList<URL>();
    serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1.napoli"));
    serviceUrls.add(SERVICEURL2.addParameter("methods", "getXXX1.MORGAN,getXXX2"));
    serviceUrls.add(SERVICEURL3.addParameter("methods", "getXXX1.morgan,getXXX2,getXXX3"));

    registryDirectory.notify(serviceUrls);

    invocation = new RpcInvocation(
                                   Constants.$INVOKE,
                                   new Class[] { String.class, String[].class, Object[].class },
                                   new Object[] { "getXXX1", new String[] { "Enum" }, new Object[] { Param.MORGAN } });

    List invokers = registryDirectory.list(invocation);
    Assert.assertEquals(1, invokers.size());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:22,代码来源:RegistryDirectoryTest.java

示例12: testNotifyoverrideUrls_withInvoker

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
/**
 * 测试override规则是否优先
 * 场景:与invoker 一起推override规则
 */
@Test
public void testNotifyoverrideUrls_withInvoker(){
    RegistryDirectory registryDirectory = getRegistryDirectory();
    
    List<URL> durls = new ArrayList<URL>();
    durls.add(SERVICEURL.addParameter("timeout", "1000"));
    durls.add(SERVICEURL2.addParameter("timeout", "1000").addParameter("connections", "10"));
    durls.add(URL.valueOf("override://0.0.0.0?timeout=1&connections=5"));

    registryDirectory.notify(durls);
    Assert.assertEquals(true, registryDirectory.isAvailable());
    
    //开始验证参数值

    invocation = new RpcInvocation();

    List<Invoker<?>> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(2, invokers.size());
    
    Assert.assertEquals("override rute must be first priority", "1", invokers.get(0).getUrl().getParameter("timeout"));
    Assert.assertEquals("override rute must be first priority", "5", invokers.get(0).getUrl().getParameter("connections"));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:27,代码来源:RegistryDirectoryTest.java

示例13: testNofityOverrideUrls_Clean1

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
/**
 * 测试清除override规则,同时下发清除规则和其他override规则
 * 测试是否能够恢复到推送时的providerUrl
 */
@Test
public void testNofityOverrideUrls_Clean1(){
    RegistryDirectory registryDirectory = getRegistryDirectory();
    invocation = new RpcInvocation();
    
    List<URL> durls = new ArrayList<URL>();
    durls.add(SERVICEURL.setHost("10.20.30.140").addParameter("timeout", "1"));
    registryDirectory.notify(durls);
    
    durls = new ArrayList<URL>();
    durls.add(URL.valueOf("override://0.0.0.0?timeout=1000"));
    registryDirectory.notify(durls);
    
    durls = new ArrayList<URL>();
    durls.add(URL.valueOf("override://0.0.0.0?timeout=3"));
    durls.add(URL.valueOf("override://0.0.0.0"));
    registryDirectory.notify(durls);
    
    List<Invoker<?>> invokers = registryDirectory.list(invocation);
    Invoker<?> aInvoker = invokers.get(0);
    //需要恢复到最初的providerUrl
    Assert.assertEquals("1",aInvoker.getUrl().getParameter("timeout"));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:28,代码来源:RegistryDirectoryTest.java

示例14: testNofityOverrideUrls_disabled_allProvider

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
/**
 * 测试override通过enable=false,禁用所有服务提供者
 * 预期:不能通过override禁用所有服务提供者.
 */
@Test
public void testNofityOverrideUrls_disabled_allProvider(){
	RegistryDirectory registryDirectory = getRegistryDirectory();
    invocation = new RpcInvocation();
    
    List<URL> durls = new ArrayList<URL>();
    durls.add(SERVICEURL.setHost("10.20.30.140"));
    durls.add(SERVICEURL.setHost("10.20.30.141"));
    registryDirectory.notify(durls);
    
    durls = new ArrayList<URL>();
    durls.add(URL.valueOf("override://0.0.0.0?"+Constants.ENABLED_KEY+"=false"));
    registryDirectory.notify(durls);
    
    List<Invoker<?>> invokers = registryDirectory.list(invocation);
    //不能通过override禁用所有服务提供者.
    Assert.assertEquals(2,invokers.size());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:23,代码来源:RegistryDirectoryTest.java

示例15: testNofityOverrideUrls_disabled_specifiedProvider

import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入依赖的package包/类
/**
 * 测试override通过enable=false,禁用指定服务提供者
 * 预期:可以禁用指定的服务提供者。
 */
@Test
public void testNofityOverrideUrls_disabled_specifiedProvider(){
	RegistryDirectory registryDirectory = getRegistryDirectory();
    invocation = new RpcInvocation();
    
    List<URL> durls = new ArrayList<URL>();
    durls.add(SERVICEURL.setHost("10.20.30.140"));
    durls.add(SERVICEURL.setHost("10.20.30.141"));
    registryDirectory.notify(durls);
    
    durls = new ArrayList<URL>();
    durls.add(URL.valueOf("override://10.20.30.140?"+Constants.DISABLED_KEY+"=true"));
    registryDirectory.notify(durls);
    
    List<Invoker<?>> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(1,invokers.size());
    Assert.assertEquals("10.20.30.141", invokers.get(0).getUrl().getHost());
    
    durls = new ArrayList<URL>();
    durls.add(URL.valueOf("empty://0.0.0.0?"+Constants.DISABLED_KEY+"=true&"+Constants.CATEGORY_KEY+"="+Constants.CONFIGURATORS_CATEGORY));
    registryDirectory.notify(durls);
    List<Invoker<?>> invokers2 = registryDirectory.list(invocation);
    Assert.assertEquals(2,invokers2.size());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:29,代码来源:RegistryDirectoryTest.java


注:本文中的com.alibaba.dubbo.registry.integration.RegistryDirectory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。