test_class.declarator: LOCAL_HOST = "127.0.0.1"
test_class.modifier: private static final
test_class.original_string: private static final String LOCAL_HOST = "127.0.0.1";
test_class.type: String
test_class.var_name: LOCAL_HOST
test_class.declarator: SCRIPT_URL = URL.valueOf("condition://0.0.0.0/com.foo.BarService")
test_class.modifier: private
test_class.original_string: private URL SCRIPT_URL = URL.valueOf("condition://0.0.0.0/com.foo.BarService");
test_class.type: URL
test_class.var_name: SCRIPT_URL
test_class.file: dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/condition/ConditionRouterTest.java
test_class.identifier: ConditionRouterTest
test_case.body: @Test
      public void testRoute_Force() {
          Router router = new ConditionRouterFactory().getRouter(getRouteUrl("host = " + LOCAL_HOST + " => " + " host = 1.2.3.4").addParameter(FORCE_KEY, String.valueOf(true)));
          List<Invoker<String>> invokers = new ArrayList<Invoker<String>>();
          Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
          Invoker<String> invoker2 = new MockInvoker<String>(URL.valueOf("dubbo://" + LOCAL_HOST + ":20880/com.foo.BarService"));
          Invoker<String> invoker3 = new MockInvoker<String>(URL.valueOf("dubbo://" + LOCAL_HOST + ":20880/com.foo.BarService"));
          invokers.add(invoker1);
          invokers.add(invoker2);
          invokers.add(invoker3);
          List<Invoker<String>> filteredInvokers = router.route(invokers, URL.valueOf("consumer://" + LOCAL_HOST + "/com.foo.BarService"), new RpcInvocation());
          Assertions.assertEquals(0, filteredInvokers.size());
      }
