Java Code Examples for com.alibaba.dubbo.registry.integration.RegistryDirectory#destroy()

The following examples show how to use com.alibaba.dubbo.registry.integration.RegistryDirectory#destroy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegistryDirectoryTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
/**
 * When destroying, RegistryDirectory should: 1. be disconnected from Registry 2. destroy all invokers
 */
@Test
public void testDestroy() {
    RegistryDirectory registryDirectory = getRegistryDirectory();

    List<URL> serviceUrls = new ArrayList<URL>();
    serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1"));
    serviceUrls.add(SERVICEURL2.addParameter("methods", "getXXX1,getXXX2"));
    serviceUrls.add(SERVICEURL3.addParameter("methods", "getXXX1,getXXX2,getXXX3"));

    registryDirectory.notify(serviceUrls);
    List<Invoker> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(true, registryDirectory.isAvailable());
    Assert.assertEquals(true, invokers.get(0).isAvailable());

    registryDirectory.destroy();
    Assert.assertEquals(false, registryDirectory.isAvailable());
    Assert.assertEquals(false, invokers.get(0).isAvailable());
    registryDirectory.destroy();

    Map<String, List<Invoker<RegistryDirectoryTest>>> methodInvokerMap = registryDirectory.getMethodInvokerMap();
    Map<String, Invoker<RegistryDirectoryTest>> urlInvokerMap = registryDirectory.getUrlInvokerMap();

    Assert.assertTrue(methodInvokerMap == null);
    Assert.assertEquals(0, urlInvokerMap.size());
    // List<U> urls = mockRegistry.getSubscribedUrls();

    RpcInvocation inv = new RpcInvocation();
    try {
        registryDirectory.list(inv);
        fail();
    } catch (RpcException e) {
        Assert.assertTrue(e.getMessage().contains("already destroyed"));
    }
}
 
Example 2
Source File: RegistryDirectoryTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroy_WithDestroyRegistry() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    CountDownLatch latch = new CountDownLatch(1);
    registryDirectory.setRegistry(new MockRegistry(latch));
    registryDirectory.subscribe(URL.valueOf("consumer://" + NetUtils.getLocalHost() + "/DemoService?category=providers"));
    registryDirectory.destroy();
    Assert.assertEquals(0, latch.getCount());
}
 
Example 3
Source File: RegistryDirectoryTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * When destroying, RegistryDirectory should: 1. be disconnected from Registry 2. destroy all invokers
 */
@Test
public void testDestroy() {
    RegistryDirectory registryDirectory = getRegistryDirectory();

    List<URL> serviceUrls = new ArrayList<URL>();
    serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1"));
    serviceUrls.add(SERVICEURL2.addParameter("methods", "getXXX1,getXXX2"));
    serviceUrls.add(SERVICEURL3.addParameter("methods", "getXXX1,getXXX2,getXXX3"));

    registryDirectory.notify(serviceUrls);
    List<Invoker> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(true, registryDirectory.isAvailable());
    Assert.assertEquals(true, invokers.get(0).isAvailable());

    registryDirectory.destroy();
    Assert.assertEquals(false, registryDirectory.isAvailable());
    Assert.assertEquals(false, invokers.get(0).isAvailable());
    registryDirectory.destroy();

    Map<String, List<Invoker<RegistryDirectoryTest>>> methodInvokerMap = registryDirectory.getMethodInvokerMap();
    Map<String, Invoker<RegistryDirectoryTest>> urlInvokerMap = registryDirectory.getUrlInvokerMap();

    Assert.assertTrue(methodInvokerMap == null);
    Assert.assertEquals(0, urlInvokerMap.size());
    // List<U> urls = mockRegistry.getSubscribedUrls();

    RpcInvocation inv = new RpcInvocation();
    try {
        registryDirectory.list(inv);
        fail();
    } catch (RpcException e) {
        Assert.assertTrue(e.getMessage().contains("already destroyed"));
    }
}
 
