• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Route类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.alibaba.dubbo.registry.common.domain.Route的典型用法代码示例。如果您正苦于以下问题:Java Route类的具体用法?Java Route怎么用?Java Route使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Route类属于com.alibaba.dubbo.registry.common.domain包,在下文中一共展示了Route类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: index

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
/**
 * 路由模块首页
 * @param context
 */
public void index(Map<String, Object> context) {
    String service = (String) context.get("service");
    String address = (String) context.get("address");
    address = Tool.getIP(address);
    List<Route> routes;
    if (service != null && service.length() > 0
    		&& address != null && address.length() > 0) {
        routes = routeService.findByServiceAndAddress(service, address);
    } else if (service != null && service.length() > 0) {
        routes = routeService.findByService(service);
    } else if (address != null && address.length() > 0) {
        routes = routeService.findByAddress(address);
    } else {
        routes = routeService.findAll();
    }
    context.put("routes", routes);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:22,代码来源:Routes.java


示例2: routeselect

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的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);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:25,代码来源:Routes.java


示例3: matchRoute

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
public static boolean matchRoute(String consumerAddress, String consumerQueryUrl, Route route, Map<String, List<String>> clusters) {
    RouteRule rule = RouteRule.parseQuitely(route);
    Map<String, RouteRule.MatchPair> when = RouteRuleUtils.expandCondition(
            rule.getWhenCondition(), "consumer.cluster", "consumer.host", clusters);
    Map<String, String> consumerSample = ParseUtils.parseQuery("consumer.", consumerQueryUrl);

    final int index = consumerAddress.lastIndexOf(":");
    String consumerHost = null;
    if (index != -1) {
        consumerHost = consumerAddress.substring(0, index);
    } else {
        consumerHost = consumerAddress;
    }
    consumerSample.put("consumer.host", consumerHost);

    return RouteRuleUtils.isMatchCondition(when, consumerSample, consumerSample);
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:18,代码来源:RouteUtils.java


示例4: url2Route

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
public static Route url2Route(Pair<Long, URL> pair) {
	if (pair == null) {
		return null;
	}
	
    Long id = pair.getKey();
    URL url = pair.getValue();

    if (null == url)
        return null;

    Route r = new Route();
    r.setId(id);
    r.setName(url.getParameter("name"));
    r.setService(url.getServiceKey());
    r.setPriority(url.getParameter(Constants.PRIORITY_KEY, 0));
    r.setEnabled(url.getParameter(Constants.ENABLED_KEY, true));
    r.setForce(url.getParameter(Constants.FORCE_KEY, false));
    r.setRule(url.getParameterAndDecoded(Constants.RULE_KEY));
    return r;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:22,代码来源:SyncUtils.java


示例5: matchRoute

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
public static boolean matchRoute(String consumerAddress, String consumerQueryUrl, Route route, Map<String, List<String>> clusters) {
    RouteRule rule = RouteRule.parseQuitely(route);
    Map<String, RouteRule.MatchPair> when = RouteRuleUtils.expandCondition(
            rule.getWhenCondition(), "consumer.cluster", "consumer.host", clusters);
    Map<String, String> consumerSample = ParseUtils.parseQuery("consumer.", consumerQueryUrl);
    
    final int index = consumerAddress.lastIndexOf(":");
    String consumerHost = null;
    if(index != -1){
        consumerHost = consumerAddress.substring(0, index);
    }
    else {
        consumerHost = consumerAddress;
    }
    consumerSample.put("consumer.host", consumerHost);
    
    return RouteRuleUtils.isMatchCondition(when, consumerSample, consumerSample);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:19,代码来源:RouteUtils.java


示例6: getFirstRouteMatchedWhenConditionOfRule

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
static Route getFirstRouteMatchedWhenConditionOfRule(String serviceName, Map<String, String> consumerSample, List<Route> routes, Map<Long, RouteRule> routeRuleMap) {
    if (serviceName == null || serviceName.length() == 0) {
        return null;
    }
    if (routes != null && routes.size() > 0) {
        for (Route route : routes) {
            if (isSerivceNameMatched(route.getService(), serviceName)) {
                RouteRule rule = routeRuleMap.get(route.getId());
                // 当满足when条件时
                if (rule != null && RouteRuleUtils.isMatchCondition(
                        rule.getWhenCondition(), consumerSample, consumerSample)) {
                    return route; // 第一个满足即返回
                }
            }
        }
    }
    return null;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:19,代码来源:RouteUtils.java


示例7: route2RouteRule

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
static Map<Long, RouteRule> route2RouteRule(List<Route> routes,
                                            Map<String, List<String>> clusters) {
    Map<Long, RouteRule> rules = new HashMap<Long, RouteRule>();
    // route -> RouteRule
    if (routes != null && routes.size() > 0) {
        for(Route route: routes) {
            rules.put(route.getId(), RouteRule.parseQuitely(route));
        }
    }
    // expand the cluster parameters into conditions of routerule
    if (clusters != null && clusters.size() > 0) {
        Map<Long, RouteRule> rrs = new HashMap<Long, RouteRule>();
        for (Map.Entry<Long, RouteRule> entry : rules.entrySet()) {
            RouteRule rr = entry.getValue();

            Map<String, RouteRule.MatchPair> when = RouteRuleUtils.expandCondition(
                    rr.getWhenCondition(), "consumer.cluster", "consumer.host", clusters);
            Map<String, RouteRule.MatchPair> then = RouteRuleUtils.expandCondition(
                    rr.getThenCondition(), "provider.cluster", "provider.host", clusters);

            rrs.put(entry.getKey(), RouteRule.createFromCondition(when, then));
        }
        rules = rrs;
    }
    return rules;
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:27,代码来源:RouteUtils.java


示例8: route2RouteRule

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
static Map<Long, RouteRule> route2RouteRule(List<Route> routes,
                                            Map<String, List<String>> clusters) {
    Map<Long, RouteRule> rules = new HashMap<Long, RouteRule>();
    // route -> RouteRule
    if (routes != null && routes.size() > 0) {
        for (Route route : routes) {
            rules.put(route.getId(), RouteRule.parseQuitely(route));
        }
    }
    // expand the cluster parameters into conditions of routerule
    if (clusters != null && clusters.size() > 0) {
        Map<Long, RouteRule> rrs = new HashMap<Long, RouteRule>();
        for (Map.Entry<Long, RouteRule> entry : rules.entrySet()) {
            RouteRule rr = entry.getValue();

            Map<String, RouteRule.MatchPair> when = RouteRuleUtils.expandCondition(
                    rr.getWhenCondition(), "consumer.cluster", "consumer.host", clusters);
            Map<String, RouteRule.MatchPair> then = RouteRuleUtils.expandCondition(
                    rr.getThenCondition(), "provider.cluster", "provider.host", clusters);

            rrs.put(entry.getKey(), RouteRule.createFromCondition(when, then));
        }
        rules = rrs;
    }
    return rules;
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:27,代码来源:RouteUtils.java


示例9: url2Route

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
public static Route url2Route(Pair<Long, URL> pair) {
    if (pair == null) {
        return null;
    }

    Long id = pair.getKey();
    URL url = pair.getValue();

    if (null == url)
        return null;

    Route r = new Route();
    r.setId(id);
    r.setName(url.getParameter("name"));
    r.setService(url.getServiceKey());
    r.setPriority(url.getParameter(Constants.PRIORITY_KEY, 0));
    r.setEnabled(url.getParameter(Constants.ENABLED_KEY, true));
    r.setForce(url.getParameter(Constants.FORCE_KEY, false));
    r.setRule(url.getParameterAndDecoded(Constants.RULE_KEY));
    return r;
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:22,代码来源:SyncUtils.java


示例10: updateRoute

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
public void updateRoute(Route route) {
    Long id = route.getId();
    if(id == null) {
        throw new IllegalStateException("no route id");
    }
    URL oldRoute = findRouteUrl(id);
    if(oldRoute == null) {
        throw new IllegalStateException("Route was changed!");
    }
    
    registryService.unregister(oldRoute);
    registryService.register(route.toUrl());
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:14,代码来源:RouteServiceImpl.java


示例11: parse

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
/**
 * 把字符串形式的RouteRule的解析成对象。
 * 
 * @throws ParseException RouteRule字符串格式不对了。以下输入的情况,RouteRule都是非法的。
 * <ul> <li> 输入是<code>null</code>。
 * <li> 输入是空串,或是空白串。
 * <li> 输入的Rule,没有When条件
 * <li> 输入的Rule,没有Then条件
 * </ul>
 */
public static RouteRule parse(Route route) throws ParseException {
    if(route == null) 
        throw new ParseException("null route!", 0);
    
    if(route.getMatchRule() == null && route.getFilterRule() == null) {
        return parse(route.getRule());
    }
    
    return parse(route == null ? null : route.getMatchRule(), route == null ? null : route.getFilterRule());
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:21,代码来源:RouteRule.java


示例12: url2RouteList

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
public static List<Route> url2RouteList(Map<Long, URL> cs) {
    List<Route> list = new ArrayList<Route>();
    if(cs == null) return list;
    for(Map.Entry<Long, URL> entry : cs.entrySet()) {
        list.add(url2Route(new Pair<Long, URL>(entry.getKey(), entry.getValue())));
    }
    return list;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:9,代码来源:SyncUtils.java


示例13: previewRoute

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
public static Map<String, String> previewRoute(String serviceName, String consumerAddress, String queryUrl, Map<String, String> serviceUrls,
        Route route, Map<String, List<String>> clusters, List<Route> routed) {
    if(null == route) {
        throw new IllegalArgumentException("Route is null.");
    }
    List<Route> routes = new ArrayList<Route>();
    routes.add(route);
    return route(serviceName, consumerAddress, queryUrl, serviceUrls, routes, clusters, routed);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:10,代码来源:RouteUtils.java


示例14: parseQuitely

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
/**
 * @see #parse(String)
 * @throws RuntimeException 解析出错时,Wrap了{@link #parse(String)}方法的抛出的{@link ParseException}的异常。
 */
public static RouteRule parseQuitely(Route route) {
    try {
        return parse(route);
    } catch (ParseException e) {
       throw new RuntimeException(e);
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:12,代码来源:RouteRule.java


示例15: test_filterServiceByRule

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
@Test
public void test_filterServiceByRule()throws Exception {
     List<String> services = new ArrayList<String>();
     services.add("com.alibaba.MemberService");
     services.add("com.alibaba.ViewCacheService");
     services.add("com.alibaba.PC2Service");
     services.add("service2");
     
     Route route = new Route();
     route.setMatchRule("service=com.alibaba.*,AuthService&service!=com.alibaba.DomainService,com.alibaba.ViewCacheService&consumer.host!=127.0.0.1,15.11.57.6&consumer.version = 2.0.0&consumer.version != 1.0.0");
     route.setFilterRule("provider.application=morgan,pc2&provider.host=10.16.26.51&provider.port=1020");
     RouteRule rr = RouteRule.parse(route);
     Collection<String> changedService = RouteRuleUtils.filterServiceByRule(services, rr);
     assertEquals(3,changedService.size());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:16,代码来源:RouteRuleUtilsTest.java


示例16: test_filterServiceByRule

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
@Test
public void test_filterServiceByRule() throws Exception {
    List<String> services = new ArrayList<String>();
    services.add("com.alibaba.MemberService");
    services.add("com.alibaba.ViewCacheService");
    services.add("com.alibaba.PC2Service");
    services.add("service2");

    Route route = new Route();
    route.setMatchRule("service=com.alibaba.*,AuthService&service!=com.alibaba.DomainService,com.alibaba.ViewCacheService&consumer.host!=127.0.0.1,15.11.57.6&consumer.version = 2.0.0&consumer.version != 1.0.0");
    route.setFilterRule("provider.application=morgan,pc2&provider.host=10.16.26.51&provider.port=1020");
    RouteRule rr = RouteRule.parse(route);
    Collection<String> changedService = RouteRuleUtils.filterServiceByRule(services, rr);
    assertEquals(3, changedService.size());
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:16,代码来源:RouteRuleUtilsTest.java


示例17: show

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的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());
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:15,代码来源:Consumers.java


示例18: url2RouteList

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
public static List<Route> url2RouteList(Map<Long, URL> cs) {
    List<Route> list = new ArrayList<Route>();
    if (cs == null) return list;
    for (Map.Entry<Long, URL> entry : cs.entrySet()) {
        list.add(url2Route(new Pair<Long, URL>(entry.getKey(), entry.getValue())));
    }
    return list;
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:9,代码来源:SyncUtils.java


示例19: parse

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
/**
 * 把字符串形式的RouteRule的解析成对象。
 *
 * @throws ParseException RouteRule字符串格式不对了。以下输入的情况,RouteRule都是非法的。
 * <ul> <li> 输入是<code>null</code>。
 * <li> 输入是空串,或是空白串。
 * <li> 输入的Rule,没有When条件
 * <li> 输入的Rule,没有Then条件
 * </ul>
 */
public static RouteRule parse(Route route) throws ParseException {
    if (route == null)
        throw new ParseException("null route!", 0);

    if (route.getMatchRule() == null && route.getFilterRule() == null) {
        return parse(route.getRule());
    }

    return parse(route == null ? null : route.getMatchRule(), route == null ? null : route.getFilterRule());
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:21,代码来源:RouteRule.java


示例20: test_filterServiceByRule2

import com.alibaba.dubbo.registry.common.domain.Route; //导入依赖的package包/类
@Test
 public void test_filterServiceByRule2()throws Exception {
  List<String> services = new ArrayList<String>();
  services.add("com.alibaba.MemberService");
  services.add("com.alibaba.ViewCacheService");
  services.add("com.alibaba.PC2Service");
  services.add("service2");
  
  Route route = new Route();
  route.setMatchRule("service=com.alibaba.PC2Service&service!=com.alibaba.DomainService,com.alibaba.ViewCacheService&consumer.host!=127.0.0.1,15.11.57.6&consumer.version = 2.0.0&consumer.version != 1.0.0");
  route.setFilterRule("provider.application=morgan,pc2&provider.host=10.16.26.51&provider.port=1020");
  RouteRule rr = RouteRule.parse(route);
  Collection<String> changedService = RouteRuleUtils.filterServiceByRule(services, rr);
  assertEquals(2,changedService.size());
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:16,代码来源:RouteRuleUtilsTest.java



注:本文中的com.alibaba.dubbo.registry.common.domain.Route类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TreePathScanner类代码示例发布时间:2022-05-21
下一篇:
Java GifDrawable类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap