当前位置: 首页>>代码示例>>Java>>正文


Java Route.setMatchRule方法代码示例

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


在下文中一共展示了Route.setMatchRule方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_matchRoute

import com.alibaba.dubbo.registry.common.domain.Route; //导入方法依赖的package包/类
@Test
public void test_matchRoute() throws Exception {
    Route route = new Route();
    route.setId(1L);
    route.setPriority(3);
    route.setMatchRule("consumer.host = 1.1.2.2");
    route.setFilterRule("xxx = yyy");
    routes.add(route);

    {
        assertTrue(RouteUtils.matchRoute("1.1.2.2:20880", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&application=kylin", route, clusters));

        assertFalse(RouteUtils.matchRoute("9.9.9.9", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&application=kylin", route, clusters));

        route.setMatchRule("consumer.host = 1.1.2.2 & consumer.application = kylin");
        assertTrue(RouteUtils.matchRoute("1.1.2.2", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&application=kylin", route, clusters));

        route.setMatchRule("consumer.host = 1.1.2.2 & consumer.application = notExstied");
        assertFalse(RouteUtils.matchRoute("1.1.2.2", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&methods=getPort,say&application=kylin", route, clusters));
    }
    
    {
        route.setMatchRule("consumer.cluster = cluster1");
        
        assertTrue(RouteUtils.matchRoute("7.7.7.7:20880", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&application=kylin", route, clusters));
        
        assertFalse(RouteUtils.matchRoute("9.9.9.9", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&application=kylin", route, clusters));
        
        route.setMatchRule("consumer.cluster = cluster1 & consumer.application = kylin");
        assertTrue(RouteUtils.matchRoute("7.7.7.7", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&application=kylin", route, clusters));
        
        route.setMatchRule("consumer.cluster = cluster1 & consumer.application = notExstied");
        assertFalse(RouteUtils.matchRoute("7.7.7.7", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&methods=getPort,say&application=kylin", route, clusters));
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:36,代码来源:RouteUtilsTest.java

示例2: 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

示例3: 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:dachengxi,项目名称:EatDubbo,代码行数:16,代码来源:RouteRuleUtilsTest.java

示例4: test_matchRoute

import com.alibaba.dubbo.registry.common.domain.Route; //导入方法依赖的package包/类
@Test
public void test_matchRoute() throws Exception {
    Route route = new Route();
    route.setId(1L);
    route.setPriority(3);
    route.setMatchRule("consumer.host = 1.1.2.2");
    route.setFilterRule("xxx = yyy");
    routes.add(route);

    {
        assertTrue(RouteUtils.matchRoute("1.1.2.2:20880", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&application=kylin", route, clusters));

        assertFalse(RouteUtils.matchRoute("9.9.9.9", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&application=kylin", route, clusters));

        route.setMatchRule("consumer.host = 1.1.2.2 & consumer.application = kylin");
        assertTrue(RouteUtils.matchRoute("1.1.2.2", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&application=kylin", route, clusters));

        route.setMatchRule("consumer.host = 1.1.2.2 & consumer.application = notExstied");
        assertFalse(RouteUtils.matchRoute("1.1.2.2", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&methods=getPort,say&application=kylin", route, clusters));
    }

    {
        route.setMatchRule("consumer.cluster = cluster1");

        assertTrue(RouteUtils.matchRoute("7.7.7.7:20880", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&application=kylin", route, clusters));

        assertFalse(RouteUtils.matchRoute("9.9.9.9", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&application=kylin", route, clusters));

        route.setMatchRule("consumer.cluster = cluster1 & consumer.application = kylin");
        assertTrue(RouteUtils.matchRoute("7.7.7.7", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&application=kylin", route, clusters));

        route.setMatchRule("consumer.cluster = cluster1 & consumer.application = notExstied");
        assertFalse(RouteUtils.matchRoute("7.7.7.7", "dubbo=2.0.0&version=3.0.0&revision=3.0.0&methods=getPort,say&application=kylin", route, clusters));
    }
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:36,代码来源:RouteUtilsTest.java

示例5: 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

示例6: 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:l1325169021,项目名称:github-test,代码行数:16,代码来源:RouteRuleUtilsTest.java


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