com.alibaba.dubbo.registry.common.domain.Provider Java Examples
The following examples show how to use
com.alibaba.dubbo.registry.common.domain.Provider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Weights.java From dubbox with Apache License 2.0 | 6 votes |
/** * 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")); }
Example #2
Source File: Loadbalances.java From dubbox with Apache License 2.0 | 6 votes |
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")); }
Example #3
Source File: Loadbalances.java From dubbo3 with Apache License 2.0 | 6 votes |
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")); }
Example #4
Source File: Loadbalances.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
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")); }
Example #5
Source File: Providers.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
public boolean create(Provider provider, Map<String, Object> context) { String service = provider.getService(); if (!super.currentUser.hasServicePrivilege(service)) { context.put("message", getMessage("HaveNoServicePrivilege", service)); return false; } if (provider.getParameters() == null) { String url = provider.getUrl(); if (url != null) { int i = url.indexOf('?'); if (i > 0) { provider.setUrl(url.substring(0, i)); provider.setParameters(url.substring(i + 1)); } } } provider.setDynamic(false); // 页面上添加的一定是静态的Provider providerService.create(provider); return true; }
Example #6
Source File: Providers.java From dubbox with Apache License 2.0 | 6 votes |
/** * 装载新增服务页面,获取所有的服务名称 * @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)); } } } }
Example #7
Source File: Unregister.java From dubbox with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") protected String doExecute(Map<String,Object> context) throws Exception { Map<String, String[]> params = request.getParameterMap(); if (params == null || params.size() == 0) { throw new IllegalArgumentException("The url parameters is null! Usage: " + request.getRequestURL().toString() + "?com.xxx.XxxService=http://" + operatorAddress + "/xxxService"); } for (Map.Entry<String, String[]> entry : params.entrySet()) { if (entry.getKey() != null && entry.getKey().length() > 0 && entry.getValue() != null && entry.getValue().length > 0 && entry.getValue()[0] != null && entry.getValue()[0].length() > 0) { if (! currentUser.hasServicePrivilege(entry.getKey())) { throw new IllegalStateException("The user " + operator + " have no privilege of service " + entry.getKey()); } for(Entry<String,String> e : CollectionUtils.split(Arrays.asList(entry.getValue()), "?").entrySet()){ Provider provider = providervice.findByServiceAndAddress(entry.getKey(), e.getKey()); if (provider != null) { providervice.deleteStaticProvider(provider.getId()); } } } } return "Unregister " + params.size() + " services."; }
Example #8
Source File: Weights.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
/** * 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")); }
Example #9
Source File: Unregister.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") protected String doExecute(Map<String,Object> context) throws Exception { Map<String, String[]> params = request.getParameterMap(); if (params == null || params.size() == 0) { throw new IllegalArgumentException("The url parameters is null! Usage: " + request.getRequestURL().toString() + "?com.xxx.XxxService=http://" + operatorAddress + "/xxxService"); } for (Map.Entry<String, String[]> entry : params.entrySet()) { if (entry.getKey() != null && entry.getKey().length() > 0 && entry.getValue() != null && entry.getValue().length > 0 && entry.getValue()[0] != null && entry.getValue()[0].length() > 0) { if (! currentUser.hasServicePrivilege(entry.getKey())) { throw new IllegalStateException("The user " + operator + " have no privilege of service " + entry.getKey()); } for(Entry<String,String> e : CollectionUtils.split(Arrays.asList(entry.getValue()), "?").entrySet()){ Provider provider = providervice.findByServiceAndAddress(entry.getKey(), e.getKey()); if (provider != null) { providervice.deleteStaticProvider(provider.getId()); } } } } return "Unregister " + params.size() + " services."; }
Example #10
Source File: SyncUtils.java From dubbox with Apache License 2.0 | 6 votes |
public static Provider url2Provider(Pair<Long, URL> pair) { if (pair == null) { return null; } Long id = pair.getKey(); URL url = pair.getValue(); if (url == null) return null; Provider p = new Provider(); p.setId(id); p.setService(url.getServiceKey()); p.setAddress(url.getAddress()); p.setApplication(url.getParameter(Constants.APPLICATION_KEY)); p.setUrl(url.toIdentityString()); p.setParameters(url.toParameterString()); p.setDynamic(url.getParameter("dynamic", true)); p.setEnabled(url.getParameter(Constants.ENABLED_KEY, true)); p.setWeight(url.getParameter(Constants.WEIGHT_KEY, Constants.DEFAULT_WEIGHT)); p.setUsername(url.getParameter("owner")); return p; }
Example #11
Source File: SyncUtils.java From dubbox with Apache License 2.0 | 6 votes |
public static Provider url2Provider(Pair<Long, URL> pair) { if (pair == null) { return null; } Long id = pair.getKey(); URL url = pair.getValue(); if (url == null) return null; Provider p = new Provider(); p.setId(id); p.setService(url.getServiceKey()); p.setAddress(url.getAddress()); p.setApplication(url.getParameter(Constants.APPLICATION_KEY)); p.setUrl(url.toIdentityString()); p.setParameters(url.toParameterString()); p.setDynamic(url.getParameter("dynamic", true)); p.setEnabled(url.getParameter(Constants.ENABLED_KEY, true)); p.setWeight(url.getParameter(Constants.WEIGHT_KEY, Constants.DEFAULT_WEIGHT)); p.setUsername(url.getParameter("owner")); return p; }
Example #12
Source File: Weights.java From dubbox with Apache License 2.0 | 6 votes |
/** * 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")); }
Example #13
Source File: Loadbalances.java From dubbox with Apache License 2.0 | 6 votes |
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")); }
Example #14
Source File: OverrideUtils.java From dubbox with Apache License 2.0 | 6 votes |
public static void setProviderOverrides(Provider provider, List<Override> overrides) { if (provider == null || overrides == null) { return; } List<Override> result = new ArrayList<Override>(overrides.size()); for(Override override : overrides){ if (! override.isEnabled()) { continue; } if (override.isMatch(provider)) { result.add(override); } if (override.isUniqueMatch(provider)) { provider.setOverride(override); } } provider.setOverrides(overrides); }
Example #15
Source File: Weights.java From dubbox with Apache License 2.0 | 6 votes |
/** * 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")); }
Example #16
Source File: Providers.java From dubbox with Apache License 2.0 | 6 votes |
public boolean create(Provider provider, Map<String, Object> context) { String service = provider.getService(); if (!super.currentUser.hasServicePrivilege(service)) { context.put("message", getMessage("HaveNoServicePrivilege", service)); return false; } if (provider.getParameters() == null) { String url = provider.getUrl(); if (url != null) { int i = url.indexOf('?'); if (i > 0) { provider.setUrl(url.substring(0, i)); provider.setParameters(url.substring(i + 1)); } } } provider.setDynamic(false); // 页面上添加的一定是静态的Provider providerService.create(provider); return true; }
Example #17
Source File: Unregister.java From dubbo3 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") protected String doExecute(Map<String,Object> context) throws Exception { Map<String, String[]> params = request.getParameterMap(); if (params == null || params.size() == 0) { throw new IllegalArgumentException("The url parameters is null! Usage: " + request.getRequestURL().toString() + "?com.xxx.XxxService=http://" + operatorAddress + "/xxxService"); } for (Map.Entry<String, String[]> entry : params.entrySet()) { if (entry.getKey() != null && entry.getKey().length() > 0 && entry.getValue() != null && entry.getValue().length > 0 && entry.getValue()[0] != null && entry.getValue()[0].length() > 0) { if (! currentUser.hasServicePrivilege(entry.getKey())) { throw new IllegalStateException("The user " + operator + " have no privilege of service " + entry.getKey()); } for(Entry<String,String> e : CollectionUtils.split(Arrays.asList(entry.getValue()), "?").entrySet()){ Provider provider = providervice.findByServiceAndAddress(entry.getKey(), e.getKey()); if (provider != null) { providervice.deleteStaticProvider(provider.getId()); } } } } return "Unregister " + params.size() + " services."; }
Example #18
Source File: Providers.java From dubbox with Apache License 2.0 | 6 votes |
/** * 装载新增服务页面,获取所有的服务名称 * @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)); } } } }
Example #19
Source File: OverrideUtils.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
public static void setProviderOverrides(Provider provider, List<Override> overrides) { if (provider == null || overrides == null) { return; } List<Override> result = new ArrayList<Override>(overrides.size()); for(Override override : overrides){ if (! override.isEnabled()) { continue; } if (override.isMatch(provider)) { result.add(override); } if (override.isUniqueMatch(provider)) { provider.setOverride(override); } } provider.setOverrides(overrides); }
Example #20
Source File: SyncUtils.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
public static Provider url2Provider(Pair<Long, URL> pair) { if (pair == null) { return null; } Long id = pair.getKey(); URL url = pair.getValue(); if (url == null) return null; Provider p = new Provider(); p.setId(id); p.setService(url.getServiceKey()); p.setAddress(url.getAddress()); p.setApplication(url.getParameter(Constants.APPLICATION_KEY)); p.setUrl(url.toIdentityString()); p.setParameters(url.toParameterString()); p.setDynamic(url.getParameter("dynamic", true)); p.setEnabled(url.getParameter(Constants.ENABLED_KEY, true)); p.setWeight(url.getParameter(Constants.WEIGHT_KEY, Constants.DEFAULT_WEIGHT)); p.setUsername(url.getParameter("owner")); return p; }
Example #21
Source File: OverrideUtils.java From dubbox with Apache License 2.0 | 6 votes |
public static void setProviderOverrides(Provider provider, List<Override> overrides) { if (provider == null || overrides == null) { return; } List<Override> result = new ArrayList<Override>(overrides.size()); for(Override override : overrides){ if (! override.isEnabled()) { continue; } if (override.isMatch(provider)) { result.add(override); } if (override.isUniqueMatch(provider)) { provider.setOverride(override); } } provider.setOverrides(overrides); }
Example #22
Source File: SyncUtils.java From dubbo3 with Apache License 2.0 | 6 votes |
public static Provider url2Provider(Pair<Long, URL> pair) { if (pair == null) { return null; } Long id = pair.getKey(); URL url = pair.getValue(); if (url == null) return null; Provider p = new Provider(); p.setId(id); p.setService(url.getServiceKey()); p.setAddress(url.getAddress()); p.setApplication(url.getParameter(Constants.APPLICATION_KEY)); p.setUrl(url.toIdentityString()); p.setParameters(url.toParameterString()); p.setDynamic(url.getParameter("dynamic", true)); p.setEnabled(url.getParameter(Constants.ENABLED_KEY, true)); p.setWeight(url.getParameter(Constants.WEIGHT_KEY, Constants.DEFAULT_WEIGHT)); p.setUsername(url.getParameter("owner")); return p; }
Example #23
Source File: Versions.java From dubbox with Apache License 2.0 | 5 votes |
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); }
Example #24
Source File: ProviderServiceImpl.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public void updateProvider(Provider provider) { Long id = provider.getId(); if(id == null) { throw new IllegalStateException("no provider id"); } URL oldProvider = findProviderUrl(id); if(oldProvider == null) { throw new IllegalStateException("Provider was changed!"); } URL newProvider = provider.toUrl(); registryService.unregister(oldProvider); registryService.register(newProvider); }
Example #25
Source File: Versions.java From dubbox with Apache License 2.0 | 5 votes |
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); }
Example #26
Source File: Tool.java From dubbo3 with Apache License 2.0 | 5 votes |
public static boolean isProviderEnabled(Provider provider, List<Override> oList){ for(Override o : oList){ if (o.isMatch(provider)) { Map<String, String> params = StringUtils.parseQueryString(o.getParams()); String disbaled = params.get(Constants.DISABLED_KEY); if(disbaled != null && disbaled.length() > 0){ return ! "true".equals(disbaled); } } } return provider.isEnabled(); }
Example #27
Source File: Versions.java From dubbox with Apache License 2.0 | 5 votes |
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); }
Example #28
Source File: ProviderServiceImpl.java From dubbo3 with Apache License 2.0 | 5 votes |
public void updateProvider(Provider provider) { Long id = provider.getId(); if(id == null) { throw new IllegalStateException("no provider id"); } URL oldProvider = findProviderUrl(id); if(oldProvider == null) { throw new IllegalStateException("Provider was changed!"); } URL newProvider = provider.toUrl(); registryService.unregister(oldProvider); registryService.register(newProvider); }
Example #29
Source File: SyncUtils.java From dubbox with Apache License 2.0 | 5 votes |
public static List<Provider> url2ProviderList(Map<Long, URL> ps) { List<Provider> ret = new ArrayList<Provider>(); for(Map.Entry<Long, URL> entry : ps.entrySet()) { ret.add(url2Provider(new Pair<Long, URL>(entry.getKey(), entry.getValue()))); } return ret; }
Example #30
Source File: ProviderServiceImpl.java From dubbox with Apache License 2.0 | 5 votes |
public void enableProvider(Long id) { if(id == null) { throw new IllegalStateException("no provider id"); } Provider oldProvider = findProvider(id); if(oldProvider == null) { throw new IllegalStateException("Provider was changed!"); } if (oldProvider.isDynamic()) { //保证disable的override唯一 if(!oldProvider.isEnabled()){ Override override = new Override(); override.setAddress(oldProvider.getAddress()); override.setService(oldProvider.getService()); override.setEnabled(true); override.setParams(Constants.DISABLED_KEY+"=false"); overrideService.saveOverride(override); return; } List<Override> oList = overrideService.findByServiceAndAddress(oldProvider.getService(), oldProvider.getAddress()); for(Override o : oList){ Map<String, String> params = StringUtils.parseQueryString(o.getParams()); if(params.containsKey(Constants.DISABLED_KEY)){ if(params.get(Constants.DISABLED_KEY) .equals("true")){ overrideService.deleteOverride(o.getId()); } } } } else { oldProvider.setEnabled(true); updateProvider(oldProvider); } }