@Test public void test_isSerivceNameMatched() throws Exception { assertTrue(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.MemberService", "com.alibaba.morgan.MemberService:1.0.0")); assertTrue(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.MemberService", "cn/com.alibaba.morgan.MemberService:1.0.0")); assertTrue(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.MemberService", "cn/com.alibaba.morgan.MemberService")); assertTrue(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.MemberService", "com.alibaba.morgan.MemberService")); assertTrue(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.Member*", "com.alibaba.morgan.MemberService:1.0.0")); assertTrue(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.Member*", "cn/com.alibaba.morgan.MemberService:1.0.0")); assertTrue(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.Member*", "cn/com.alibaba.morgan.MemberService")); assertTrue(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.Member*", "com.alibaba.morgan.MemberService")); assertFalse(RouteUtils.isSerivceNameMatched("cn/com.alibaba.morgan.Member*", "com.alibaba.morgan.MemberService:1.0.0")); assertTrue(RouteUtils.isSerivceNameMatched("cn/com.alibaba.morgan.MemberService", "cn/com.alibaba.morgan.MemberService:1.0.0")); assertTrue(RouteUtils.isSerivceNameMatched("cn/com.alibaba.morgan.Member*", "cn/com.alibaba.morgan.MemberService")); assertFalse(RouteUtils.isSerivceNameMatched("cn/com.alibaba.morgan.Member*", "intl/com.alibaba.morgan.MemberService")); assertFalse(RouteUtils.isSerivceNameMatched("cn/com.alibaba.morgan.Member*", "com.alibaba.morgan.MemberService")); assertTrue(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.Member*:1.0.0", "com.alibaba.morgan.MemberService:1.0.0")); assertTrue(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.MemberService:1.0.0", "cn/com.alibaba.morgan.MemberService:1.0.0")); assertFalse(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.MemberService:1.0.0", "cn/com.alibaba.morgan.MemberService:2.0.0")); assertFalse(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.Member*:1.0.0", "cn/com.alibaba.morgan.MemberService")); assertFalse(RouteUtils.isSerivceNameMatched("com.alibaba.morgan.Member*:1.0.0", "com.alibaba.morgan.MemberService")); }
static boolean isSerivceNameMatched(String servicePattern, String serviceName) { final int pip = servicePattern.indexOf('/'); final int pi = serviceName.indexOf('/'); if(pip != -1) { if(pi == -1) return false; String gp = servicePattern.substring(0, pip); servicePattern = servicePattern.substring(pip + 1); String g = serviceName.substring(0, pi); if(!gp.equals(g)) return false; } if(pi != -1) serviceName = serviceName.substring(pi + 1); final int vip = servicePattern.lastIndexOf(':'); final int vi = serviceName.lastIndexOf(':'); if(vip != -1) { if(vi == -1) return false; String vp = servicePattern.substring(vip + 1); servicePattern = servicePattern.substring(0, vip); String v = serviceName.substring(vi + 1); if(!vp.equals(v)) return false; } if(vi != -1) serviceName = serviceName.substring(0, vi); return ParseUtils.isMatchGlobPattern(servicePattern, serviceName); }
RouteUtils { static boolean isSerivceNameMatched(String servicePattern, String serviceName) { final int pip = servicePattern.indexOf('/'); final int pi = serviceName.indexOf('/'); if(pip != -1) { if(pi == -1) return false; String gp = servicePattern.substring(0, pip); servicePattern = servicePattern.substring(pip + 1); String g = serviceName.substring(0, pi); if(!gp.equals(g)) return false; } if(pi != -1) serviceName = serviceName.substring(pi + 1); final int vip = servicePattern.lastIndexOf(':'); final int vi = serviceName.lastIndexOf(':'); if(vip != -1) { if(vi == -1) return false; String vp = servicePattern.substring(vip + 1); servicePattern = servicePattern.substring(0, vip); String v = serviceName.substring(vi + 1); if(!vp.equals(v)) return false; } if(vi != -1) serviceName = serviceName.substring(0, vi); return ParseUtils.isMatchGlobPattern(servicePattern, serviceName); } }
RouteUtils { static boolean isSerivceNameMatched(String servicePattern, String serviceName) { final int pip = servicePattern.indexOf('/'); final int pi = serviceName.indexOf('/'); if(pip != -1) { if(pi == -1) return false; String gp = servicePattern.substring(0, pip); servicePattern = servicePattern.substring(pip + 1); String g = serviceName.substring(0, pi); if(!gp.equals(g)) return false; } if(pi != -1) serviceName = serviceName.substring(pi + 1); final int vip = servicePattern.lastIndexOf(':'); final int vi = serviceName.lastIndexOf(':'); if(vip != -1) { if(vi == -1) return false; String vp = servicePattern.substring(vip + 1); servicePattern = servicePattern.substring(0, vip); String v = serviceName.substring(vi + 1); if(!vp.equals(v)) return false; } if(vi != -1) serviceName = serviceName.substring(0, vi); return ParseUtils.isMatchGlobPattern(servicePattern, serviceName); }  }
RouteUtils { static boolean isSerivceNameMatched(String servicePattern, String serviceName) { final int pip = servicePattern.indexOf('/'); final int pi = serviceName.indexOf('/'); if(pip != -1) { if(pi == -1) return false; String gp = servicePattern.substring(0, pip); servicePattern = servicePattern.substring(pip + 1); String g = serviceName.substring(0, pi); if(!gp.equals(g)) return false; } if(pi != -1) serviceName = serviceName.substring(pi + 1); final int vip = servicePattern.lastIndexOf(':'); final int vi = serviceName.lastIndexOf(':'); if(vip != -1) { if(vi == -1) return false; String vp = servicePattern.substring(vip + 1); servicePattern = servicePattern.substring(0, vip); String v = serviceName.substring(vi + 1); if(!vp.equals(v)) return false; } if(vi != -1) serviceName = serviceName.substring(0, vi); return ParseUtils.isMatchGlobPattern(servicePattern, serviceName); }  static boolean matchRoute(String consumerAddress, String consumerQueryUrl, Route route, Map<String, List<String>> clusters); 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); static List<Route> findUsedRoute(String serviceName, String consumerAddress, String consumerQueryUrl,
            List<Route> routes, Map<String, List<String>> clusters); static List<Provider> route(String serviceName, String consumerAddress, String consumerQueryUrl, List<Provider> providers,
    		List<Override> overrides, List<Route> routes, Map<String, List<String>> clusters, List<Route> routed); static Map<String, String> route(String serviceName, String consumerAddress, String consumerQueryUrl, Map<String, String> serviceUrls,
            List<Route> routes, Map<String, List<String>> clusters, List<Route> routed); }
