Search in sources :

Example 6 with Provider

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

the class Disable 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.getUsername() + " have no privilege of service " + provider.getService());
            }
        }
        for (Provider provider : providers) {
            provider.setUsername(operator);
            provider.setOperatorAddress(operatorAddress);
            providerService.disableProvider(provider.getId());
        }
    }
    return "Disable " + (providers == null ? 0 : providers.size()) + " services.";
}
Also used : Provider(com.alibaba.dubbo.registry.common.domain.Provider)

Example 7 with Provider

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

the class Consumers method show.

public void show(Long id, Map<String, Object> context) {
    Consumer consumer = consumerService.findConsumer(id);
    List<Provider> providers = providerService.findByService(consumer.getService());
    List<Route> routes = routeService.findByService(consumer.getService());
    List<Override> overrides = overrideService.findByService(consumer.getService());
    List<Route> routed = new ArrayList<Route>();
    consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
    consumer.setRoutes(routed);
    OverrideUtils.setConsumerOverrides(consumer, overrides);
    context.put("consumer", consumer);
    context.put("providers", consumer.getProviders());
    context.put("routes", consumer.getRoutes());
    context.put("overrides", consumer.getOverrides());
}
Also used : Consumer(com.alibaba.dubbo.registry.common.domain.Consumer) ArrayList(java.util.ArrayList) Override(com.alibaba.dubbo.registry.common.domain.Override) Route(com.alibaba.dubbo.registry.common.domain.Route) Provider(com.alibaba.dubbo.registry.common.domain.Provider)

Example 8 with Provider

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

the class Loadbalances method add.

public void add(Map<String, Object> context) {
    String service = (String) context.get("service");
    if (service != null && service.length() > 0 && !service.contains("*")) {
        List<Provider> providerList = providerService.findByService(service);
        List<String> addressList = new ArrayList<String>();
        for (Provider provider : providerList) {
            addressList.add(provider.getUrl().split("://")[1].split("/")[0]);
        }
        context.put("addressList", addressList);
        context.put("service", service);
        context.put("methods", CollectionUtils.sort(providerService.findMethodsByService(service)));
    } else {
        List<String> serviceList = Tool.sortSimpleName(providerService.findServices());
        context.put("serviceList", serviceList);
    }
    if (context.get("input") != null)
        context.put("input", context.get("input"));
}
Also used : ArrayList(java.util.ArrayList) Provider(com.alibaba.dubbo.registry.common.domain.Provider)

Example 9 with Provider

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

the class Providers method show.

public void show(Long id, Map<String, Object> context) {
    Provider provider = providerService.findProvider(id);
    if (provider != null && provider.isDynamic()) {
        List<Override> overrides = overrideService.findByServiceAndAddress(provider.getService(), provider.getAddress());
        OverrideUtils.setProviderOverrides(provider, overrides);
    }
    context.put("provider", provider);
}
Also used : Override(com.alibaba.dubbo.registry.common.domain.Override) Provider(com.alibaba.dubbo.registry.common.domain.Provider)

Example 10 with Provider

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

the class Dump method versions.

public void versions(Map<String, Object> context) throws IOException {
    PrintWriter writer = response.getWriter();
    List<Provider> providers = providerDAO.findAll();
    List<Consumer> consumers = consumerDAO.findAll();
    Set<String> parametersSet = new HashSet<String>();
    Map<String, Set<String>> versions = new HashMap<String, Set<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 dubboversion = parameter.get("dubbo");
            String app = parameter.get("application");
            if (versions.get(dubboversion) == null) {
                Set<String> apps = new HashSet<String>();
                versions.put(dubboversion, apps);
            }
            versions.get(dubboversion).add(app);
        }
    }
    for (String version : versions.keySet()) {
        writer.println("dubbo version: " + version);
        writer.println(StringUtils.join(versions.get(version), "\n"));
        writer.println("\n");
    }
    context.put("versions", versions);
    writer.flush();
    response.setContentType("text/plain");
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Provider(com.alibaba.dubbo.registry.common.domain.Provider) Consumer(com.alibaba.dubbo.registry.common.domain.Consumer) PrintWriter(java.io.PrintWriter) HashSet(java.util.HashSet)

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