|
@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.web.interceptor;
|
|
|
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Properties;
|
|
import java.util.Properties;
|
|
|
|
+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;
|
|
@@ -130,6 +131,12 @@ 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) {
|
|
|
|
+ // 我也不知道这是啥玩意儿 by wangwei
|
|
|
|
+ Double mean = apiStatusInfo.getMean();
|
|
|
|
+ int sleep = mean > 10000 ? 1000 : mean.intValue();
|
|
|
|
+ sleep = sleep < 100 ? 100 : sleep;
|
|
|
|
+ Util.sleep(TimeUnit.MILLISECONDS, sleep);
|
|
|
|
+
|
|
response.setStatus(HttpStatus.SERVICE_UNAVAILABLE.value());
|
|
response.setStatus(HttpStatus.SERVICE_UNAVAILABLE.value());
|
|
ServletUtil.returnJson(new StatusResponse("503", "limited"), response);
|
|
ServletUtil.returnJson(new StatusResponse("503", "limited"), response);
|
|
return false;
|
|
return false;
|