本文整理汇总了Java中com.alibaba.dubbo.registry.common.domain.Consumer类的典型用法代码示例。如果您正苦于以下问题:Java Consumer类的具体用法?Java Consumer怎么用?Java Consumer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Consumer类属于com.alibaba.dubbo.registry.common.domain包,在下文中一共展示了Consumer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: routeselect
import com.alibaba.dubbo.registry.common.domain.Consumer; //导入依赖的package包/类
/**
* 选择消费者
* @param context
*/
public void routeselect(Map<String, Object> context){
long rid = Long.valueOf((String)context.get("id"));
context.put("id", rid);
Route route = routeService.findRoute(rid);
if (route == null) {
throw new IllegalStateException("Route(id=" + rid + ") is not existed!");
}
context.put("route", route);
// 获取数据
List<Consumer> consumers = consumerService.findByService(route.getService());
context.put("consumers", consumers);
Map<String, Boolean> matchRoute = new HashMap<String, Boolean>();
for(Consumer c : consumers) {
matchRoute.put(c.getAddress(), RouteUtils.matchRoute(c.getAddress(), null, route, null));
}
context.put("matchRoute", matchRoute);
}
示例2: url2Consumer
import com.alibaba.dubbo.registry.common.domain.Consumer; //导入依赖的package包/类
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;
}
示例3: setConsumerOverrides
import com.alibaba.dubbo.registry.common.domain.Consumer; //导入依赖的package包/类
public static void setConsumerOverrides(Consumer consumer, List<Override> overrides) {
if (consumer == null || overrides == null) {
return;
}
List<Override> result = new ArrayList<Override>(overrides.size());
for(Override override : overrides){
if (! override.isEnabled()) {
continue;
}
if (override.isMatch(consumer)) {
result.add(override);
}
if (override.isUniqueMatch(consumer)) {
consumer.setOverride(override);
}
}
Collections.sort(result, OverrideUtils.OVERRIDE_COMPARATOR);
consumer.setOverrides(result);
}
示例4: routeselect
import com.alibaba.dubbo.registry.common.domain.Consumer; //导入依赖的package包/类
/**
* 选择消费者
*
* @param context
*/
public void routeselect(Map<String, Object> context) {
long rid = Long.valueOf((String) context.get("id"));
context.put("id", rid);
Route route = routeService.findRoute(rid);
if (route == null) {
throw new IllegalStateException("Route(id=" + rid + ") is not existed!");
}
context.put("route", route);
// 获取数据
List<Consumer> consumers = consumerService.findByService(route.getService());
context.put("consumers", consumers);
Map<String, Boolean> matchRoute = new HashMap<String, Boolean>();
for (Consumer c : consumers) {
matchRoute.put(c.getAddress(), RouteUtils.matchRoute(c.getAddress(), null, route, null));
}
context.put("matchRoute", matchRoute);
}
示例5: url2Consumer
import com.alibaba.dubbo.registry.common.domain.Consumer; //导入依赖的package包/类
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;
}
示例6: setConsumerOverrides
import com.alibaba.dubbo.registry.common.domain.Consumer; //导入依赖的package包/类
public static void setConsumerOverrides(Consumer consumer, List<Override> overrides) {
if (consumer == null || overrides == null) {
return;
}
List<Override> result = new ArrayList<Override>(overrides.size());
for (Override override : overrides) {
if (!override.isEnabled()) {
continue;
}
if (override.isMatch(consumer)) {
result.add(override);
}
if (override.isUniqueMatch(consumer)) {
consumer.setOverride(override);
}
}
Collections.sort(result, OverrideUtils.OVERRIDE_COMPARATOR);
consumer.setOverrides(result);
}
示例7: index
import com.alibaba.dubbo.registry.common.domain.Consumer; //导入依赖的package包/类
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);
}
示例8: show
import com.alibaba.dubbo.registry.common.domain.Consumer; //导入依赖的package包/类
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);
}
}
示例9: show
import com.alibaba.dubbo.registry.common.domain.Consumer; //导入依赖的package包/类
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());
}
示例10: url2ConsumerList
import com.alibaba.dubbo.registry.common.domain.Consumer; //导入依赖的package包/类
public static List<Consumer> url2ConsumerList(Map<Long, URL> cs) {
List<Consumer> list = new ArrayList<Consumer>();
if(cs == null) return list;
for(Map.Entry<Long, URL> entry : cs.entrySet()) {
list.add(url2Consumer(new Pair<Long, URL>(entry.getKey(), entry.getValue())));
}
return list;
}