Example 4
Source File: RegistryDirectoryTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroy_WithDestroyRegistry() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    CountDownLatch latch = new CountDownLatch(1);
    registryDirectory.setRegistry(new MockRegistry(latch));
    registryDirectory.subscribe(URL.valueOf("consumer://" + NetUtils.getLocalHost() + "/DemoService?category=providers"));
    registryDirectory.destroy();
    Assert.assertEquals(0, latch.getCount());
}
 
Example 5
Source File: RegistryDirectoryTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
/**
 * When destroying, RegistryDirectory should: 1. be disconnected from Registry 2. destroy all invokers
 */
@Test
public void testDestroy() {
    RegistryDirectory registryDirectory = getRegistryDirectory();

    List<URL> serviceUrls = new ArrayList<URL>();
    serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1"));
    serviceUrls.add(SERVICEURL2.addParameter("methods", "getXXX1,getXXX2"));
    serviceUrls.add(SERVICEURL3.addParameter("methods", "getXXX1,getXXX2,getXXX3"));

    registryDirectory.notify(serviceUrls);
    List<Invoker> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(true, registryDirectory.isAvailable());
    Assert.assertEquals(true, invokers.get(0).isAvailable());

    registryDirectory.destroy();
    Assert.assertEquals(false, registryDirectory.isAvailable());
    Assert.assertEquals(false, invokers.get(0).isAvailable());
    registryDirectory.destroy();

    Map<String, List<Invoker<RegistryDirectoryTest>>> methodInvokerMap = registryDirectory.getMethodInvokerMap();
    Map<String, Invoker<RegistryDirectoryTest>> urlInvokerMap = registryDirectory.getUrlInvokerMap();

    Assert.assertTrue(methodInvokerMap == null);
    Assert.assertEquals(0, urlInvokerMap.size());
    // List<U> urls = mockRegistry.getSubscribedUrls();

    RpcInvocation inv = new RpcInvocation();
    try {
        registryDirectory.list(inv);
        fail();
    } catch (RpcException e) {
        Assert.assertTrue(e.getMessage().contains("already destroyed"));
    }
}
 
Example 6
Source File: RegistryDirectoryTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroy_WithDestroyRegistry() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    CountDownLatch latch = new CountDownLatch(1);
    registryDirectory.setRegistry(new MockRegistry(latch));
    registryDirectory.subscribe(URL.valueOf("consumer://" + NetUtils.getLocalHost() + "/DemoService?category=providers"));
    registryDirectory.destroy();
    Assert.assertEquals(0, latch.getCount());
}
 
Example 7
Source File: RegistryDirectoryTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * When destroying, RegistryDirectory should: 1. be disconnected from Registry 2. destroy all invokers
 */
@Test
public void testDestroy() {
    RegistryDirectory registryDirectory = getRegistryDirectory();

    List<URL> serviceUrls = new ArrayList<URL>();
    serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1"));
    serviceUrls.add(SERVICEURL2.addParameter("methods", "getXXX1,getXXX2"));
    serviceUrls.add(SERVICEURL3.addParameter("methods", "getXXX1,getXXX2,getXXX3"));

    registryDirectory.notify(serviceUrls);
    List<Invoker> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(true, registryDirectory.isAvailable());
    Assert.assertEquals(true, invokers.get(0).isAvailable());

    registryDirectory.destroy();
    Assert.assertEquals(false, registryDirectory.isAvailable());
    Assert.assertEquals(false, invokers.get(0).isAvailable());
    registryDirectory.destroy();

    Map<String, List<Invoker<RegistryDirectoryTest>>> methodInvokerMap = registryDirectory.getMethodInvokerMap();
    Map<String, Invoker<RegistryDirectoryTest>> urlInvokerMap = registryDirectory.getUrlInvokerMap();

    Assert.assertTrue(methodInvokerMap == null);
    Assert.assertEquals(0, urlInvokerMap.size());
    // List<U> urls = mockRegistry.getSubscribedUrls();

    RpcInvocation inv = new RpcInvocation();
    try {
        registryDirectory.list(inv);
        fail();
    } catch (RpcException e) {
        Assert.assertTrue(e.getMessage().contains("already destroyed"));
    }
}
 