test_case.class_method_signature: ConditionRouterTest.testRoute_Force()
test_case.full_signature: @Test public void testRoute_Force()
test_case.identifier: testRoute_Force
test_case.invocations: getRouter addParameter getRouteUrl valueOf valueOf valueOf valueOf add add add route valueOf assertEquals size
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRoute_Force()
focal_class.declarator: NAME = "condition"
focal_class.modifier: public static final
focal_class.original_string: public static final String NAME = "condition";
focal_class.type: String
focal_class.var_name: NAME
focal_class.declarator: logger = LoggerFactory.getLogger(ConditionRouter.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(ConditionRouter.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: ROUTE_PATTERN = Pattern.compile("([&!=,]*)\\s*([^&!=,\\s]+)")
focal_class.modifier: protected static final
focal_class.original_string: protected static final Pattern ROUTE_PATTERN = Pattern.compile("([&!=,]*)\\s*([^&!=,\\s]+)");
focal_class.type: Pattern
focal_class.var_name: ROUTE_PATTERN
focal_class.declarator: whenCondition
focal_class.modifier: protected
focal_class.original_string: protected Map<String, MatchPair> whenCondition;
focal_class.type: Map<String, MatchPair>
focal_class.var_name: whenCondition
focal_class.declarator: thenCondition
focal_class.modifier: protected
focal_class.original_string: protected Map<String, MatchPair> thenCondition;
focal_class.type: Map<String, MatchPair>
focal_class.var_name: thenCondition
focal_class.declarator: enabled
focal_class.modifier: private
focal_class.original_string: private boolean enabled;
focal_class.type: boolean
focal_class.var_name: enabled
focal_class.file: dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/ConditionRouter.java
focal_class.identifier: ConditionRouter
focal_class.class_method_signature: ConditionRouter.ConditionRouter(String rule, boolean force, boolean enabled)
focal_class.full_signature: public  ConditionRouter(String rule, boolean force, boolean enabled)
focal_class.identifier: ConditionRouter
focal_class.modifiers: public
focal_class.parameters: (String rule, boolean force, boolean enabled)
focal_class.signature:  ConditionRouter(String rule, boolean force, boolean enabled)
focal_class.class_method_signature: ConditionRouter.ConditionRouter(URL url)
focal_class.full_signature: public  ConditionRouter(URL url)
focal_class.identifier: ConditionRouter
focal_class.modifiers: public
focal_class.parameters: (URL url)
focal_class.signature:  ConditionRouter(URL url)
focal_class.class_method_signature: ConditionRouter.init(String rule)
focal_class.full_signature: public void init(String rule)
focal_class.identifier: init
focal_class.modifiers: public
focal_class.parameters: (String rule)
focal_class.return: void
focal_class.signature: void init(String rule)
focal_class.class_method_signature: ConditionRouter.parseRule(String rule)
focal_class.full_signature: private static Map<String, MatchPair> parseRule(String rule)
focal_class.identifier: parseRule
focal_class.modifiers: private static
focal_class.parameters: (String rule)
focal_class.return: Map<String, MatchPair>
focal_class.signature: Map<String, MatchPair> parseRule(String rule)
focal_class.class_method_signature: ConditionRouter.route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.full_signature: @Override public List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.identifier: route
focal_class.modifiers: @Override public
focal_class.parameters: (List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.return: List<Invoker<T>>
focal_class.signature: List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.class_method_signature: ConditionRouter.isRuntime()
focal_class.full_signature: @Override public boolean isRuntime()
focal_class.identifier: isRuntime
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isRuntime()
focal_class.class_method_signature: ConditionRouter.getUrl()
focal_class.full_signature: @Override public URL getUrl()
focal_class.identifier: getUrl
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: URL
focal_class.signature: URL getUrl()
focal_class.class_method_signature: ConditionRouter.matchWhen(URL url, Invocation invocation)
focal_class.full_signature:  boolean matchWhen(URL url, Invocation invocation)
focal_class.identifier: matchWhen
focal_class.parameters: (URL url, Invocation invocation)
focal_class.return: boolean
focal_class.signature: boolean matchWhen(URL url, Invocation invocation)
focal_class.class_method_signature: ConditionRouter.matchThen(URL url, URL param)
focal_class.full_signature: private boolean matchThen(URL url, URL param)
focal_class.identifier: matchThen
focal_class.modifiers: private
focal_class.parameters: (URL url, URL param)
focal_class.return: boolean
focal_class.signature: boolean matchThen(URL url, URL param)
focal_class.class_method_signature: ConditionRouter.matchCondition(Map<String, MatchPair> condition, URL url, URL param, Invocation invocation)
focal_class.full_signature: private boolean matchCondition(Map<String, MatchPair> condition, URL url, URL param, Invocation invocation)
focal_class.identifier: matchCondition
focal_class.modifiers: private
focal_class.parameters: (Map<String, MatchPair> condition, URL url, URL param, Invocation invocation)
focal_class.return: boolean
focal_class.signature: boolean matchCondition(Map<String, MatchPair> condition, URL url, URL param, Invocation invocation)
focal_class.superclass: extends AbstractRouter
focal_method.body: @Override
      public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation)
              throws RpcException {
          if (!enabled) {
              return invokers;
          }
  
          if (CollectionUtils.isEmpty(invokers)) {
              return invokers;
          }
          try {
              if (!matchWhen(url, invocation)) {
                  return invokers;
              }
              List<Invoker<T>> result = new ArrayList<Invoker<T>>();
              if (thenCondition == null) {
                  logger.warn("The current consumer in the service blacklist. consumer: " + NetUtils.getLocalHost() + ", service: " + url.getServiceKey());
                  return result;
              }
              for (Invoker<T> invoker : invokers) {
                  if (matchThen(invoker.getUrl(), url)) {
                      result.add(invoker);
                  }
              }
              if (!result.isEmpty()) {
                  return result;
              } else if (force) {
                  logger.warn("The route result is empty and force execute. consumer: " + NetUtils.getLocalHost() + ", service: " + url.getServiceKey() + ", router: " + url.getParameterAndDecoded(RULE_KEY));
                  return result;
              }
          } catch (Throwable t) {
              logger.error("Failed to execute condition router rule: " + getUrl() + ", invokers: " + invokers + ", cause: " + t.getMessage(), t);
          }
          return invokers;
      }
focal_method.class_method_signature: ConditionRouter.route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_method.full_signature: @Override public List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_method.identifier: route
focal_method.invocations: isEmpty matchWhen warn getLocalHost getServiceKey matchThen getUrl add isEmpty warn getLocalHost getServiceKey getParameterAndDecoded error getUrl getMessage
focal_method.modifiers: @Override public
focal_method.parameters: (List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_method.return: List<Invoker<T>>
focal_method.signature: List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation)