Search in sources :

Example 11 with Consumer

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

the class SyncUtils method url2Consumer.

public static Consumer url2Consumer(Pair<Long, URL> pair) {
    if (pair == null) {
        return null;
    }
    Long id = pair.getKey();
    URL url = pair.getValue();
    if (null == url)
        return null;
    Consumer c = new Consumer();
    c.setId(id);
    c.setService(url.getServiceKey());
    c.setAddress(url.getHost());
    c.setApplication(url.getParameter(Constants.APPLICATION_KEY));
    c.setParameters(url.toParameterString());
    return c;
}
Also used : Consumer(com.alibaba.dubbo.registry.common.domain.Consumer) URL(com.alibaba.dubbo.common.URL)

Example 12 with Consumer

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

the class Dump method consumers.

public void consumers(Map<String, Object> context) throws IOException {
    PrintWriter writer = response.getWriter();
    List<Consumer> consumers = consumerDAO.findAll();
    List<String> sortedConsumerss = new ArrayList<String>();
    for (Consumer consumer : consumers) {
        sortedConsumerss.add(consumer.getAddress() + " " + consumer.getService());
    }
    Collections.sort(sortedConsumerss);
    writer.println(sortedConsumerss.size() + " consumer instance");
    for (String consumer : sortedConsumerss) {
        writer.println(consumer);
    }
    writer.flush();
    response.setContentType("text/plain");
}
Also used : Consumer(com.alibaba.dubbo.registry.common.domain.Consumer) ArrayList(java.util.ArrayList) PrintWriter(java.io.PrintWriter)

Example 13 with Consumer

use of com.alibaba.dubbo.registry.common.domain.Consumer 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)

Aggregations

Consumer (com.alibaba.dubbo.registry.common.domain.Consumer)13 Provider (com.alibaba.dubbo.registry.common.domain.Provider)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 Route (com.alibaba.dubbo.registry.common.domain.Route)5 HashSet (java.util.HashSet)5 Override (com.alibaba.dubbo.registry.common.domain.Override)4 Set (java.util.Set)3 PrintWriter (java.io.PrintWriter)2 Map (java.util.Map)2 URL (com.alibaba.dubbo.common.URL)1 RootContextPath (com.alibaba.dubbo.governance.web.common.pulltool.RootContextPath)1 MatchPair (com.alibaba.dubbo.registry.common.route.RouteRule.MatchPair)1