|
@@ -7,6 +7,7 @@ import java.util.concurrent.TimeUnit;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
+import org.apache.commons.lang.math.RandomUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
@@ -133,6 +134,13 @@ public class ApiFlowLimitedInterceptor implements HandlerInterceptor {
|
|
LOG.error("fail to get value of expression. expression= " + expression, e);
|
|
LOG.error("fail to get value of expression. expression= " + expression, e);
|
|
}
|
|
}
|
|
if (limited) {
|
|
if (limited) {
|
|
|
|
+
|
|
|
|
+ // 允许10%的请求
|
|
|
|
+ int random = RandomUtils.nextInt(100);
|
|
|
|
+ if (random <= 10) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
// 我也不知道这是啥玩意儿 by wangwei
|
|
// 我也不知道这是啥玩意儿 by wangwei
|
|
Double mean = apiStatusInfo.getMean();
|
|
Double mean = apiStatusInfo.getMean();
|
|
int sleep = mean > 1000d ? 1000 : mean.intValue();
|
|
int sleep = mean > 1000d ? 1000 : mean.intValue();
|