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