Search in sources :

Example 1 with AbstractRegistry

use of org.apache.dubbo.registry.support.AbstractRegistry in project dubbo by alibaba.

the class ServiceCheckUtils method getConsumerAddressNum.

public static int getConsumerAddressNum(ConsumerModel consumerModel) {
    // TODO, only check one registry by default.
    int num = 0;
    Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
    if (CollectionUtils.isNotEmpty(registries)) {
        AbstractRegistry abstractRegistry = (AbstractRegistry) registries.iterator().next();
        for (Map.Entry<URL, Map<String, List<URL>>> entry : abstractRegistry.getNotified().entrySet()) {
            if (entry.getKey().getServiceKey().equals(consumerModel.getServiceKey())) {
                if (CollectionUtils.isNotEmptyMap(entry.getValue())) {
                    num = entry.getValue().size();
                }
            }
        }
    }
    return num;
}
Also used : AbstractRegistry(org.apache.dubbo.registry.support.AbstractRegistry) AbstractRegistry(org.apache.dubbo.registry.support.AbstractRegistry) Registry(org.apache.dubbo.registry.Registry) Map(java.util.Map) URL(org.apache.dubbo.common.URL)

Example 2 with AbstractRegistry

use of org.apache.dubbo.registry.support.AbstractRegistry in project incubator-dubbo-ops by apache.

the class ServiceControllerTest method tearDown.

@After
public void tearDown() throws Exception {
    final Set<URL> registered = ((AbstractRegistry) registry).getRegistered();
    for (final URL url : registered) {
        try {
            registry.unregister(url);
        } catch (Exception ignored) {
        }
    }
    TimeUnit.SECONDS.sleep(1);
}
Also used : AbstractRegistry(org.apache.dubbo.registry.support.AbstractRegistry) URL(org.apache.dubbo.common.URL) After(org.junit.After)

Aggregations

URL (org.apache.dubbo.common.URL)2 AbstractRegistry (org.apache.dubbo.registry.support.AbstractRegistry)2 Map (java.util.Map)1 Registry (org.apache.dubbo.registry.Registry)1 After (org.junit.After)1