本文整理汇总了Java中com.alibaba.dubbo.registry.common.route.RouteUtils类的典型用法代码示例。如果您正苦于以下问题:Java RouteUtils类的具体用法?Java RouteUtils怎么用?Java RouteUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RouteUtils类属于com.alibaba.dubbo.registry.common.route包,在下文中一共展示了RouteUtils类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: routeselect
import com.alibaba.dubbo.registry.common.route.RouteUtils; //导入依赖的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: routeselect
import com.alibaba.dubbo.registry.common.route.RouteUtils; //导入依赖的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);
}
示例3: show
import com.alibaba.dubbo.registry.common.route.RouteUtils; //导入依赖的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());
}
示例4: show
import com.alibaba.dubbo.registry.common.route.RouteUtils; //导入依赖的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());
}
示例5: index
import com.alibaba.dubbo.registry.common.route.RouteUtils; //导入依赖的package包/类
public void index(Map<String, Object> context) throws Exception {
String service = (String) context.get("service");
String application = (String) context.get("application");
String address = (String) context.get("address");
List<Consumer> consumers;
List<Override> overrides;
List<Provider> providers = null;
List<Route> routes = null;
// service
if (service != null && service.length() > 0) {
consumers = consumerService.findByService(service);
overrides = overrideService.findByService(service);
providers = providerService.findByService(service);
routes = routeService.findByService(service);
}
// address
else if (address != null && address.length() > 0) {
consumers = consumerService.findByAddress(address);
overrides = overrideService.findByAddress(Tool.getIP(address));
}
// application
else if (application != null && application.length() > 0) {
consumers = consumerService.findByApplication(application);
overrides = overrideService.findByApplication(application);
}
// all
else {
consumers = consumerService.findAll();
overrides = overrideService.findAll();
}
if (consumers != null && consumers.size() > 0) {
for (Consumer consumer : consumers) {
if (service == null || service.length() == 0) {
providers = providerService.findByService(consumer.getService());
routes = routeService.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("consumers", consumers);
}