use of com.alibaba.dubbo.registry.integration.RegistryDirectory in project dubbo by alibaba.
the class RegistryDirectoryTest method testNofityOverrideUrls_Clean1.
/**
* 测试清除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"));
}
use of com.alibaba.dubbo.registry.integration.RegistryDirectory in project dubbo by alibaba.
the class RegistryDirectoryTest method testNotifyoverrideUrls_withInvoker.
/**
* 测试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"));
}
use of com.alibaba.dubbo.registry.integration.RegistryDirectory in project dubbo by alibaba.
the class RegistryDirectoryTest method getRegistryDirectory.
private RegistryDirectory getRegistryDirectory(URL url) {
RegistryDirectory registryDirectory = new RegistryDirectory(URL.class, url);
registryDirectory.setProtocol(protocol);
// asert empty
List invokers = registryDirectory.list(invocation);
Assert.assertEquals(0, invokers.size());
Assert.assertEquals(false, registryDirectory.isAvailable());
return registryDirectory;
}
use of com.alibaba.dubbo.registry.integration.RegistryDirectory in project dubbo by alibaba.
the class RegistryDirectoryTest method testNotified_Normal_withRouters.
/**
* 测试推送只有router的情况
*/
@Test
public void testNotified_Normal_withRouters() {
LogUtil.start();
RegistryDirectory registryDirectory = getRegistryDirectory();
test_Notified1invokers(registryDirectory);
test_Notified_only_routers(registryDirectory);
Assert.assertEquals(true, registryDirectory.isAvailable());
Assert.assertTrue("notify no invoker urls ,should not error", LogUtil.checkNoError());
LogUtil.stop();
test_Notified2invokers(registryDirectory);
}
use of com.alibaba.dubbo.registry.integration.RegistryDirectory in project dubbo by alibaba.
the class RegistryDirectoryTest method test_Notified_acceptProtocol1.
//测试protocol匹配,只选择匹配的protocol进行refer
@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());
}
Aggregations