本文整理汇总了Java中com.alibaba.dubbo.registry.common.route.RouteRuleUtils.filterServiceByRule方法的典型用法代码示例。如果您正苦于以下问题:Java RouteRuleUtils.filterServiceByRule方法的具体用法?Java RouteRuleUtils.filterServiceByRule怎么用?Java RouteRuleUtils.filterServiceByRule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.registry.common.route.RouteRuleUtils
的用法示例。
在下文中一共展示了RouteRuleUtils.filterServiceByRule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_filterServiceByRule
import com.alibaba.dubbo.registry.common.route.RouteRuleUtils; //导入方法依赖的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());
}
示例2: test_filterServiceByRule2
import com.alibaba.dubbo.registry.common.route.RouteRuleUtils; //导入方法依赖的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());
}