Search in sources :

Example 11 with URL

use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.

the class ProviderServiceImpl method updateProvider.

public void updateProvider(Provider provider) {
    Long id = provider.getId();
    if (id == null) {
        throw new IllegalStateException("no provider id");
    }
    URL oldProvider = findProviderUrl(id);
    if (oldProvider == null) {
        throw new IllegalStateException("Provider was changed!");
    }
    URL newProvider = provider.toUrl();
    registryService.unregister(oldProvider);
    registryService.register(newProvider);
}
Also used : URL(com.alibaba.dubbo.common.URL)

Example 12 with URL

use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.

the class ProviderServiceImpl method create.

public void create(Provider provider) {
    URL url = provider.toUrl();
    registryService.register(url);
}
Also used : URL(com.alibaba.dubbo.common.URL)

Example 13 with URL

use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.

the class ProviderServiceImpl method findApplications.

public List<String> findApplications() {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
    if (providerUrls == null)
        return ret;
    for (Map.Entry<String, Map<Long, URL>> e1 : providerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for (Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            String app = u.getParameter(Constants.APPLICATION_KEY);
            if (app != null)
                ret.add(app);
        }
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) URL(com.alibaba.dubbo.common.URL)

Example 14 with URL

use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.

the class ProviderServiceImpl method findAddressesByService.

public List<String> findAddressesByService(String service) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
    if (null == providerUrls)
        return ret;
    for (Map.Entry<Long, URL> e2 : providerUrls.get(service).entrySet()) {
        URL u = e2.getValue();
        String app = u.getAddress();
        if (app != null)
            ret.add(app);
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) URL(com.alibaba.dubbo.common.URL)

Example 15 with URL

use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.

the class ProviderServiceImpl method deleteStaticProvider.

public void deleteStaticProvider(Long id) {
    URL oldProvider = findProviderUrl(id);
    if (oldProvider == null) {
        throw new IllegalStateException("Provider was changed!");
    }
    registryService.unregister(oldProvider);
}
Also used : URL(com.alibaba.dubbo.common.URL)

Aggregations

URL (com.alibaba.dubbo.common.URL)283 Test (org.junit.Test)157 ArrayList (java.util.ArrayList)73 RpcInvocation (com.alibaba.dubbo.rpc.RpcInvocation)62 HashMap (java.util.HashMap)39 Result (com.alibaba.dubbo.rpc.Result)37 Map (java.util.Map)36 Invoker (com.alibaba.dubbo.rpc.Invoker)34 List (java.util.List)30 ConcurrentMap (java.util.concurrent.ConcurrentMap)29 RegistryDirectory (com.alibaba.dubbo.registry.integration.RegistryDirectory)28 Invocation (com.alibaba.dubbo.rpc.Invocation)28 RpcException (com.alibaba.dubbo.rpc.RpcException)22 NotifyListener (com.alibaba.dubbo.registry.NotifyListener)20 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)17 RpcResult (com.alibaba.dubbo.rpc.RpcResult)16 DemoService (com.alibaba.dubbo.rpc.support.DemoService)12 Set (java.util.Set)12 ConcurrentHashSet (com.alibaba.dubbo.common.utils.ConcurrentHashSet)11 Protocol (com.alibaba.dubbo.rpc.Protocol)10