예제 #1
0
 public static List<Provider> route(
     String serviceName,
     String consumerAddress,
     String consumerQueryUrl,
     List<Provider> providers,
     List<Override> overrides,
     List<Route> routes,
     Map<String, List<String>> clusters,
     List<Route> routed) {
   if (providers == null) {
     return null;
   }
   Map<String, String> urls = new HashMap<String, String>();
   urls.put(
       "consumer://" + consumerAddress + "/" + serviceName,
       consumerQueryUrl); // not empty dummy data
   for (Provider provider : providers) {
     if (com.alibaba.dubbo.governance.web.common.pulltool.Tool.isProviderEnabled(
         provider, overrides)) {
       urls.put(provider.getUrl(), provider.getParameters());
     }
   }
   urls =
       RouteUtils.route(
           serviceName, consumerAddress, consumerQueryUrl, urls, routes, clusters, routed);
   List<Provider> result = new ArrayList<Provider>();
   for (Provider provider : providers) {
     if (urls.containsKey(provider.getUrl())) {
       result.add(provider);
     }
   }
   return result;
 }
예제 #2
0
 /**
  * load页面供新增操作
  *
  * @param context
  */
 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"));
 }