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;
}
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");
}
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);
}
}
Aggregations