use of com.alibaba.dubbo.registry.common.domain.Provider in project dubbo by alibaba.
the class Versions method index.
public void index(Map<String, Object> context) {
List<Provider> providers = providerService.findAll();
List<Consumer> consumers = consumerService.findAll();
Set<String> parametersSet = new HashSet<String>();
for (Provider provider : providers) {
parametersSet.add(provider.getParameters());
}
for (Consumer consumer : consumers) {
parametersSet.add(consumer.getParameters());
}
Map<String, Set<String>> versions = new HashMap<String, Set<String>>();
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 (versions.get(dubbo) == null) {
Set<String> apps = new HashSet<String>();
versions.put(dubbo, apps);
}
versions.get(dubbo).add(application);
}
}
context.put("versions", versions);
}
use of com.alibaba.dubbo.registry.common.domain.Provider in project dubbo by alibaba.
the class Providers method add.
/**
* 装载新增服务页面,获取所有的服务名称
* @param context
*/
public void add(Long id, Map<String, Object> context) {
if (context.get("service") == null) {
List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
context.put("serviceList", serviceList);
}
if (id != null) {
Provider p = providerService.findProvider(id);
if (p != null) {
context.put("provider", p);
String parameters = p.getParameters();
if (parameters != null && parameters.length() > 0) {
Map<String, String> map = StringUtils.parseQueryString(parameters);
map.put("timestamp", String.valueOf(System.currentTimeMillis()));
map.remove("pid");
p.setParameters(StringUtils.toQueryString(map));
}
}
}
}
use of com.alibaba.dubbo.registry.common.domain.Provider in project dubbo by alibaba.
the class Providers method enable.
public boolean enable(Long[] ids, Map<String, Object> context) {
Map<Long, Provider> id2Provider = new HashMap<Long, Provider>();
for (Long id : ids) {
Provider provider = providerService.findProvider(id);
if (provider == null) {
context.put("message", getMessage("NoSuchOperationData", id));
return false;
} else if (!super.currentUser.hasServicePrivilege(provider.getService())) {
context.put("message", getMessage("HaveNoServicePrivilege", provider.getService()));
return false;
}
id2Provider.put(id, provider);
}
for (Long id : ids) {
providerService.enableProvider(id);
}
return true;
}
use of com.alibaba.dubbo.registry.common.domain.Provider in project dubbo by alibaba.
the class Routes method preview.
public void preview(Map<String, Object> context) throws Exception {
String rid = (String) context.get("id");
String consumerid = (String) context.get("cid");
if (StringUtils.isEmpty(rid)) {
context.put("message", getMessage("MissRequestParameters", "id"));
}
Map<String, String> serviceUrls = new HashMap<String, String>();
Route route = routeService.findRoute(Long.valueOf(rid));
if (null == route) {
context.put("message", getMessage("NoSuchRecord"));
}
List<Provider> providers = providerService.findByService(route.getService());
if (providers != null) {
for (Provider p : providers) {
serviceUrls.put(p.getUrl(), p.getParameters());
}
}
if (StringUtils.isNotEmpty(consumerid)) {
Consumer consumer = consumerService.findConsumer(Long.valueOf(consumerid));
if (null == consumer) {
context.put("message", getMessage("NoSuchRecord"));
}
Map<String, String> result = RouteUtils.previewRoute(consumer.getService(), consumer.getAddress(), consumer.getParameters(), serviceUrls, route, null, null);
context.put("route", route);
context.put("consumer", consumer);
context.put("result", result);
} else {
String address = (String) context.get("address");
String service = (String) context.get("service");
Map<String, String> result = RouteUtils.previewRoute(service, address, null, serviceUrls, route, null, null);
context.put("route", route);
Consumer consumer = new Consumer();
consumer.setService(service);
consumer.setAddress(address);
context.put("consumer", consumer);
context.put("result", result);
}
}
use of com.alibaba.dubbo.registry.common.domain.Provider in project dubbo by alibaba.
the class Index method execute.
public void execute(Context context) {
Set<String> applications = new HashSet<String>();
Set<String> services = new HashSet<String>();
List<Provider> pList = new ArrayList<Provider>();
try {
pList = providerService.findAll();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
for (Provider p : pList) {
applications.add(p.getApplication());
services.add(p.getService());
}
List<Consumer> cList = new ArrayList<Consumer>();
try {
cList = consumerService.findAll();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
for (Consumer c : cList) {
applications.add(c.getApplication());
services.add(c.getService());
}
context.put("rootContextPath", new RootContextPath(request.getContextPath()));
context.put("services", services.size());
context.put("providers", pList.size());
context.put("consumers", cList.size());
context.put("applications", applications.size());
}
Aggregations