@Test public void testPassLocalCheckForArray() throws InterruptedException { final String resourceName = "testPassLocalCheckForArray"; final ResourceWrapper resourceWrapper = new StringResourceWrapper(resourceName, EntryType.IN); int paramIdx = 0; double globalThreshold = 1; ParamFlowRule rule = new ParamFlowRule(resourceName).setParamIdx(paramIdx) .setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_RATE_LIMITER).setCount(globalThreshold); TimeUtil.currentTimeMillis(); String v1 = "a", v2 = "B", v3 = "Cc"; Object arr = new String[] {v1, v2, v3}; ParameterMetric metric = new ParameterMetric(); ParameterMetricStorage.getMetricsMap().put(resourceWrapper.getName(), metric); metric.getRuleTimeCounterMap().put(rule, new ConcurrentLinkedHashMapWrapper<Object, AtomicLong>(4000)); assertTrue(ParamFlowChecker.passCheck(resourceWrapper, rule, 1, arr)); assertFalse(ParamFlowChecker.passCheck(resourceWrapper, rule, 1, arr)); }
public static boolean passCheck(ResourceWrapper resourceWrapper, ParamFlowRule rule, int count, Object... args) { if (args == null) { return true; } int paramIdx = rule.getParamIdx(); if (args.length <= paramIdx) { return true; } Object value = args[paramIdx]; if (value == null) { return true; } if (rule.isClusterMode() && rule.getGrade() == RuleConstant.FLOW_GRADE_QPS) { return passClusterCheck(resourceWrapper, rule, count, value); } return passLocalCheck(resourceWrapper, rule, count, value); }
ParamFlowChecker { public static boolean passCheck(ResourceWrapper resourceWrapper, ParamFlowRule rule, int count, Object... args) { if (args == null) { return true; } int paramIdx = rule.getParamIdx(); if (args.length <= paramIdx) { return true; } Object value = args[paramIdx]; if (value == null) { return true; } if (rule.isClusterMode() && rule.getGrade() == RuleConstant.FLOW_GRADE_QPS) { return passClusterCheck(resourceWrapper, rule, count, value); } return passLocalCheck(resourceWrapper, rule, count, value); } }
ParamFlowChecker { public static boolean passCheck(ResourceWrapper resourceWrapper, ParamFlowRule rule, int count, Object... args) { if (args == null) { return true; } int paramIdx = rule.getParamIdx(); if (args.length <= paramIdx) { return true; } Object value = args[paramIdx]; if (value == null) { return true; } if (rule.isClusterMode() && rule.getGrade() == RuleConstant.FLOW_GRADE_QPS) { return passClusterCheck(resourceWrapper, rule, count, value); } return passLocalCheck(resourceWrapper, rule, count, value); } private  ParamFlowChecker(); }
ParamFlowChecker { public static boolean passCheck(ResourceWrapper resourceWrapper, ParamFlowRule rule, int count, Object... args) { if (args == null) { return true; } int paramIdx = rule.getParamIdx(); if (args.length <= paramIdx) { return true; } Object value = args[paramIdx]; if (value == null) { return true; } if (rule.isClusterMode() && rule.getGrade() == RuleConstant.FLOW_GRADE_QPS) { return passClusterCheck(resourceWrapper, rule, count, value); } return passLocalCheck(resourceWrapper, rule, count, value); } private  ParamFlowChecker(); static boolean passCheck(ResourceWrapper resourceWrapper, /*@Valid*/ ParamFlowRule rule, /*@Valid*/ int count,
                             Object... args); }
ParamFlowChecker { public static boolean passCheck(ResourceWrapper resourceWrapper, ParamFlowRule rule, int count, Object... args) { if (args == null) { return true; } int paramIdx = rule.getParamIdx(); if (args.length <= paramIdx) { return true; } Object value = args[paramIdx]; if (value == null) { return true; } if (rule.isClusterMode() && rule.getGrade() == RuleConstant.FLOW_GRADE_QPS) { return passClusterCheck(resourceWrapper, rule, count, value); } return passLocalCheck(resourceWrapper, rule, count, value); } private  ParamFlowChecker(); static boolean passCheck(ResourceWrapper resourceWrapper, /*@Valid*/ ParamFlowRule rule, /*@Valid*/ int count,
                             Object... args);  }