|
@@ -15,6 +15,7 @@ import org.springframework.http.MediaType;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.util.Calculator;
|
|
|
import cn.com.qmth.examcloud.commons.util.FreeMarkerUtil;
|
|
|
import cn.com.qmth.examcloud.commons.util.ResourceLoader;
|
|
|
import cn.com.qmth.examcloud.web.support.ApiInfo;
|
|
@@ -132,15 +133,16 @@ public class ApiStatusEndpoint {
|
|
|
apiStatusInfo.setExceptionFiveMinuteRate(meterInfo.getFiveMinuteRate());
|
|
|
apiStatusInfo.setExceptionFifteenMinuteRate(meterInfo.getFifteenMinuteRate());
|
|
|
|
|
|
- apiStatusInfo.setExceptionPercent(meterInfo.getCount() / timerInfo.getCount());
|
|
|
- apiStatusInfo
|
|
|
- .setExceptionMeanPercent(meterInfo.getMeanRate() / timerInfo.getMeanRate());
|
|
|
+ apiStatusInfo.setExceptionPercent(
|
|
|
+ getPercent(meterInfo.getCount(), timerInfo.getCount()));
|
|
|
+ apiStatusInfo.setExceptionMeanPercent(
|
|
|
+ getPercent(meterInfo.getMeanRate(), timerInfo.getMeanRate()));
|
|
|
apiStatusInfo.setExceptionOneMinutePercent(
|
|
|
- meterInfo.getOneMinuteRate() / timerInfo.getOneMinuteRate());
|
|
|
+ getPercent(meterInfo.getOneMinuteRate(), timerInfo.getOneMinuteRate()));
|
|
|
apiStatusInfo.setExceptionFiveMinutePercent(
|
|
|
- meterInfo.getFiveMinuteRate() / timerInfo.getFiveMinuteRate());
|
|
|
- apiStatusInfo.setExceptionFifteenMinutePercent(
|
|
|
- meterInfo.getFifteenMinuteRate() / timerInfo.getFifteenMinuteRate());
|
|
|
+ getPercent(meterInfo.getFiveMinuteRate(), timerInfo.getFiveMinuteRate()));
|
|
|
+ apiStatusInfo.setExceptionFifteenMinutePercent(getPercent(
|
|
|
+ meterInfo.getFifteenMinuteRate(), timerInfo.getFifteenMinuteRate()));
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -179,4 +181,11 @@ public class ApiStatusEndpoint {
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ private Double getPercent(double v1, double v2) {
|
|
|
+ if (0 == v1 || 0 == v2) {
|
|
|
+ return 0d;
|
|
|
+ }
|
|
|
+ return Calculator.divide(v1, v2, 3);
|
|
|
+ }
|
|
|
+
|
|
|
}
|