本文整理汇总了Java中com.alibaba.dubbo.registry.integration.RegistryDirectory.getRouters方法的典型用法代码示例。如果您正苦于以下问题:Java RegistryDirectory.getRouters方法的具体用法?Java RegistryDirectory.getRouters怎么用?Java RegistryDirectory.getRouters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.registry.integration.RegistryDirectory
的用法示例。
在下文中一共展示了RegistryDirectory.getRouters方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
示例2: 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());
}
示例3: testNotifyRouterUrls
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
/**
* 1. notify twice, the second time notified router rules should completely replace the former one. 2. notify with
* no router url, do nothing to current routers 3. notify with only one router url, with router=clean, clear all
* current routers
*/
@Test
public void testNotifyRouterUrls() {
if (isScriptUnsupported) return;
RegistryDirectory registryDirectory = getRegistryDirectory();
URL routerurl = URL.valueOf(Constants.ROUTE_PROTOCOL + "://127.0.0.1:9096/");
URL routerurl2 = URL.valueOf(Constants.ROUTE_PROTOCOL + "://127.0.0.1:9097/");
List<URL> serviceUrls = new ArrayList<URL>();
// without ROUTER_KEY, the first router should not be created.
serviceUrls.add(routerurl.addParameter(Constants.CATEGORY_KEY, Constants.ROUTERS_CATEGORY).addParameter(Constants.TYPE_KEY, "javascript").addParameter(Constants.ROUTER_KEY,
"notsupported").addParameter(Constants.RULE_KEY,
"function test1(){}"));
serviceUrls.add(routerurl2.addParameter(Constants.CATEGORY_KEY, Constants.ROUTERS_CATEGORY).addParameter(Constants.TYPE_KEY, "javascript").addParameter(Constants.ROUTER_KEY,
ScriptRouterFactory.NAME).addParameter(Constants.RULE_KEY,
"function test1(){}"));
registryDirectory.notify(serviceUrls);
List<Router> routers = registryDirectory.getRouters();
//default invocation selector
Assert.assertEquals(1+1, routers.size());
Assert.assertTrue(ScriptRouter.class == routers.get(1).getClass() || ScriptRouter.class == routers.get(0).getClass());
registryDirectory.notify(new ArrayList<URL>());
routers = registryDirectory.getRouters();
Assert.assertEquals(1 + 1, routers.size());
Assert.assertTrue(ScriptRouter.class == routers.get(1).getClass() || ScriptRouter.class == routers.get(0).getClass());
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());
}
示例4: testNotifyRouterUrls
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
/**
* 1. notify twice, the second time notified router rules should completely replace the former one. 2. notify with
* no router url, do nothing to current routers 3. notify with only one router url, with router=clean, clear all
* current routers
*/
@Test
public void testNotifyRouterUrls() {
if (isScriptUnsupported) return;
RegistryDirectory registryDirectory = getRegistryDirectory();
URL routerurl = URL.valueOf(Constants.ROUTE_PROTOCOL + "://127.0.0.1:9096/");
URL routerurl2 = URL.valueOf(Constants.ROUTE_PROTOCOL + "://127.0.0.1:9097/");
List<URL> serviceUrls = new ArrayList<URL>();
// without ROUTER_KEY, the first router should not be created.
serviceUrls.add(routerurl.addParameter(Constants.CATEGORY_KEY, Constants.ROUTERS_CATEGORY).addParameter(Constants.TYPE_KEY, "javascript").addParameter(Constants.ROUTER_KEY,
"notsupported").addParameter(Constants.RULE_KEY,
"function test1(){}"));
serviceUrls.add(routerurl2.addParameter(Constants.CATEGORY_KEY, Constants.ROUTERS_CATEGORY).addParameter(Constants.TYPE_KEY, "javascript").addParameter(Constants.ROUTER_KEY,
ScriptRouterFactory.NAME).addParameter(Constants.RULE_KEY,
"function test1(){}"));
registryDirectory.notify(serviceUrls);
List<Router> routers = registryDirectory.getRouters();
//default invocation selector
Assert.assertEquals(1+1, routers.size());
Assert.assertEquals(ScriptRouter.class, routers.get(1).getClass());
registryDirectory.notify(new ArrayList<URL>());
routers = registryDirectory.getRouters();
Assert.assertEquals(1 + 1, routers.size());
Assert.assertEquals(ScriptRouter.class, routers.get(1).getClass());
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());
}
示例5: testNotifyRouterUrls
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
/**
* 1. notify twice, the second time notified router rules should completely replace the former one. 2. notify with
* no router url, do nothing to current routers 3. notify with only one router url, with router=clean, clear all
* current routers
*/
@Test
public void testNotifyRouterUrls() {
if (isScriptUnsupported) return;
RegistryDirectory registryDirectory = getRegistryDirectory();
URL routerurl = URL.valueOf(Constants.ROUTE_PROTOCOL + "://127.0.0.1:9096/");
URL routerurl2 = URL.valueOf(Constants.ROUTE_PROTOCOL + "://127.0.0.1:9097/");
List<URL> serviceUrls = new ArrayList<URL>();
// without ROUTER_KEY, the first router should not be created.
serviceUrls.add(routerurl.addParameter(Constants.CATEGORY_KEY, Constants.ROUTERS_CATEGORY).addParameter(Constants.TYPE_KEY, "javascript").addParameter(Constants.ROUTER_KEY,
"notsupported").addParameter(Constants.RULE_KEY,
"function test1(){}"));
serviceUrls.add(routerurl2.addParameter(Constants.CATEGORY_KEY, Constants.ROUTERS_CATEGORY).addParameter(Constants.TYPE_KEY, "javascript").addParameter(Constants.ROUTER_KEY,
ScriptRouterFactory.NAME).addParameter(Constants.RULE_KEY,
"function test1(){}"));
registryDirectory.notify(serviceUrls);
List<Router> routers = registryDirectory.getRouters();
//default invocation selector
Assert.assertEquals(1 + 1, routers.size());
Assert.assertTrue(ScriptRouter.class == routers.get(1).getClass() || ScriptRouter.class == routers.get(0).getClass());
registryDirectory.notify(new ArrayList<URL>());
routers = registryDirectory.getRouters();
Assert.assertEquals(1 + 1, routers.size());
Assert.assertTrue(ScriptRouter.class == routers.get(1).getClass() || ScriptRouter.class == routers.get(0).getClass());
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());
}