Search in sources :

Example 21 with Provider

use of com.alibaba.dubbo.registry.common.domain.Provider in project dubbo by alibaba.

the class Versions method show.

public void show(Long[] ids, Map<String, Object> context) {
    String version = (String) context.get("version");
    if (version != null && version.length() > 0) {
        List<Provider> providers = providerService.findAll();
        List<Consumer> consumers = consumerService.findAll();
        Set<String> parametersSet = new HashSet<String>();
        Set<String> applications = new HashSet<String>();
        for (Provider provider : providers) {
            parametersSet.add(provider.getParameters());
        }
        for (Consumer consumer : consumers) {
            parametersSet.add(consumer.getParameters());
        }
        Iterator<String> temp = parametersSet.iterator();
        while (temp.hasNext()) {
            Map<String, String> parameter = StringUtils.parseQueryString(temp.next());
            if (parameter != null) {
                String dubbo = parameter.get("dubbo");
                if (dubbo == null)
                    dubbo = "0.0.0";
                String application = parameter.get("application");
                if (version.equals(dubbo)) {
                    applications.add(application);
                }
            }
        }
        context.put("applications", applications);
    }
}
Also used : Consumer(com.alibaba.dubbo.registry.common.domain.Consumer) Provider(com.alibaba.dubbo.registry.common.domain.Provider) HashSet(java.util.HashSet)

Example 22 with Provider

use of com.alibaba.dubbo.registry.common.domain.Provider in project dubbo by alibaba.

the class Unregisterall method doExecute.

protected String doExecute(Map<String, Object> context) throws Exception {
    String address = request.getParameter("provider");
    if (address == null || address.length() == 0) {
        address = request.getParameter("client");
    }
    if (address == null || address.length() == 0) {
        throw new IllegalArgumentException("The url provider parameter is null! Usage: " + request.getRequestURL().toString() + "?provider=" + operatorAddress);
    }
    List<Provider> providers = providerService.findByAddress(address);
    if (providers != null && providers.size() > 0) {
        for (Provider provider : providers) {
            if (!currentUser.hasServicePrivilege(provider.getService())) {
                throw new IllegalStateException("The user " + currentUser + " have no privilege of service " + provider.getService());
            }
        }
        for (Provider provider : providers) {
            provider.setUsername(operator);
            provider.setOperatorAddress(operatorAddress);
            providerService.deleteStaticProvider(provider.getId());
        }
    }
    return "Unregister " + (providers == null ? 0 : providers.size()) + " services.";
}
Also used : Provider(com.alibaba.dubbo.registry.common.domain.Provider)

Aggregations

Provider (com.alibaba.dubbo.registry.common.domain.Provider)22 Override (com.alibaba.dubbo.registry.common.domain.Override)8 ArrayList (java.util.ArrayList)8 Consumer (com.alibaba.dubbo.registry.common.domain.Consumer)7 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)4 Route (com.alibaba.dubbo.registry.common.domain.Route)3 PrintWriter (java.io.PrintWriter)2 Set (java.util.Set)2 URL (com.alibaba.dubbo.common.URL)1 RootContextPath (com.alibaba.dubbo.governance.web.common.pulltool.RootContextPath)1 Owner (com.alibaba.dubbo.registry.common.domain.Owner)1 Map (java.util.Map)1