Java Code Examples for com.alibaba.dubbo.registry.NotifyListener#notify()

The following examples show how to use com.alibaba.dubbo.registry.NotifyListener#notify() . 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: MulticastRegistry.java    From dubbox with Apache License 2.0 6 votes vote down vote up
protected void registered(URL url) {
    for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) {
        URL key = entry.getKey();
        if (UrlUtils.isMatch(key, url)) {
            Set<URL> urls = received.get(key);
            if (urls == null) {
                received.putIfAbsent(key, new ConcurrentHashSet<URL>());
                urls = received.get(key);
            }
            urls.add(url);
            List<URL> list = toList(urls);
            for (NotifyListener listener : entry.getValue()) {
                notify(key, listener, list);
                synchronized (listener) {
                    listener.notify();
                }
            }
        }
    }
}
 
Example 2
Source File: MulticastRegistry.java    From dubbox with Apache License 2.0 6 votes vote down vote up
protected void registered(URL url) {
    for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) {
        URL key = entry.getKey();
        if (UrlUtils.isMatch(key, url)) {
            Set<URL> urls = received.get(key);
            if (urls == null) {
                received.putIfAbsent(key, new ConcurrentHashSet<URL>());
                urls = received.get(key);
            }
            urls.add(url);
            List<URL> list = toList(urls);
            for (NotifyListener listener : entry.getValue()) {
                notify(key, listener, list);
                synchronized (listener) {
                    listener.notify();
                }
            }
        }
    }
}
 
Example 3
Source File: RegistryProtocolTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void testNotifyOverride() throws Exception{
    URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl);
    Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl);
    Exporter<?> exporter = protocol.export(invoker);
    RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol();
    NotifyListener listener = getListener(rprotocol);
    List<URL> urls = new ArrayList<URL>();
    urls.add(URL.valueOf("override://0.0.0.0/?timeout=1000"));
    urls.add(URL.valueOf("override://0.0.0.0/"+ service + "?timeout=100"));
    urls.add(URL.valueOf("override://0.0.0.0/"+ service + "?x=y"));
    listener.notify(urls);
    
    assertEquals(true, exporter.getInvoker().isAvailable());
    assertEquals("100", exporter.getInvoker().getUrl().getParameter("timeout"));
    assertEquals("y", exporter.getInvoker().getUrl().getParameter("x"));
    
    exporter.unexport();
    assertEquals(false, exporter.getInvoker().isAvailable());
    destroyRegistryProtocol();
    
}
 
Example 4
Source File: RegistryProtocolTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
/**
 * The name of the service does not match and can't override invoker
 * Service name matching, service version number mismatch
 */
@Test
public void testNotifyOverride_notmatch() throws Exception {
    URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl);
    Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl);
    Exporter<?> exporter = protocol.export(invoker);
    RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol();
    NotifyListener listener = getListener(rprotocol);
    List<URL> urls = new ArrayList<URL>();
    urls.add(URL.valueOf("override://0.0.0.0/com.alibaba.dubbo.registry.protocol.HackService?timeout=100"));
    listener.notify(urls);
    assertEquals(true, exporter.getInvoker().isAvailable());
    assertEquals(null, exporter.getInvoker().getUrl().getParameter("timeout"));
    exporter.unexport();
    destroyRegistryProtocol();
}
 
Example 5
Source File: MulticastRegistry.java    From dubbox with Apache License 2.0 6 votes vote down vote up
protected void registered(URL url) {
    for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) {
        URL key = entry.getKey();
        if (UrlUtils.isMatch(key, url)) {
            Set<URL> urls = received.get(key);
            if (urls == null) {
                received.putIfAbsent(key, new ConcurrentHashSet<URL>());
                urls = received.get(key);
            }
            urls.add(url);
            List<URL> list = toList(urls);
            for (NotifyListener listener : entry.getValue()) {
                notify(key, listener, list);
                synchronized (listener) {
                    listener.notify();
                }
            }
        }
    }
}
 
Example 6
Source File: MockRegistry.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void subscribe(URL url, NotifyListener listener) {
    this.subscribedUrl = url;
    List<URL> urls = new ArrayList<URL>();
    
    urls.add(url.setProtocol("mockprotocol")
                .removeParameter(Constants.CATEGORY_KEY)
                .addParameter(Constants.METHODS_KEY, "sayHello"));
    
    listener.notify(urls);
}
 
