本文整理汇总了Java中com.alibaba.dubbo.registry.integration.RegistryDirectory.notify方法的典型用法代码示例。如果您正苦于以下问题:Java RegistryDirectory.notify方法的具体用法?Java RegistryDirectory.notify怎么用?Java RegistryDirectory.notify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.registry.integration.RegistryDirectory
的用法示例。
在下文中一共展示了RegistryDirectory.notify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
示例3: 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());
}
示例4: 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"));
}
示例5: 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());
}
示例6: 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"));
}
示例7: testNofityOverrideUrls_CleanNOverride
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
/**
* 测试同时推送清除override和针对某个provider的override
* 看override是否能够生效
*/
@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);
Assert.assertEquals("4",aInvoker.getUrl().getParameter("timeout"));
}
示例8: testNotifyoverrideUrls_afterInvoker
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
/**
* 测试override规则是否优先
* 场景:先推送override,后推送invoker
*/
@Test
public void testNotifyoverrideUrls_afterInvoker() {
RegistryDirectory registryDirectory = getRegistryDirectory();
//在推送两个provider,directory状态恢复为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);
Assert.assertEquals(true, registryDirectory.isAvailable());
List<URL> overrideUrls = new ArrayList<URL>();
overrideUrls.add(URL.valueOf("override://0.0.0.0?timeout=1&connections=5"));
registryDirectory.notify(overrideUrls);
//开始验证参数值
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"));
}
示例9: testNofity_To_Decrease_provider
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
/**
* 测试override通过enable=false,禁用指定服务提供者
* 预期:可以禁用指定的服务提供者。
*/
@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);
Assert.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);
Assert.assertEquals(1, invokers2.size());
Assert.assertEquals("10.20.30.140", 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<?>> invokers3 = registryDirectory.list(invocation);
Assert.assertEquals(1, invokers3.size());
}
示例10: testforbid
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
private void testforbid(RegistryDirectory registryDirectory) {
invocation = new RpcInvocation();
List<URL> serviceUrls = new ArrayList<URL>();
serviceUrls.add(new URL(Constants.EMPTY_PROTOCOL, Constants.ANYHOST_VALUE, 0, service, Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY));
registryDirectory.notify(serviceUrls);
Assert.assertEquals("invokers size=0 ,then the registry directory is not available", false,
registryDirectory.isAvailable());
try {
registryDirectory.list(invocation);
fail("forbid must throw RpcException");
} catch (RpcException e) {
Assert.assertEquals(RpcException.FORBIDDEN_EXCEPTION, e.getCode());
}
}
示例11: testforbid
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
private void testforbid(RegistryDirectory registryDirectory) {
invocation = new RpcInvocation();
List<URL> serviceUrls = new ArrayList<URL>();
serviceUrls.add(new URL(Constants.EMPTY_PROTOCOL, Constants.ANYHOST_VALUE, 0, service, Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY));
registryDirectory.notify(serviceUrls);
Assert.assertEquals("invokers size=0 ,then the registry directory is not available", false,
registryDirectory.isAvailable());
try {
registryDirectory.list(invocation);
fail("forbid must throw RpcException");
} catch (RpcException e) {
Assert.assertEquals(RpcException.FORBIDDEN_EXCEPTION, e.getCode());
}
}
示例12: testNotifyoverrideUrls_afterInvoker
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
/**
* 测试override规则是否优先
* 场景:先推送override,后推送invoker
*/
@Test
public void testNotifyoverrideUrls_afterInvoker(){
RegistryDirectory registryDirectory = getRegistryDirectory();
//在推送两个provider,directory状态恢复为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);
Assert.assertEquals(true, registryDirectory.isAvailable());
List<URL> overrideUrls = new ArrayList<URL>();
overrideUrls.add(URL.valueOf("override://0.0.0.0?timeout=1&connections=5"));
registryDirectory.notify(overrideUrls);
//开始验证参数值
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"));
}
示例13: testNotifyoverrideUrls_Nouse
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
/**
* 测试override规则是否优先
* 场景:推送的规则与provider的参数是一样的
* 期望:不需要重新引用
*/
@Test
public void testNotifyoverrideUrls_Nouse(){
RegistryDirectory registryDirectory = getRegistryDirectory();
invocation = new RpcInvocation();
List<URL> durls = new ArrayList<URL>();
durls.add(SERVICEURL.addParameter("timeout", "1"));//一个一样,一个不一样
durls.add(SERVICEURL2.addParameter("timeout", "1").addParameter("connections", "5"));
registryDirectory.notify(durls);
List<Invoker<?>> invokers = registryDirectory.list(invocation);
Assert.assertEquals(2, invokers.size());
Invoker<?> a1Invoker = invokers.get(0);
Invoker<?> b1Invoker = invokers.get(1);
durls = new ArrayList<URL>();
durls.add(URL.valueOf("override://0.0.0.0?timeout=1&connections=5"));
registryDirectory.notify(durls);
Assert.assertEquals(true, registryDirectory.isAvailable());
invokers = registryDirectory.list(invocation);
Assert.assertEquals(2, invokers.size());
Invoker<?> a2Invoker = invokers.get(0);
Invoker<?> b2Invoker = invokers.get(1);
//参数不一样,必须重新引用
Assert.assertFalse("object not same",a1Invoker == a2Invoker);
//参数一样,不能重新引用
Assert.assertTrue("object same",b1Invoker == b2Invoker);
}
示例14: testEmptyNotifyCauseForbidden
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
/**
* Empty notify cause forbidden, non-empty notify cancels forbidden state
*/
@Test
public void testEmptyNotifyCauseForbidden() {
RegistryDirectory registryDirectory = getRegistryDirectory();
List invokers = null;
List<URL> serviceUrls = new ArrayList<URL>();
registryDirectory.notify(serviceUrls);
RpcInvocation inv = new RpcInvocation();
try {
invokers = registryDirectory.list(inv);
} catch (RpcException e) {
Assert.assertEquals(RpcException.FORBIDDEN_EXCEPTION, e.getCode());
Assert.assertEquals(false, registryDirectory.isAvailable());
}
serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1"));
serviceUrls.add(SERVICEURL2.addParameter("methods", "getXXX1,getXXX2"));
serviceUrls.add(SERVICEURL3.addParameter("methods", "getXXX1,getXXX2,getXXX3"));
registryDirectory.notify(serviceUrls);
inv.setMethodName("getXXX2");
invokers = registryDirectory.list(inv);
Assert.assertEquals(true, registryDirectory.isAvailable());
Assert.assertEquals(2, invokers.size());
}
示例15: testDubbo1UrlWithGenericInvocation
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
@Test
public void testDubbo1UrlWithGenericInvocation() {
RegistryDirectory registryDirectory = getRegistryDirectory();
List<URL> serviceUrls = new ArrayList<URL>();
URL serviceURL = SERVICEURL_DUBBO_NOPATH.addParameter("methods", "getXXX1,getXXX2,getXXX3");
serviceUrls.add(serviceURL);
registryDirectory.notify(serviceUrls);
// Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException;
invocation = new RpcInvocation(Constants.$INVOKE, new Class[] { String.class, String[].class, Object[].class },
new Object[] { "getXXX1", "", new Object[] {} });
List<Invoker> invokers = registryDirectory.list(invocation);
Assert.assertEquals(1, invokers.size());
Assert.assertEquals(serviceURL.setPath(service).addParameters("check", "false", "interface", DemoService.class.getName()), invokers.get(0).getUrl());
}