RouteUtils { static boolean isSerivceNameMatched(String servicePattern, String serviceName) { final int pip = servicePattern.indexOf('/'); final int pi = serviceName.indexOf('/'); if(pip != -1) { if(pi == -1) return false; String gp = servicePattern.substring(0, pip); servicePattern = servicePattern.substring(pip + 1); String g = serviceName.substring(0, pi); if(!gp.equals(g)) return false; } if(pi != -1) serviceName = serviceName.substring(pi + 1); final int vip = servicePattern.lastIndexOf(':'); final int vi = serviceName.lastIndexOf(':'); if(vip != -1) { if(vi == -1) return false; String vp = servicePattern.substring(vip + 1); servicePattern = servicePattern.substring(0, vip); String v = serviceName.substring(vi + 1); if(!vp.equals(v)) return false; } if(vi != -1) serviceName = serviceName.substring(0, vi); return ParseUtils.isMatchGlobPattern(servicePattern, serviceName); }  static boolean matchRoute(String consumerAddress, String consumerQueryUrl, Route route, Map<String, List<String>> clusters); 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); static List<Route> findUsedRoute(String serviceName, String consumerAddress, String consumerQueryUrl,
            List<Route> routes, Map<String, List<String>> clusters); static List<Provider> route(String serviceName, String consumerAddress, String consumerQueryUrl, List<Provider> providers,
    		List<Override> overrides, List<Route> routes, Map<String, List<String>> clusters, List<Route> routed); static Map<String, String> route(String serviceName, String consumerAddress, String consumerQueryUrl, Map<String, String> serviceUrls,
            List<Route> routes, Map<String, List<String>> clusters, List<Route> routed);  }