Example 8
Source File: RegistryDirectoryTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroy_WithDestroyRegistry() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    CountDownLatch latch = new CountDownLatch(1);
    registryDirectory.setRegistry(new MockRegistry(latch));
    registryDirectory.subscribe(URL.valueOf("consumer://" + NetUtils.getLocalHost() + "/DemoService?category=providers"));
    registryDirectory.destroy();
    Assert.assertEquals(0, latch.getCount());
}
 
Example 9
Source File: RegistryDirectoryTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * When destroying, RegistryDirectory should: 1. be disconnected from Registry 2. destroy all invokers
 */
@Test
public void testDestroy() {
    RegistryDirectory registryDirectory = getRegistryDirectory();

    List<URL> serviceUrls = new ArrayList<URL>();
    serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1"));
    serviceUrls.add(SERVICEURL2.addParameter("methods", "getXXX1,getXXX2"));
    serviceUrls.add(SERVICEURL3.addParameter("methods", "getXXX1,getXXX2,getXXX3"));

    registryDirectory.notify(serviceUrls);
    List<Invoker> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(true, registryDirectory.isAvailable());
    Assert.assertEquals(true, invokers.get(0).isAvailable());

    registryDirectory.destroy();
    Assert.assertEquals(false, registryDirectory.isAvailable());
    Assert.assertEquals(false, invokers.get(0).isAvailable());
    registryDirectory.destroy();

    Map<String, List<Invoker<RegistryDirectoryTest>>> methodInvokerMap = registryDirectory.getMethodInvokerMap();
    Map<String, Invoker<RegistryDirectoryTest>> urlInvokerMap = registryDirectory.getUrlInvokerMap();

    Assert.assertTrue(methodInvokerMap == null);
    Assert.assertEquals(0, urlInvokerMap.size());
    // List<U> urls = mockRegistry.getSubscribedUrls();

    RpcInvocation inv = new RpcInvocation();
    try {
        registryDirectory.list(inv);
        fail();
    } catch (RpcException e) {
        Assert.assertTrue(e.getMessage().contains("already destroyed"));
    }
}
 
Example 10
Source File: RegistryDirectoryTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroy_WithDestroyRegistry() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    CountDownLatch latch = new CountDownLatch(1);
    registryDirectory.setRegistry(new MockRegistry(latch));
    registryDirectory.subscribe(URL.valueOf("consumer://" + NetUtils.getLocalHost() + "/DemoService?category=providers"));
    registryDirectory.destroy();
    Assert.assertEquals(0, latch.getCount());
}
 
Example 11
Source File: RegistryDirectoryTest.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
@Test
public void testDestroy_WithDestroyRegistry_WithError() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    registryDirectory.setRegistry(new MockRegistry(true));
    registryDirectory.destroy();
}
 
Example 12
Source File: RegistryDirectoryTest.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Test
public void testDestroy_WithDestroyRegistry_WithError() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    registryDirectory.setRegistry(new MockRegistry(true));
    registryDirectory.destroy();
}
 
Example 13
Source File: RegistryDirectoryTest.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
@Test
public void testDestroy_WithDestroyRegistry_WithError() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    registryDirectory.setRegistry(new MockRegistry(true));
    registryDirectory.destroy();
}
 
Example 14
Source File: RegistryDirectoryTest.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Test
public void testDestroy_WithDestroyRegistry_WithError() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    registryDirectory.setRegistry(new MockRegistry(true));
    registryDirectory.destroy();
}
 
Example 15
Source File: RegistryDirectoryTest.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Test
public void testDestroy_WithDestroyRegistry_WithError() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    registryDirectory.setRegistry(new MockRegistry(true));
    registryDirectory.destroy();
}