Example 7
Source File: SimpleRegistryService.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected void registered(URL url) {
    for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) {
        URL key = entry.getKey();
        if (UrlUtils.isMatch(key, url)) {
            List<URL> list = lookup(key);
            for (NotifyListener listener : entry.getValue()) {
            	listener.notify(list);
            }
        }
    }
}
 
Example 8
Source File: SimpleRegistryService.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected void unregistered(URL url) {
    for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) {
        URL key = entry.getKey();
        if (UrlUtils.isMatch(key, url)) {
            List<URL> list = lookup(key);
            for (NotifyListener listener : entry.getValue()) {
            	listener.notify(list);
            }
        }
    }
}
 
Example 9
Source File: SimpleRegistryService.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public void unsubscribe(String service, URL url, NotifyListener listener) {
    super.unsubscribe(service, url, listener);
    String client = RpcContext.getContext().getRemoteAddressString();
    Map<String, NotifyListener> listeners = remoteListeners.get(client);
    if (listeners != null && listeners.size() > 0) {
        listeners.remove(service);
    }
    List<URL> urls = getRegistered().get(service);
    if (urls != null && urls.size() > 0) {
        listener.notify(urls);
    }
}
 
Example 10
Source File: SimpleRegistryService.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@Override
public void unsubscribe(String service, URL url, NotifyListener listener) {
    super.unsubscribe(service, url, listener);
    String client = RpcContext.getContext().getRemoteAddressString();
    Map<String, NotifyListener> listeners = remoteListeners.get(client);
    if (listeners != null && listeners.size() > 0) {
        listeners.remove(service);
    }
    List<URL> urls = getRegistered().get(service);
    if (urls != null && urls.size() > 0) {
        listener.notify(urls);
    }
}
 
Example 11
Source File: MockRegistry.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void subscribe(URL url, NotifyListener listener) {
    this.subscribedUrl = url;
    List<URL> urls = new ArrayList<URL>();
    
    urls.add(url.setProtocol("mockprotocol")
                .removeParameter(Constants.CATEGORY_KEY)
                .addParameter(Constants.METHODS_KEY, "sayHello"));
    
    listener.notify(urls);
}
 
Example 12
Source File: SimpleRegistryService.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
public void unsubscribe(String service, URL url, NotifyListener listener) {
    super.unsubscribe(service, url, listener);
    String client = RpcContext.getContext().getRemoteAddressString();
    Map<String, NotifyListener> listeners = remoteListeners.get(client);
    if (listeners != null && listeners.size() > 0) {
        listeners.remove(service);
    }
    List<URL> urls = getRegistered().get(service);
    if (urls != null && urls.size() > 0) {
        listener.notify(urls);
    }
}
 
Example 13
Source File: SimpleRegistryService.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected void unregistered(URL url) {
    for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) {
        URL key = entry.getKey();
        if (UrlUtils.isMatch(key, url)) {
            List<URL> list = lookup(key);
            for (NotifyListener listener : entry.getValue()) {
            	listener.notify(list);
            }
        }
    }
}
 
Example 14
Source File: SimpleRegistryService.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected void registered(URL url) {
    for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) {
        URL key = entry.getKey();
        if (UrlUtils.isMatch(key, url)) {
            List<URL> list = lookup(key);
            for (NotifyListener listener : entry.getValue()) {
            	listener.notify(list);
            }
        }
    }
}
 
Example 15
Source File: AbstractRegistryService.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
protected void notify(String service, List<URL> urls, NotifyListener listener) {
    listener.notify(urls);
}
 
Example 16
Source File: AbstractRegistryService.java    From dubbox with Apache License 2.0 4 votes vote down vote up
protected void notify(String service, List<URL> urls, NotifyListener listener) {
    listener.notify(urls);
}
 
Example 17
Source File: AbstractRegistryService.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
protected void notify(String service, List<URL> urls, NotifyListener listener) {
    listener.notify(urls);
}
 
Example 18
Source File: AbstractRegistryService.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
protected void notify(String service, List<URL> urls, NotifyListener listener) {
    listener.notify(urls);
}
 
Example 19
Source File: AbstractRegistryService.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
protected void notify(String service, List<URL> urls, NotifyListener listener) {
    listener.notify(urls);
}
 
Example 20
Source File: AbstractRegistryService.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
protected void notify(String service, List<URL> urls, NotifyListener listener) {
    listener.notify(urls);
}