use of org.apache.dubbo.registry.integration.RegistryDirectory in project dubbo by alibaba.
the class RegistryDirectoryTest method testNotifyoverrideUrls_afterInvoker.
/**
* Test whether the override rule have a high priority
* Scene: first push override , then push invoker
*/
@Test
public void testNotifyoverrideUrls_afterInvoker() {
RegistryDirectory registryDirectory = getRegistryDirectory();
// After pushing two provider, the directory state is restored to true
List<URL> serviceUrls = new ArrayList<URL>();
serviceUrls.add(SERVICEURL.addParameter("timeout", "1000"));
serviceUrls.add(SERVICEURL2.addParameter("timeout", "1000").addParameter("connections", "10"));
registryDirectory.notify(serviceUrls);
Assertions.assertTrue(registryDirectory.isAvailable());
List<URL> overrideUrls = new ArrayList<URL>();
overrideUrls.add(URL.valueOf("override://0.0.0.0?timeout=1&connections=5"));
registryDirectory.notify(overrideUrls);
// Start validation of parameter values
invocation = new RpcInvocation();
List<Invoker<?>> invokers = registryDirectory.list(invocation);
Assertions.assertEquals(2, invokers.size());
Assertions.assertEquals("1", invokers.get(0).getUrl().getParameter("timeout"), "override rute must be first priority");
Assertions.assertEquals("5", invokers.get(0).getUrl().getParameter("connections"), "override rute must be first priority");
}
use of org.apache.dubbo.registry.integration.RegistryDirectory in project dubbo by alibaba.
the class RegistryDirectoryTest method testNofityOverrideUrls_CleanNOverride.
/**
* Test the simultaneous push to clear the override and the override for a certain provider
* See if override can take effect
*/
@Test
public void testNofityOverrideUrls_CleanNOverride() {
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=3"));
durls.add(URL.valueOf("override://0.0.0.0"));
durls.add(URL.valueOf("override://10.20.30.140:9091?timeout=4"));
registryDirectory.notify(durls);
List<Invoker<?>> invokers = registryDirectory.list(invocation);
Invoker<?> aInvoker = invokers.get(0);
Assertions.assertEquals("4", aInvoker.getUrl().getParameter("timeout"));
}
use of org.apache.dubbo.registry.integration.RegistryDirectory in project dubbo by alibaba.
the class RegistryDirectoryTest method testNofity_To_Decrease_provider.
/**
* Test override disables a specified service provider through enable=false
* It is expected that a specified service provider can be disable.
*/
@Test
public void testNofity_To_Decrease_provider() {
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);
List<Invoker<?>> invokers = registryDirectory.list(invocation);
Assertions.assertEquals(2, invokers.size());
durls = new ArrayList<URL>();
durls.add(SERVICEURL.setHost("10.20.30.140"));
registryDirectory.notify(durls);
List<Invoker<?>> invokers2 = registryDirectory.list(invocation);
Assertions.assertEquals(1, invokers2.size());
Assertions.assertEquals("10.20.30.140", invokers2.get(0).getUrl().getHost());
durls = new ArrayList<URL>();
durls.add(URL.valueOf("empty://0.0.0.0?" + DISABLED_KEY + "=true&" + CATEGORY_KEY + "=" + CONFIGURATORS_CATEGORY));
registryDirectory.notify(durls);
List<Invoker<?>> invokers3 = registryDirectory.list(invocation);
Assertions.assertEquals(1, invokers3.size());
}
use of org.apache.dubbo.registry.integration.RegistryDirectory in project dubbo by alibaba.
the class RegistryDirectoryTest method test_NotifiedDubbo1.
// The test call is independent of the path of the registry url
@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);
Assertions.assertTrue(registryDirectory.isAvailable());
invocation = new RpcInvocation();
List<Invoker<DemoService>> invokers = registryDirectory.list(invocation);
Assertions.assertEquals(1, invokers.size());
invocation.setMethodName("getXXX");
invokers = registryDirectory.list(invocation);
Assertions.assertEquals(1, invokers.size());
Assertions.assertEquals(DemoService.class.getName(), invokers.get(0).getUrl().getPath());
}
use of org.apache.dubbo.registry.integration.RegistryDirectory in project dubbo by alibaba.
the class RegistryDirectoryTest method testNofityOverrideUrls_Clean1.
/**
* Test cleanup override rules, and sent remove rules and other override rules
* Whether the test can be restored to the providerUrl when it is pushed
*/
@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);
// Need to be restored to the original providerUrl
Assertions.assertEquals("3", aInvoker.getUrl().getParameter("timeout"));
}
Aggregations