Package com.alibaba.dubbo.registry.common.domain

Examples of com.alibaba.dubbo.registry.common.domain.Route


     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());
   }
View Full Code Here


        clusters.put("cluster1", list1);
    }
   
    @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));
        }
    }
View Full Code Here

TOP

Related Classes of com.alibaba.dubbo.registry.common.domain.Route

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.