浏览代码

Deprecated ApiStatisticInterceptor

deason 11 月之前
父节点
当前提交
27af2711e9

+ 107 - 107
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/actuator/ApiStatusEndpoint.java

@@ -1,107 +1,107 @@
-package cn.com.qmth.examcloud.web.actuator;
-
-import cn.com.qmth.examcloud.commons.util.DateUtil;
-import cn.com.qmth.examcloud.commons.util.FreeMarkerUtil;
-import cn.com.qmth.examcloud.commons.util.ResourceLoader;
-import com.google.common.collect.Maps;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
-import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
-import org.springframework.boot.actuate.endpoint.annotation.Selector;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.MediaType;
-
-import java.lang.reflect.Field;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * 接口状态
- *
- * @author WANGWEI
- * @date 2019年7月25日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
- */
-@Configuration
-@Endpoint(id = "api-status")
-public class ApiStatusEndpoint {
-
-    private static AtomicBoolean running = new AtomicBoolean(false);
-
-    @Autowired
-    ApiStatusInfoCollector apiStatusInfoCollector;
-
-    /**
-     * url: /actuator/api-status
-     *
-     * @return
-     * @author WANGWEI
-     */
-    @ReadOperation(produces = {MediaType.TEXT_HTML_VALUE})
-    public String getByDefault() {
-        return get("");
-    }
-
-    /**
-     * url: /actuator/api-status/ignored?order=XX
-     *
-     * @param order
-     * @return
-     * @author WANGWEI
-     */
-    @ReadOperation(produces = {MediaType.TEXT_HTML_VALUE})
-    public String get(@Selector String order) {
-
-        if (!running.compareAndSet(false, true)) {
-            return DateUtil.chinaNow() + " | 请求限制";
-        }
-
-        String ret = null;
-        try {
-            List<ApiStatusInfo> list = ApiStatusInfoHolder.getApiStatusInfoList();
-
-            Collections.sort(list, new Comparator<ApiStatusInfo>() {
-                @Override
-                public int compare(ApiStatusInfo o1, ApiStatusInfo o2) {
-
-                    try {
-                        Field field = o1.getClass().getDeclaredField(order);
-                        field.setAccessible(true);
-                        Object value1 = field.get(o1);
-                        Object value2 = field.get(o2);
-
-                        if (null == value1) {
-                            return -1;
-                        } else if (null == value2) {
-                            return 1;
-                        } else if (value1 instanceof Long) {
-                            return (int) (((Long) value2) - ((Long) value1));
-                        } else if (value1 instanceof Double) {
-                            return (int) (((Double) value2) - ((Double) value1));
-                        } else if (value1 instanceof String) {
-                            return ((String) value1).compareToIgnoreCase((String) value2);
-                        } else {
-                            return 0;
-                        }
-                    } catch (Exception e) {
-                        return 0;
-                    }
-                }
-            });
-
-            Map<String, Object> map = Maps.newHashMap();
-            map.put("data", list);
-            map.put("dateTime", new Date());
-
-            String html = ResourceLoader.getResource("api-status.html");
-
-            ret = FreeMarkerUtil.process(html, map);
-
-        } finally {
-            running.compareAndSet(true, false);
-        }
-
-        return ret;
-    }
-
-}
+// package cn.com.qmth.examcloud.web.actuator;
+//
+// import cn.com.qmth.examcloud.commons.util.DateUtil;
+// import cn.com.qmth.examcloud.commons.util.FreeMarkerUtil;
+// import cn.com.qmth.examcloud.commons.util.ResourceLoader;
+// import com.google.common.collect.Maps;
+// import org.springframework.beans.factory.annotation.Autowired;
+// import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
+// import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
+// import org.springframework.boot.actuate.endpoint.annotation.Selector;
+// import org.springframework.context.annotation.Configuration;
+// import org.springframework.http.MediaType;
+//
+// import java.lang.reflect.Field;
+// import java.util.*;
+// import java.util.concurrent.atomic.AtomicBoolean;
+//
+// /**
+//  * 接口状态
+//  *
+//  * @author WANGWEI
+//  * @date 2019年7月25日
+//  * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+//  */
+// @Configuration
+// @Endpoint(id = "api-status")
+// public class ApiStatusEndpoint {
+//
+//     private static AtomicBoolean running = new AtomicBoolean(false);
+//
+//     @Autowired
+//     ApiStatusInfoCollector apiStatusInfoCollector;
+//
+//     /**
+//      * url: /actuator/api-status
+//      *
+//      * @return
+//      * @author WANGWEI
+//      */
+//     @ReadOperation(produces = {MediaType.TEXT_HTML_VALUE})
+//     public String getByDefault() {
+//         return get("");
+//     }
+//
+//     /**
+//      * url: /actuator/api-status/ignored?order=XX
+//      *
+//      * @param order
+//      * @return
+//      * @author WANGWEI
+//      */
+//     @ReadOperation(produces = {MediaType.TEXT_HTML_VALUE})
+//     public String get(@Selector String order) {
+//
+//         if (!running.compareAndSet(false, true)) {
+//             return DateUtil.chinaNow() + " | 请求限制";
+//         }
+//
+//         String ret = null;
+//         try {
+//             List<ApiStatusInfo> list = ApiStatusInfoHolder.getApiStatusInfoList();
+//
+//             Collections.sort(list, new Comparator<ApiStatusInfo>() {
+//                 @Override
+//                 public int compare(ApiStatusInfo o1, ApiStatusInfo o2) {
+//
+//                     try {
+//                         Field field = o1.getClass().getDeclaredField(order);
+//                         field.setAccessible(true);
+//                         Object value1 = field.get(o1);
+//                         Object value2 = field.get(o2);
+//
+//                         if (null == value1) {
+//                             return -1;
+//                         } else if (null == value2) {
+//                             return 1;
+//                         } else if (value1 instanceof Long) {
+//                             return (int) (((Long) value2) - ((Long) value1));
+//                         } else if (value1 instanceof Double) {
+//                             return (int) (((Double) value2) - ((Double) value1));
+//                         } else if (value1 instanceof String) {
+//                             return ((String) value1).compareToIgnoreCase((String) value2);
+//                         } else {
+//                             return 0;
+//                         }
+//                     } catch (Exception e) {
+//                         return 0;
+//                     }
+//                 }
+//             });
+//
+//             Map<String, Object> map = Maps.newHashMap();
+//             map.put("data", list);
+//             map.put("dateTime", new Date());
+//
+//             String html = ResourceLoader.getResource("api-status.html");
+//
+//             ret = FreeMarkerUtil.process(html, map);
+//
+//         } finally {
+//             running.compareAndSet(true, false);
+//         }
+//
+//         return ret;
+//     }
+//
+// }

+ 185 - 185
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/actuator/ApiStatusInfo.java

@@ -1,185 +1,185 @@
-package cn.com.qmth.examcloud.web.actuator;
-
-public class ApiStatusInfo {
-
-    private String mapping;
-
-    private String description;
-
-    private Long count;
-
-    private double meanRate;
-
-    private double oneMinuteRate;
-
-    private double fiveMinuteRate;
-
-    private double fifteenMinuteRate;
-
-    private double min;
-
-    private double max;
-
-    private double mean;
-
-    private double p50;
-
-    private double p75;
-
-    private double p95;
-
-    private double p98;
-
-    private double p99;
-
-    private Long errorCount;
-
-    private double errorMeanRate;
-
-    private double errorPercent;
-
-    public String getMapping() {
-        return mapping;
-    }
-
-    public void setMapping(String mapping) {
-        this.mapping = mapping;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public Long getCount() {
-        return count;
-    }
-
-    public void setCount(Long count) {
-        this.count = count;
-    }
-
-    public double getMeanRate() {
-        return meanRate;
-    }
-
-    public void setMeanRate(double meanRate) {
-        this.meanRate = meanRate;
-    }
-
-    public double getOneMinuteRate() {
-        return oneMinuteRate;
-    }
-
-    public void setOneMinuteRate(double oneMinuteRate) {
-        this.oneMinuteRate = oneMinuteRate;
-    }
-
-    public double getFiveMinuteRate() {
-        return fiveMinuteRate;
-    }
-
-    public void setFiveMinuteRate(double fiveMinuteRate) {
-        this.fiveMinuteRate = fiveMinuteRate;
-    }
-
-    public double getFifteenMinuteRate() {
-        return fifteenMinuteRate;
-    }
-
-    public void setFifteenMinuteRate(double fifteenMinuteRate) {
-        this.fifteenMinuteRate = fifteenMinuteRate;
-    }
-
-    public double getMin() {
-        return min;
-    }
-
-    public void setMin(double min) {
-        this.min = min;
-    }
-
-    public double getMax() {
-        return max;
-    }
-
-    public void setMax(double max) {
-        this.max = max;
-    }
-
-    public double getMean() {
-        return mean;
-    }
-
-    public void setMean(double mean) {
-        this.mean = mean;
-    }
-
-    public double getP50() {
-        return p50;
-    }
-
-    public void setP50(double p50) {
-        this.p50 = p50;
-    }
-
-    public double getP75() {
-        return p75;
-    }
-
-    public void setP75(double p75) {
-        this.p75 = p75;
-    }
-
-    public double getP95() {
-        return p95;
-    }
-
-    public void setP95(double p95) {
-        this.p95 = p95;
-    }
-
-    public double getP98() {
-        return p98;
-    }
-
-    public void setP98(double p98) {
-        this.p98 = p98;
-    }
-
-    public double getP99() {
-        return p99;
-    }
-
-    public void setP99(double p99) {
-        this.p99 = p99;
-    }
-
-    public Long getErrorCount() {
-        return errorCount;
-    }
-
-    public void setErrorCount(Long errorCount) {
-        this.errorCount = errorCount;
-    }
-
-    public double getErrorMeanRate() {
-        return errorMeanRate;
-    }
-
-    public void setErrorMeanRate(double errorMeanRate) {
-        this.errorMeanRate = errorMeanRate;
-    }
-
-    public double getErrorPercent() {
-        return errorPercent;
-    }
-
-    public void setErrorPercent(double errorPercent) {
-        this.errorPercent = errorPercent;
-    }
-
-}
+// package cn.com.qmth.examcloud.web.actuator;
+//
+// public class ApiStatusInfo {
+//
+//     private String mapping;
+//
+//     private String description;
+//
+//     private Long count;
+//
+//     private double meanRate;
+//
+//     private double oneMinuteRate;
+//
+//     private double fiveMinuteRate;
+//
+//     private double fifteenMinuteRate;
+//
+//     private double min;
+//
+//     private double max;
+//
+//     private double mean;
+//
+//     private double p50;
+//
+//     private double p75;
+//
+//     private double p95;
+//
+//     private double p98;
+//
+//     private double p99;
+//
+//     private Long errorCount;
+//
+//     private double errorMeanRate;
+//
+//     private double errorPercent;
+//
+//     public String getMapping() {
+//         return mapping;
+//     }
+//
+//     public void setMapping(String mapping) {
+//         this.mapping = mapping;
+//     }
+//
+//     public String getDescription() {
+//         return description;
+//     }
+//
+//     public void setDescription(String description) {
+//         this.description = description;
+//     }
+//
+//     public Long getCount() {
+//         return count;
+//     }
+//
+//     public void setCount(Long count) {
+//         this.count = count;
+//     }
+//
+//     public double getMeanRate() {
+//         return meanRate;
+//     }
+//
+//     public void setMeanRate(double meanRate) {
+//         this.meanRate = meanRate;
+//     }
+//
+//     public double getOneMinuteRate() {
+//         return oneMinuteRate;
+//     }
+//
+//     public void setOneMinuteRate(double oneMinuteRate) {
+//         this.oneMinuteRate = oneMinuteRate;
+//     }
+//
+//     public double getFiveMinuteRate() {
+//         return fiveMinuteRate;
+//     }
+//
+//     public void setFiveMinuteRate(double fiveMinuteRate) {
+//         this.fiveMinuteRate = fiveMinuteRate;
+//     }
+//
+//     public double getFifteenMinuteRate() {
+//         return fifteenMinuteRate;
+//     }
+//
+//     public void setFifteenMinuteRate(double fifteenMinuteRate) {
+//         this.fifteenMinuteRate = fifteenMinuteRate;
+//     }
+//
+//     public double getMin() {
+//         return min;
+//     }
+//
+//     public void setMin(double min) {
+//         this.min = min;
+//     }
+//
+//     public double getMax() {
+//         return max;
+//     }
+//
+//     public void setMax(double max) {
+//         this.max = max;
+//     }
+//
+//     public double getMean() {
+//         return mean;
+//     }
+//
+//     public void setMean(double mean) {
+//         this.mean = mean;
+//     }
+//
+//     public double getP50() {
+//         return p50;
+//     }
+//
+//     public void setP50(double p50) {
+//         this.p50 = p50;
+//     }
+//
+//     public double getP75() {
+//         return p75;
+//     }
+//
+//     public void setP75(double p75) {
+//         this.p75 = p75;
+//     }
+//
+//     public double getP95() {
+//         return p95;
+//     }
+//
+//     public void setP95(double p95) {
+//         this.p95 = p95;
+//     }
+//
+//     public double getP98() {
+//         return p98;
+//     }
+//
+//     public void setP98(double p98) {
+//         this.p98 = p98;
+//     }
+//
+//     public double getP99() {
+//         return p99;
+//     }
+//
+//     public void setP99(double p99) {
+//         this.p99 = p99;
+//     }
+//
+//     public Long getErrorCount() {
+//         return errorCount;
+//     }
+//
+//     public void setErrorCount(Long errorCount) {
+//         this.errorCount = errorCount;
+//     }
+//
+//     public double getErrorMeanRate() {
+//         return errorMeanRate;
+//     }
+//
+//     public void setErrorMeanRate(double errorMeanRate) {
+//         this.errorMeanRate = errorMeanRate;
+//     }
+//
+//     public double getErrorPercent() {
+//         return errorPercent;
+//     }
+//
+//     public void setErrorPercent(double errorPercent) {
+//         this.errorPercent = errorPercent;
+//     }
+//
+// }

+ 142 - 142
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/actuator/ApiStatusInfoCollector.java

@@ -1,142 +1,142 @@
-package cn.com.qmth.examcloud.web.actuator;
-
-import cn.com.qmth.examcloud.commons.util.Calculator;
-import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
-import cn.com.qmth.examcloud.web.support.ApiInfo;
-import cn.com.qmth.examcloud.web.support.ApiInfoHolder;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-import java.util.Map;
-
-@Component
-public class ApiStatusInfoCollector {
-
-    private static String algorithm;
-
-    {
-        // 耗时直方图算法:U:uniform ; B:biased
-        algorithm = PropertyHolder.getString("$API.statistic.histograms.algorithm", "B");
-        if (!(algorithm.equals("B") || algorithm.equals("U"))) {
-            throw new RuntimeException("histograms algorithm must be 'U' or 'B'");
-        }
-    }
-
-    public synchronized List<ApiStatusInfo> collect(ReportInfo reportInfo) {
-
-        List<HistogramInfo> histogramInfoList = reportInfo.getHistogramInfoList();
-        List<MeterInfo> meterInfoList = reportInfo.getMeterInfoList();
-        List<TimerInfo> timerInfoList = reportInfo.getTimerInfoList();
-
-        Map<String, MeterInfo> apiErrMeterInfoMap = Maps.newHashMap();
-        for (MeterInfo meterInfo : meterInfoList) {
-            String key = meterInfo.getKey();
-            if (key.startsWith(MetricNames.API_ERROR_METER.name())) {
-                String mapping = key.substring(MetricNames.API_ERROR_METER.name().length() + 1);
-                apiErrMeterInfoMap.put(mapping, meterInfo);
-            }
-        }
-
-        Map<String, HistogramInfo> apiHistogramInfoMap = Maps.newHashMap();
-        if (algorithm.equals("U")) {
-            for (HistogramInfo histogramInfo : histogramInfoList) {
-                String key = histogramInfo.getKey();
-                if (key.startsWith(MetricNames.API_HISTOGRAM.name())) {
-                    String mapping = key.substring(MetricNames.API_HISTOGRAM.name().length() + 1);
-                    apiHistogramInfoMap.put(mapping, histogramInfo);
-                }
-            }
-        }
-
-        Map<String, TimerInfo> apiTimerInfoMap = Maps.newHashMap();
-        if (algorithm.equals("B")) {
-            for (TimerInfo timerInfo : timerInfoList) {
-                String key = timerInfo.getKey();
-                if (key.startsWith(MetricNames.API_TIMER.name())) {
-                    String mapping = key.substring(MetricNames.API_TIMER.name().length() + 1);
-                    apiTimerInfoMap.put(mapping, timerInfo);
-                }
-            }
-        }
-
-        List<ApiStatusInfo> list = Lists.newArrayList();
-
-        for (MeterInfo cur : meterInfoList) {
-            String key = cur.getKey();
-            if (key.startsWith(MetricNames.API_METER.name())) {
-
-                String mapping = key.substring(MetricNames.API_METER.name().length() + 1);
-
-                ApiStatusInfo apiStatusInfo = new ApiStatusInfo();
-                list.add(apiStatusInfo);
-
-                apiStatusInfo.setMapping(mapping);
-
-                ApiInfo apiInfo = ApiInfoHolder.getApiInfo(mapping);
-                if (null != apiInfo) {
-                    apiStatusInfo.setDescription(apiInfo.getDescription());
-                }
-
-                apiStatusInfo.setCount(cur.getCount());
-                apiStatusInfo.setMeanRate(cur.getMeanRate());
-                apiStatusInfo.setOneMinuteRate(cur.getOneMinuteRate());
-                apiStatusInfo.setFiveMinuteRate(cur.getFiveMinuteRate());
-                apiStatusInfo.setFifteenMinuteRate(cur.getFifteenMinuteRate());
-
-                if (algorithm.equals("U")) {
-                    HistogramInfo histogramInfo = apiHistogramInfoMap.get(mapping);
-
-                    apiStatusInfo.setMin(histogramInfo.getMin());
-                    apiStatusInfo.setMax(histogramInfo.getMax());
-                    apiStatusInfo.setMean(histogramInfo.getMean());
-
-                    apiStatusInfo.setP50(histogramInfo.getP50());
-                    apiStatusInfo.setP75(histogramInfo.getP75());
-                    apiStatusInfo.setP95(histogramInfo.getP95());
-                    apiStatusInfo.setP98(histogramInfo.getP98());
-                    apiStatusInfo.setP99(histogramInfo.getP99());
-                }
-
-                if (algorithm.equals("B")) {
-                    TimerInfo timerInfo = apiTimerInfoMap.get(mapping);
-
-                    apiStatusInfo.setMin(timerInfo.getMin());
-                    apiStatusInfo.setMax(timerInfo.getMax());
-                    apiStatusInfo.setMean(timerInfo.getMean());
-
-                    apiStatusInfo.setP50(timerInfo.getP50());
-                    apiStatusInfo.setP75(timerInfo.getP75());
-                    apiStatusInfo.setP95(timerInfo.getP95());
-                    apiStatusInfo.setP98(timerInfo.getP98());
-                    apiStatusInfo.setP99(timerInfo.getP99());
-                }
-
-                MeterInfo apiErrMeterInfo = apiErrMeterInfoMap.get(mapping);
-                if (null == apiErrMeterInfo) {
-                    apiStatusInfo.setErrorCount(0L);
-                    apiStatusInfo.setErrorMeanRate(0L);
-                    apiStatusInfo.setErrorPercent(0D);
-                } else {
-                    apiStatusInfo.setErrorCount(apiErrMeterInfo.getCount());
-                    apiStatusInfo.setErrorMeanRate(apiErrMeterInfo.getMeanRate());
-                    apiStatusInfo.setErrorPercent(
-                            getPercent(apiErrMeterInfo.getCount(), cur.getCount()));
-                }
-
-            }
-        }
-
-        return list;
-    }
-
-    private Double getPercent(double v1, double v2) {
-        if (0 == v1 || 0 == v2) {
-            return 0d;
-        }
-        double ret = Calculator.divide(v1, v2, 3);
-        return ret;
-    }
-
-}
+// package cn.com.qmth.examcloud.web.actuator;
+//
+// import cn.com.qmth.examcloud.commons.util.Calculator;
+// import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
+// import cn.com.qmth.examcloud.web.support.ApiInfo;
+// import cn.com.qmth.examcloud.web.support.ApiInfoHolder;
+// import com.google.common.collect.Lists;
+// import com.google.common.collect.Maps;
+// import org.springframework.stereotype.Component;
+//
+// import java.util.List;
+// import java.util.Map;
+//
+// @Component
+// public class ApiStatusInfoCollector {
+//
+//     private static String algorithm;
+//
+//     {
+//         // 耗时直方图算法:U:uniform ; B:biased
+//         algorithm = PropertyHolder.getString("$API.statistic.histograms.algorithm", "B");
+//         if (!(algorithm.equals("B") || algorithm.equals("U"))) {
+//             throw new RuntimeException("histograms algorithm must be 'U' or 'B'");
+//         }
+//     }
+//
+//     public synchronized List<ApiStatusInfo> collect(ReportInfo reportInfo) {
+//
+//         List<HistogramInfo> histogramInfoList = reportInfo.getHistogramInfoList();
+//         List<MeterInfo> meterInfoList = reportInfo.getMeterInfoList();
+//         List<TimerInfo> timerInfoList = reportInfo.getTimerInfoList();
+//
+//         Map<String, MeterInfo> apiErrMeterInfoMap = Maps.newHashMap();
+//         for (MeterInfo meterInfo : meterInfoList) {
+//             String key = meterInfo.getKey();
+//             if (key.startsWith(MetricNames.API_ERROR_METER.name())) {
+//                 String mapping = key.substring(MetricNames.API_ERROR_METER.name().length() + 1);
+//                 apiErrMeterInfoMap.put(mapping, meterInfo);
+//             }
+//         }
+//
+//         Map<String, HistogramInfo> apiHistogramInfoMap = Maps.newHashMap();
+//         if (algorithm.equals("U")) {
+//             for (HistogramInfo histogramInfo : histogramInfoList) {
+//                 String key = histogramInfo.getKey();
+//                 if (key.startsWith(MetricNames.API_HISTOGRAM.name())) {
+//                     String mapping = key.substring(MetricNames.API_HISTOGRAM.name().length() + 1);
+//                     apiHistogramInfoMap.put(mapping, histogramInfo);
+//                 }
+//             }
+//         }
+//
+//         Map<String, TimerInfo> apiTimerInfoMap = Maps.newHashMap();
+//         if (algorithm.equals("B")) {
+//             for (TimerInfo timerInfo : timerInfoList) {
+//                 String key = timerInfo.getKey();
+//                 if (key.startsWith(MetricNames.API_TIMER.name())) {
+//                     String mapping = key.substring(MetricNames.API_TIMER.name().length() + 1);
+//                     apiTimerInfoMap.put(mapping, timerInfo);
+//                 }
+//             }
+//         }
+//
+//         List<ApiStatusInfo> list = Lists.newArrayList();
+//
+//         for (MeterInfo cur : meterInfoList) {
+//             String key = cur.getKey();
+//             if (key.startsWith(MetricNames.API_METER.name())) {
+//
+//                 String mapping = key.substring(MetricNames.API_METER.name().length() + 1);
+//
+//                 ApiStatusInfo apiStatusInfo = new ApiStatusInfo();
+//                 list.add(apiStatusInfo);
+//
+//                 apiStatusInfo.setMapping(mapping);
+//
+//                 ApiInfo apiInfo = ApiInfoHolder.getApiInfo(mapping);
+//                 if (null != apiInfo) {
+//                     apiStatusInfo.setDescription(apiInfo.getDescription());
+//                 }
+//
+//                 apiStatusInfo.setCount(cur.getCount());
+//                 apiStatusInfo.setMeanRate(cur.getMeanRate());
+//                 apiStatusInfo.setOneMinuteRate(cur.getOneMinuteRate());
+//                 apiStatusInfo.setFiveMinuteRate(cur.getFiveMinuteRate());
+//                 apiStatusInfo.setFifteenMinuteRate(cur.getFifteenMinuteRate());
+//
+//                 if (algorithm.equals("U")) {
+//                     HistogramInfo histogramInfo = apiHistogramInfoMap.get(mapping);
+//
+//                     apiStatusInfo.setMin(histogramInfo.getMin());
+//                     apiStatusInfo.setMax(histogramInfo.getMax());
+//                     apiStatusInfo.setMean(histogramInfo.getMean());
+//
+//                     apiStatusInfo.setP50(histogramInfo.getP50());
+//                     apiStatusInfo.setP75(histogramInfo.getP75());
+//                     apiStatusInfo.setP95(histogramInfo.getP95());
+//                     apiStatusInfo.setP98(histogramInfo.getP98());
+//                     apiStatusInfo.setP99(histogramInfo.getP99());
+//                 }
+//
+//                 if (algorithm.equals("B")) {
+//                     TimerInfo timerInfo = apiTimerInfoMap.get(mapping);
+//
+//                     apiStatusInfo.setMin(timerInfo.getMin());
+//                     apiStatusInfo.setMax(timerInfo.getMax());
+//                     apiStatusInfo.setMean(timerInfo.getMean());
+//
+//                     apiStatusInfo.setP50(timerInfo.getP50());
+//                     apiStatusInfo.setP75(timerInfo.getP75());
+//                     apiStatusInfo.setP95(timerInfo.getP95());
+//                     apiStatusInfo.setP98(timerInfo.getP98());
+//                     apiStatusInfo.setP99(timerInfo.getP99());
+//                 }
+//
+//                 MeterInfo apiErrMeterInfo = apiErrMeterInfoMap.get(mapping);
+//                 if (null == apiErrMeterInfo) {
+//                     apiStatusInfo.setErrorCount(0L);
+//                     apiStatusInfo.setErrorMeanRate(0L);
+//                     apiStatusInfo.setErrorPercent(0D);
+//                 } else {
+//                     apiStatusInfo.setErrorCount(apiErrMeterInfo.getCount());
+//                     apiStatusInfo.setErrorMeanRate(apiErrMeterInfo.getMeanRate());
+//                     apiStatusInfo.setErrorPercent(
+//                             getPercent(apiErrMeterInfo.getCount(), cur.getCount()));
+//                 }
+//
+//             }
+//         }
+//
+//         return list;
+//     }
+//
+//     private Double getPercent(double v1, double v2) {
+//         if (0 == v1 || 0 == v2) {
+//             return 0d;
+//         }
+//         double ret = Calculator.divide(v1, v2, 3);
+//         return ret;
+//     }
+//
+// }

+ 87 - 87
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/actuator/ApiStatusInfoHolder.java

@@ -1,87 +1,87 @@
-package cn.com.qmth.examcloud.web.actuator;
-
-import cn.com.qmth.examcloud.commons.util.Util;
-import cn.com.qmth.examcloud.web.support.SpringContextHolder;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.apache.commons.lang3.RandomUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.ApplicationArguments;
-import org.springframework.boot.ApplicationRunner;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.stream.Collectors;
-
-@Component
-@Order(1000)
-public class ApiStatusInfoHolder implements ApplicationRunner {
-
-    private static final Logger LOG = LoggerFactory.getLogger(ApiStatusInfoHolder.class);
-
-    private static Map<String, ApiStatusInfo> apiStatusInfoMap = Maps.newHashMap();
-
-    private static List<ApiStatusInfo> apiStatusInfoList = Lists.newArrayList();
-
-    private static AtomicBoolean running = new AtomicBoolean(false);
-
-    public static ApiStatusInfo getApiStatusInfo(String mapping) {
-        return apiStatusInfoMap.get(mapping);
-    }
-
-    public static List<ApiStatusInfo> getApiStatusInfoList() {
-        if (running.get()) {
-            return apiStatusInfoList;
-        }
-
-        refresh();
-        return apiStatusInfoList;
-    }
-
-    @Override
-    public void run(ApplicationArguments args) throws Exception {
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                while (true) {
-                    Util.sleep(5);
-                    refresh();
-                }
-            }
-
-        }).start();
-    }
-
-    private static synchronized void refresh() {
-        long trace = 10000 + RandomUtils.nextLong(0, 89999);
-        // LOG.debug(trace + " [ApiStatus] refresh...");
-
-        running.set(true);
-
-        try {
-            ReportorHolder.getApiDataReportor().report();
-
-            Util.sleep(TimeUnit.MILLISECONDS, 500);
-
-            ReportInfo reportInfo = ReportorHolder.getApiDataReportor().getReportInfo();
-
-            ApiStatusInfoCollector apiStatusInfoCollector = SpringContextHolder.getBean(ApiStatusInfoCollector.class);
-            apiStatusInfoList = apiStatusInfoCollector.collect(reportInfo);
-
-            Map<String, ApiStatusInfo> newApiInfoMap = apiStatusInfoList.stream().collect(Collectors.toMap(ApiStatusInfo::getMapping, info -> info));
-
-            apiStatusInfoMap = newApiInfoMap;
-        } catch (Exception e) {
-            LOG.warn(trace + " [ApiStatus] refresh fail...", e);
-        }
-
-        running.set(false);
-        // LOG.debug(trace + " [ApiStatus] refresh ok...");
-    }
-
-}
+// package cn.com.qmth.examcloud.web.actuator;
+//
+// import cn.com.qmth.examcloud.commons.util.Util;
+// import cn.com.qmth.examcloud.web.support.SpringContextHolder;
+// import com.google.common.collect.Lists;
+// import com.google.common.collect.Maps;
+// import org.apache.commons.lang3.RandomUtils;
+// import org.slf4j.Logger;
+// import org.slf4j.LoggerFactory;
+// import org.springframework.boot.ApplicationArguments;
+// import org.springframework.boot.ApplicationRunner;
+// import org.springframework.core.annotation.Order;
+// import org.springframework.stereotype.Component;
+//
+// import java.util.List;
+// import java.util.Map;
+// import java.util.concurrent.TimeUnit;
+// import java.util.concurrent.atomic.AtomicBoolean;
+// import java.util.stream.Collectors;
+//
+// @Component
+// @Order(1000)
+// public class ApiStatusInfoHolder implements ApplicationRunner {
+//
+//     private static final Logger LOG = LoggerFactory.getLogger(ApiStatusInfoHolder.class);
+//
+//     private static Map<String, ApiStatusInfo> apiStatusInfoMap = Maps.newHashMap();
+//
+//     private static List<ApiStatusInfo> apiStatusInfoList = Lists.newArrayList();
+//
+//     private static AtomicBoolean running = new AtomicBoolean(false);
+//
+//     public static ApiStatusInfo getApiStatusInfo(String mapping) {
+//         return apiStatusInfoMap.get(mapping);
+//     }
+//
+//     public static List<ApiStatusInfo> getApiStatusInfoList() {
+//         if (running.get()) {
+//             return apiStatusInfoList;
+//         }
+//
+//         refresh();
+//         return apiStatusInfoList;
+//     }
+//
+//     @Override
+//     public void run(ApplicationArguments args) throws Exception {
+//         new Thread(new Runnable() {
+//             @Override
+//             public void run() {
+//                 while (true) {
+//                     Util.sleep(5);
+//                     refresh();
+//                 }
+//             }
+//
+//         }).start();
+//     }
+//
+//     private static synchronized void refresh() {
+//         long trace = 10000 + RandomUtils.nextLong(0, 89999);
+//         // LOG.debug(trace + " [ApiStatus] refresh...");
+//
+//         running.set(true);
+//
+//         try {
+//             ReportorHolder.getApiDataReportor().report();
+//
+//             Util.sleep(TimeUnit.MILLISECONDS, 500);
+//
+//             ReportInfo reportInfo = ReportorHolder.getApiDataReportor().getReportInfo();
+//
+//             ApiStatusInfoCollector apiStatusInfoCollector = SpringContextHolder.getBean(ApiStatusInfoCollector.class);
+//             apiStatusInfoList = apiStatusInfoCollector.collect(reportInfo);
+//
+//             Map<String, ApiStatusInfo> newApiInfoMap = apiStatusInfoList.stream().collect(Collectors.toMap(ApiStatusInfo::getMapping, info -> info));
+//
+//             apiStatusInfoMap = newApiInfoMap;
+//         } catch (Exception e) {
+//             LOG.warn(trace + " [ApiStatus] refresh fail...", e);
+//         }
+//
+//         running.set(false);
+//         // LOG.debug(trace + " [ApiStatus] refresh ok...");
+//     }
+//
+// }

+ 274 - 274
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/actuator/DataReportor.java

@@ -1,274 +1,274 @@
-package cn.com.qmth.examcloud.web.actuator;
-
-import com.codahale.metrics.Timer;
-import com.codahale.metrics.*;
-import com.google.common.collect.Lists;
-
-import java.util.*;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-/**
- * 数据报告
- *
- * @author WANGWEI
- * @date 2019年7月25日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
- */
-public class DataReportor extends ScheduledReporter {
-
-    public static Builder forRegistry(MetricRegistry registry) {
-        return new Builder(registry);
-    }
-
-    public static class Builder {
-
-        private final MetricRegistry registry;
-
-        private Clock clock;
-
-        private TimeUnit rateUnit;
-
-        private TimeUnit durationUnit;
-
-        private MetricFilter filter;
-
-        private ScheduledExecutorService executor;
-
-        private boolean shutdownExecutorOnStop;
-
-        private Set<MetricAttribute> disabledMetricAttributes;
-
-        private Builder(MetricRegistry registry) {
-            this.registry = registry;
-            this.clock = Clock.defaultClock();
-            this.rateUnit = TimeUnit.SECONDS;
-            this.durationUnit = TimeUnit.MILLISECONDS;
-            this.filter = MetricFilter.ALL;
-            this.executor = null;
-            this.shutdownExecutorOnStop = true;
-            disabledMetricAttributes = Collections.emptySet();
-        }
-
-        public Builder shutdownExecutorOnStop(boolean shutdownExecutorOnStop) {
-            this.shutdownExecutorOnStop = shutdownExecutorOnStop;
-            return this;
-        }
-
-        public Builder scheduleOn(ScheduledExecutorService executor) {
-            this.executor = executor;
-            return this;
-        }
-
-        public Builder withClock(Clock clock) {
-            this.clock = clock;
-            return this;
-        }
-
-        public Builder convertRatesTo(TimeUnit rateUnit) {
-            this.rateUnit = rateUnit;
-            return this;
-        }
-
-        public Builder convertDurationsTo(TimeUnit durationUnit) {
-            this.durationUnit = durationUnit;
-            return this;
-        }
-
-        public Builder filter(MetricFilter filter) {
-            this.filter = filter;
-            return this;
-        }
-
-        public Builder disabledMetricAttributes(Set<MetricAttribute> disabledMetricAttributes) {
-            this.disabledMetricAttributes = disabledMetricAttributes;
-            return this;
-        }
-
-        public DataReportor build() {
-            return new DataReportor(registry, clock, rateUnit, durationUnit, filter, executor,
-                    shutdownExecutorOnStop, disabledMetricAttributes);
-        }
-
-    }
-
-    private final Clock clock;
-
-    private ReportInfo reportInfo;
-
-    private DataReportor(MetricRegistry registry, Clock clock, TimeUnit rateUnit,
-                         TimeUnit durationUnit, MetricFilter filter, ScheduledExecutorService executor,
-                         boolean shutdownExecutorOnStop, Set<MetricAttribute> disabledMetricAttributes) {
-        super(registry, "data-reporter", filter, rateUnit, durationUnit, executor,
-                shutdownExecutorOnStop, disabledMetricAttributes);
-        this.clock = clock;
-    }
-
-    @Override
-    @SuppressWarnings("rawtypes")
-    public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
-                       SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters,
-                       SortedMap<String, Timer> timers) {
-
-        ReportInfo info = new ReportInfo();
-        info.setDateTime(new Date(clock.getTime()));
-
-        final List<HistogramInfo> histogramInfoList = Lists.newArrayList();
-        final List<TimerInfo> timerInfoList = Lists.newArrayList();
-        final List<MeterInfo> meterInfoList = Lists.newArrayList();
-        info.setHistogramInfoList(histogramInfoList);
-        info.setMeterInfoList(meterInfoList);
-        info.setTimerInfoList(timerInfoList);
-
-        if (!histograms.isEmpty()) {
-            for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
-                HistogramInfo histogramInfo = getHistogramInfo(entry.getKey(), entry.getValue());
-                histogramInfoList.add(histogramInfo);
-            }
-        }
-
-        if (!meters.isEmpty()) {
-            for (Map.Entry<String, Meter> entry : meters.entrySet()) {
-                MeterInfo meterInfo = getMeterInfo(entry.getKey(), entry.getValue());
-                meterInfoList.add(meterInfo);
-            }
-        }
-
-        if (!timers.isEmpty()) {
-            for (Map.Entry<String, Timer> entry : timers.entrySet()) {
-                TimerInfo timerInfo = getTimerInfo(entry.getKey(), entry.getValue());
-                timerInfoList.add(timerInfo);
-            }
-        }
-
-        reportInfo = info;
-    }
-
-    private MeterInfo getMeterInfo(String key, Meter meter) {
-
-        MeterInfo info = new MeterInfo();
-        info.setKey(key);
-        info.setRateUnit(getRateUnit());
-
-        if (isEnabled(MetricAttribute.COUNT)) {
-            info.setCount(meter.getCount());
-        }
-        if (isEnabled(MetricAttribute.MEAN_RATE)) {
-            info.setMeanRate(convertRate(meter.getMeanRate()));
-        }
-
-        if (isEnabled(MetricAttribute.M1_RATE)) {
-            info.setOneMinuteRate(convertRate(meter.getOneMinuteRate()));
-        }
-        if (isEnabled(MetricAttribute.M5_RATE)) {
-            info.setFiveMinuteRate(convertRate(meter.getFiveMinuteRate()));
-        }
-        if (isEnabled(MetricAttribute.M15_RATE)) {
-            info.setFifteenMinuteRate(convertRate(meter.getFifteenMinuteRate()));
-        }
-
-        return info;
-    }
-
-    private HistogramInfo getHistogramInfo(String key, Histogram histogram) {
-        Snapshot snapshot = histogram.getSnapshot();
-        HistogramInfo info = new HistogramInfo();
-        info.setKey(key);
-
-        if (isEnabled(MetricAttribute.MIN)) {
-            info.setMin(snapshot.getMin());
-        }
-        if (isEnabled(MetricAttribute.MAX)) {
-            info.setMax(snapshot.getMax());
-        }
-        if (isEnabled(MetricAttribute.MEAN)) {
-            info.setMean(snapshot.getMean());
-        }
-
-        if (isEnabled(MetricAttribute.P50)) {
-            info.setP50(snapshot.getMedian());
-        }
-        if (isEnabled(MetricAttribute.P75)) {
-            info.setP75(snapshot.get75thPercentile());
-        }
-        if (isEnabled(MetricAttribute.P95)) {
-            info.setP95(snapshot.get95thPercentile());
-        }
-        if (isEnabled(MetricAttribute.P98)) {
-            info.setP98(snapshot.get98thPercentile());
-        }
-        if (isEnabled(MetricAttribute.P99)) {
-            info.setP99(snapshot.get99thPercentile());
-        }
-        if (isEnabled(MetricAttribute.P999)) {
-            info.setP999(snapshot.get999thPercentile());
-        }
-
-        return info;
-    }
-
-    private TimerInfo getTimerInfo(String key, Timer timer) {
-        final Snapshot snapshot = timer.getSnapshot();
-        TimerInfo info = new TimerInfo();
-        info.setKey(key);
-        info.setRateUnit(getRateUnit());
-        info.setDurationUnit(getDurationUnit());
-
-        if (isEnabled(MetricAttribute.COUNT)) {
-            info.setCount(timer.getCount());
-        }
-        if (isEnabled(MetricAttribute.MEAN_RATE)) {
-            info.setMeanRate(convertRate(timer.getMeanRate()));
-        }
-
-        if (isEnabled(MetricAttribute.M1_RATE)) {
-            info.setOneMinuteRate(convertRate(timer.getOneMinuteRate()));
-        }
-        if (isEnabled(MetricAttribute.M5_RATE)) {
-            info.setFiveMinuteRate(convertRate(timer.getFiveMinuteRate()));
-        }
-        if (isEnabled(MetricAttribute.M15_RATE)) {
-            info.setFifteenMinuteRate(convertRate(timer.getFifteenMinuteRate()));
-        }
-
-        if (isEnabled(MetricAttribute.MIN)) {
-            info.setMin(convertDuration(snapshot.getMin()));
-        }
-        if (isEnabled(MetricAttribute.MAX)) {
-            info.setMax(convertDuration(snapshot.getMax()));
-        }
-        if (isEnabled(MetricAttribute.MEAN)) {
-            info.setMean(convertDuration(snapshot.getMean()));
-        }
-
-        if (isEnabled(MetricAttribute.P50)) {
-            info.setP50(convertDuration(snapshot.getMedian()));
-        }
-        if (isEnabled(MetricAttribute.P75)) {
-            info.setP75(convertDuration(snapshot.get75thPercentile()));
-        }
-        if (isEnabled(MetricAttribute.P95)) {
-            info.setP95(convertDuration(snapshot.get95thPercentile()));
-        }
-        if (isEnabled(MetricAttribute.P98)) {
-            info.setP98(convertDuration(snapshot.get98thPercentile()));
-        }
-        if (isEnabled(MetricAttribute.P99)) {
-            info.setP99(convertDuration(snapshot.get99thPercentile()));
-        }
-        if (isEnabled(MetricAttribute.P999)) {
-            info.setP999(convertDuration(snapshot.get999thPercentile()));
-        }
-
-        return info;
-    }
-
-    private boolean isEnabled(MetricAttribute type) {
-        return !getDisabledMetricAttributes().contains(type);
-    }
-
-    public ReportInfo getReportInfo() {
-        return reportInfo;
-    }
-
-}
+// package cn.com.qmth.examcloud.web.actuator;
+//
+// import com.codahale.metrics.Timer;
+// import com.codahale.metrics.*;
+// import com.google.common.collect.Lists;
+//
+// import java.util.*;
+// import java.util.concurrent.ScheduledExecutorService;
+// import java.util.concurrent.TimeUnit;
+//
+// /**
+//  * 数据报告
+//  *
+//  * @author WANGWEI
+//  * @date 2019年7月25日
+//  * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+//  */
+// public class DataReportor extends ScheduledReporter {
+//
+//     public static Builder forRegistry(MetricRegistry registry) {
+//         return new Builder(registry);
+//     }
+//
+//     public static class Builder {
+//
+//         private final MetricRegistry registry;
+//
+//         private Clock clock;
+//
+//         private TimeUnit rateUnit;
+//
+//         private TimeUnit durationUnit;
+//
+//         private MetricFilter filter;
+//
+//         private ScheduledExecutorService executor;
+//
+//         private boolean shutdownExecutorOnStop;
+//
+//         private Set<MetricAttribute> disabledMetricAttributes;
+//
+//         private Builder(MetricRegistry registry) {
+//             this.registry = registry;
+//             this.clock = Clock.defaultClock();
+//             this.rateUnit = TimeUnit.SECONDS;
+//             this.durationUnit = TimeUnit.MILLISECONDS;
+//             this.filter = MetricFilter.ALL;
+//             this.executor = null;
+//             this.shutdownExecutorOnStop = true;
+//             disabledMetricAttributes = Collections.emptySet();
+//         }
+//
+//         public Builder shutdownExecutorOnStop(boolean shutdownExecutorOnStop) {
+//             this.shutdownExecutorOnStop = shutdownExecutorOnStop;
+//             return this;
+//         }
+//
+//         public Builder scheduleOn(ScheduledExecutorService executor) {
+//             this.executor = executor;
+//             return this;
+//         }
+//
+//         public Builder withClock(Clock clock) {
+//             this.clock = clock;
+//             return this;
+//         }
+//
+//         public Builder convertRatesTo(TimeUnit rateUnit) {
+//             this.rateUnit = rateUnit;
+//             return this;
+//         }
+//
+//         public Builder convertDurationsTo(TimeUnit durationUnit) {
+//             this.durationUnit = durationUnit;
+//             return this;
+//         }
+//
+//         public Builder filter(MetricFilter filter) {
+//             this.filter = filter;
+//             return this;
+//         }
+//
+//         public Builder disabledMetricAttributes(Set<MetricAttribute> disabledMetricAttributes) {
+//             this.disabledMetricAttributes = disabledMetricAttributes;
+//             return this;
+//         }
+//
+//         public DataReportor build() {
+//             return new DataReportor(registry, clock, rateUnit, durationUnit, filter, executor,
+//                     shutdownExecutorOnStop, disabledMetricAttributes);
+//         }
+//
+//     }
+//
+//     private final Clock clock;
+//
+//     private ReportInfo reportInfo;
+//
+//     private DataReportor(MetricRegistry registry, Clock clock, TimeUnit rateUnit,
+//                          TimeUnit durationUnit, MetricFilter filter, ScheduledExecutorService executor,
+//                          boolean shutdownExecutorOnStop, Set<MetricAttribute> disabledMetricAttributes) {
+//         super(registry, "data-reporter", filter, rateUnit, durationUnit, executor,
+//                 shutdownExecutorOnStop, disabledMetricAttributes);
+//         this.clock = clock;
+//     }
+//
+//     @Override
+//     @SuppressWarnings("rawtypes")
+//     public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
+//                        SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters,
+//                        SortedMap<String, Timer> timers) {
+//
+//         ReportInfo info = new ReportInfo();
+//         info.setDateTime(new Date(clock.getTime()));
+//
+//         final List<HistogramInfo> histogramInfoList = Lists.newArrayList();
+//         final List<TimerInfo> timerInfoList = Lists.newArrayList();
+//         final List<MeterInfo> meterInfoList = Lists.newArrayList();
+//         info.setHistogramInfoList(histogramInfoList);
+//         info.setMeterInfoList(meterInfoList);
+//         info.setTimerInfoList(timerInfoList);
+//
+//         if (!histograms.isEmpty()) {
+//             for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
+//                 HistogramInfo histogramInfo = getHistogramInfo(entry.getKey(), entry.getValue());
+//                 histogramInfoList.add(histogramInfo);
+//             }
+//         }
+//
+//         if (!meters.isEmpty()) {
+//             for (Map.Entry<String, Meter> entry : meters.entrySet()) {
+//                 MeterInfo meterInfo = getMeterInfo(entry.getKey(), entry.getValue());
+//                 meterInfoList.add(meterInfo);
+//             }
+//         }
+//
+//         if (!timers.isEmpty()) {
+//             for (Map.Entry<String, Timer> entry : timers.entrySet()) {
+//                 TimerInfo timerInfo = getTimerInfo(entry.getKey(), entry.getValue());
+//                 timerInfoList.add(timerInfo);
+//             }
+//         }
+//
+//         reportInfo = info;
+//     }
+//
+//     private MeterInfo getMeterInfo(String key, Meter meter) {
+//
+//         MeterInfo info = new MeterInfo();
+//         info.setKey(key);
+//         info.setRateUnit(getRateUnit());
+//
+//         if (isEnabled(MetricAttribute.COUNT)) {
+//             info.setCount(meter.getCount());
+//         }
+//         if (isEnabled(MetricAttribute.MEAN_RATE)) {
+//             info.setMeanRate(convertRate(meter.getMeanRate()));
+//         }
+//
+//         if (isEnabled(MetricAttribute.M1_RATE)) {
+//             info.setOneMinuteRate(convertRate(meter.getOneMinuteRate()));
+//         }
+//         if (isEnabled(MetricAttribute.M5_RATE)) {
+//             info.setFiveMinuteRate(convertRate(meter.getFiveMinuteRate()));
+//         }
+//         if (isEnabled(MetricAttribute.M15_RATE)) {
+//             info.setFifteenMinuteRate(convertRate(meter.getFifteenMinuteRate()));
+//         }
+//
+//         return info;
+//     }
+//
+//     private HistogramInfo getHistogramInfo(String key, Histogram histogram) {
+//         Snapshot snapshot = histogram.getSnapshot();
+//         HistogramInfo info = new HistogramInfo();
+//         info.setKey(key);
+//
+//         if (isEnabled(MetricAttribute.MIN)) {
+//             info.setMin(snapshot.getMin());
+//         }
+//         if (isEnabled(MetricAttribute.MAX)) {
+//             info.setMax(snapshot.getMax());
+//         }
+//         if (isEnabled(MetricAttribute.MEAN)) {
+//             info.setMean(snapshot.getMean());
+//         }
+//
+//         if (isEnabled(MetricAttribute.P50)) {
+//             info.setP50(snapshot.getMedian());
+//         }
+//         if (isEnabled(MetricAttribute.P75)) {
+//             info.setP75(snapshot.get75thPercentile());
+//         }
+//         if (isEnabled(MetricAttribute.P95)) {
+//             info.setP95(snapshot.get95thPercentile());
+//         }
+//         if (isEnabled(MetricAttribute.P98)) {
+//             info.setP98(snapshot.get98thPercentile());
+//         }
+//         if (isEnabled(MetricAttribute.P99)) {
+//             info.setP99(snapshot.get99thPercentile());
+//         }
+//         if (isEnabled(MetricAttribute.P999)) {
+//             info.setP999(snapshot.get999thPercentile());
+//         }
+//
+//         return info;
+//     }
+//
+//     private TimerInfo getTimerInfo(String key, Timer timer) {
+//         final Snapshot snapshot = timer.getSnapshot();
+//         TimerInfo info = new TimerInfo();
+//         info.setKey(key);
+//         info.setRateUnit(getRateUnit());
+//         info.setDurationUnit(getDurationUnit());
+//
+//         if (isEnabled(MetricAttribute.COUNT)) {
+//             info.setCount(timer.getCount());
+//         }
+//         if (isEnabled(MetricAttribute.MEAN_RATE)) {
+//             info.setMeanRate(convertRate(timer.getMeanRate()));
+//         }
+//
+//         if (isEnabled(MetricAttribute.M1_RATE)) {
+//             info.setOneMinuteRate(convertRate(timer.getOneMinuteRate()));
+//         }
+//         if (isEnabled(MetricAttribute.M5_RATE)) {
+//             info.setFiveMinuteRate(convertRate(timer.getFiveMinuteRate()));
+//         }
+//         if (isEnabled(MetricAttribute.M15_RATE)) {
+//             info.setFifteenMinuteRate(convertRate(timer.getFifteenMinuteRate()));
+//         }
+//
+//         if (isEnabled(MetricAttribute.MIN)) {
+//             info.setMin(convertDuration(snapshot.getMin()));
+//         }
+//         if (isEnabled(MetricAttribute.MAX)) {
+//             info.setMax(convertDuration(snapshot.getMax()));
+//         }
+//         if (isEnabled(MetricAttribute.MEAN)) {
+//             info.setMean(convertDuration(snapshot.getMean()));
+//         }
+//
+//         if (isEnabled(MetricAttribute.P50)) {
+//             info.setP50(convertDuration(snapshot.getMedian()));
+//         }
+//         if (isEnabled(MetricAttribute.P75)) {
+//             info.setP75(convertDuration(snapshot.get75thPercentile()));
+//         }
+//         if (isEnabled(MetricAttribute.P95)) {
+//             info.setP95(convertDuration(snapshot.get95thPercentile()));
+//         }
+//         if (isEnabled(MetricAttribute.P98)) {
+//             info.setP98(convertDuration(snapshot.get98thPercentile()));
+//         }
+//         if (isEnabled(MetricAttribute.P99)) {
+//             info.setP99(convertDuration(snapshot.get99thPercentile()));
+//         }
+//         if (isEnabled(MetricAttribute.P999)) {
+//             info.setP999(convertDuration(snapshot.get999thPercentile()));
+//         }
+//
+//         return info;
+//     }
+//
+//     private boolean isEnabled(MetricAttribute type) {
+//         return !getDisabledMetricAttributes().contains(type);
+//     }
+//
+//     public ReportInfo getReportInfo() {
+//         return reportInfo;
+//     }
+//
+// }

+ 125 - 125
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/actuator/HistogramInfo.java

@@ -1,125 +1,125 @@
-package cn.com.qmth.examcloud.web.actuator;
-
-public class HistogramInfo {
-
-    private String key;
-
-    private Long count;
-
-    private double min;
-
-    private double max;
-
-    private double mean;
-
-    private String durationUnit;
-
-    private double p50;
-
-    private double p75;
-
-    private double p95;
-
-    private double p98;
-
-    private double p99;
-
-    private double p999;
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public Long getCount() {
-        return count;
-    }
-
-    public void setCount(Long count) {
-        this.count = count;
-    }
-
-    public double getMin() {
-        return min;
-    }
-
-    public void setMin(double min) {
-        this.min = min;
-    }
-
-    public double getMax() {
-        return max;
-    }
-
-    public void setMax(double max) {
-        this.max = max;
-    }
-
-    public double getMean() {
-        return mean;
-    }
-
-    public void setMean(double mean) {
-        this.mean = mean;
-    }
-
-    public String getDurationUnit() {
-        return durationUnit;
-    }
-
-    public void setDurationUnit(String durationUnit) {
-        this.durationUnit = durationUnit;
-    }
-
-    public double getP50() {
-        return p50;
-    }
-
-    public void setP50(double p50) {
-        this.p50 = p50;
-    }
-
-    public double getP75() {
-        return p75;
-    }
-
-    public void setP75(double p75) {
-        this.p75 = p75;
-    }
-
-    public double getP95() {
-        return p95;
-    }
-
-    public void setP95(double p95) {
-        this.p95 = p95;
-    }
-
-    public double getP98() {
-        return p98;
-    }
-
-    public void setP98(double p98) {
-        this.p98 = p98;
-    }
-
-    public double getP99() {
-        return p99;
-    }
-
-    public void setP99(double p99) {
-        this.p99 = p99;
-    }
-
-    public double getP999() {
-        return p999;
-    }
-
-    public void setP999(double p999) {
-        this.p999 = p999;
-    }
-
-}
+// package cn.com.qmth.examcloud.web.actuator;
+//
+// public class HistogramInfo {
+//
+//     private String key;
+//
+//     private Long count;
+//
+//     private double min;
+//
+//     private double max;
+//
+//     private double mean;
+//
+//     private String durationUnit;
+//
+//     private double p50;
+//
+//     private double p75;
+//
+//     private double p95;
+//
+//     private double p98;
+//
+//     private double p99;
+//
+//     private double p999;
+//
+//     public String getKey() {
+//         return key;
+//     }
+//
+//     public void setKey(String key) {
+//         this.key = key;
+//     }
+//
+//     public Long getCount() {
+//         return count;
+//     }
+//
+//     public void setCount(Long count) {
+//         this.count = count;
+//     }
+//
+//     public double getMin() {
+//         return min;
+//     }
+//
+//     public void setMin(double min) {
+//         this.min = min;
+//     }
+//
+//     public double getMax() {
+//         return max;
+//     }
+//
+//     public void setMax(double max) {
+//         this.max = max;
+//     }
+//
+//     public double getMean() {
+//         return mean;
+//     }
+//
+//     public void setMean(double mean) {
+//         this.mean = mean;
+//     }
+//
+//     public String getDurationUnit() {
+//         return durationUnit;
+//     }
+//
+//     public void setDurationUnit(String durationUnit) {
+//         this.durationUnit = durationUnit;
+//     }
+//
+//     public double getP50() {
+//         return p50;
+//     }
+//
+//     public void setP50(double p50) {
+//         this.p50 = p50;
+//     }
+//
+//     public double getP75() {
+//         return p75;
+//     }
+//
+//     public void setP75(double p75) {
+//         this.p75 = p75;
+//     }
+//
+//     public double getP95() {
+//         return p95;
+//     }
+//
+//     public void setP95(double p95) {
+//         this.p95 = p95;
+//     }
+//
+//     public double getP98() {
+//         return p98;
+//     }
+//
+//     public void setP98(double p98) {
+//         this.p98 = p98;
+//     }
+//
+//     public double getP99() {
+//         return p99;
+//     }
+//
+//     public void setP99(double p99) {
+//         this.p99 = p99;
+//     }
+//
+//     public double getP999() {
+//         return p999;
+//     }
+//
+//     public void setP999(double p999) {
+//         this.p999 = p999;
+//     }
+//
+// }

+ 75 - 75
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/actuator/MeterInfo.java

@@ -1,75 +1,75 @@
-package cn.com.qmth.examcloud.web.actuator;
-
-public class MeterInfo {
-
-    private String key;
-
-    private Long count;
-
-    private double meanRate;
-
-    private double oneMinuteRate;
-
-    private double fiveMinuteRate;
-
-    private double fifteenMinuteRate;
-
-    private String rateUnit;
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public Long getCount() {
-        return count;
-    }
-
-    public void setCount(Long count) {
-        this.count = count;
-    }
-
-    public double getMeanRate() {
-        return meanRate;
-    }
-
-    public void setMeanRate(double meanRate) {
-        this.meanRate = meanRate;
-    }
-
-    public double getOneMinuteRate() {
-        return oneMinuteRate;
-    }
-
-    public void setOneMinuteRate(double oneMinuteRate) {
-        this.oneMinuteRate = oneMinuteRate;
-    }
-
-    public double getFiveMinuteRate() {
-        return fiveMinuteRate;
-    }
-
-    public void setFiveMinuteRate(double fiveMinuteRate) {
-        this.fiveMinuteRate = fiveMinuteRate;
-    }
-
-    public double getFifteenMinuteRate() {
-        return fifteenMinuteRate;
-    }
-
-    public void setFifteenMinuteRate(double fifteenMinuteRate) {
-        this.fifteenMinuteRate = fifteenMinuteRate;
-    }
-
-    public String getRateUnit() {
-        return rateUnit;
-    }
-
-    public void setRateUnit(String rateUnit) {
-        this.rateUnit = rateUnit;
-    }
-
-}
+// package cn.com.qmth.examcloud.web.actuator;
+//
+// public class MeterInfo {
+//
+//     private String key;
+//
+//     private Long count;
+//
+//     private double meanRate;
+//
+//     private double oneMinuteRate;
+//
+//     private double fiveMinuteRate;
+//
+//     private double fifteenMinuteRate;
+//
+//     private String rateUnit;
+//
+//     public String getKey() {
+//         return key;
+//     }
+//
+//     public void setKey(String key) {
+//         this.key = key;
+//     }
+//
+//     public Long getCount() {
+//         return count;
+//     }
+//
+//     public void setCount(Long count) {
+//         this.count = count;
+//     }
+//
+//     public double getMeanRate() {
+//         return meanRate;
+//     }
+//
+//     public void setMeanRate(double meanRate) {
+//         this.meanRate = meanRate;
+//     }
+//
+//     public double getOneMinuteRate() {
+//         return oneMinuteRate;
+//     }
+//
+//     public void setOneMinuteRate(double oneMinuteRate) {
+//         this.oneMinuteRate = oneMinuteRate;
+//     }
+//
+//     public double getFiveMinuteRate() {
+//         return fiveMinuteRate;
+//     }
+//
+//     public void setFiveMinuteRate(double fiveMinuteRate) {
+//         this.fiveMinuteRate = fiveMinuteRate;
+//     }
+//
+//     public double getFifteenMinuteRate() {
+//         return fifteenMinuteRate;
+//     }
+//
+//     public void setFifteenMinuteRate(double fifteenMinuteRate) {
+//         this.fifteenMinuteRate = fifteenMinuteRate;
+//     }
+//
+//     public String getRateUnit() {
+//         return rateUnit;
+//     }
+//
+//     public void setRateUnit(String rateUnit) {
+//         this.rateUnit = rateUnit;
+//     }
+//
+// }

+ 14 - 14
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/actuator/MetricNames.java

@@ -1,14 +1,14 @@
-package cn.com.qmth.examcloud.web.actuator;
-
-/**
- * 名称元素
- *
- * @author WANGWEI
- * @date 2019年7月25日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
- */
-public enum MetricNames {
-
-    API_TIMER, API_HISTOGRAM, API_METER, API_ERROR_METER
-
-}
+// package cn.com.qmth.examcloud.web.actuator;
+//
+// /**
+//  * 名称元素
+//  *
+//  * @author WANGWEI
+//  * @date 2019年7月25日
+//  * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+//  */
+// public enum MetricNames {
+//
+//     API_TIMER, API_HISTOGRAM, API_METER, API_ERROR_METER
+//
+// }

+ 26 - 26
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/actuator/MetricRegistryHolder.java

@@ -1,26 +1,26 @@
-package cn.com.qmth.examcloud.web.actuator;
-
-import com.codahale.metrics.MetricRegistry;
-
-/**
- * MetricRegistryHolder
- *
- * @author WANGWEI
- * @date 2019年7月25日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
- */
-public class MetricRegistryHolder {
-
-    private static MetricRegistry defaultMetricRegistry = new MetricRegistry();
-
-    /**
-     * 获取默认
-     *
-     * @return
-     * @author WANGWEI
-     */
-    public static MetricRegistry getDefalut() {
-        return defaultMetricRegistry;
-    }
-
-}
+// package cn.com.qmth.examcloud.web.actuator;
+//
+// import com.codahale.metrics.MetricRegistry;
+//
+// /**
+//  * MetricRegistryHolder
+//  *
+//  * @author WANGWEI
+//  * @date 2019年7月25日
+//  * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+//  */
+// public class MetricRegistryHolder {
+//
+//     private static MetricRegistry defaultMetricRegistry = new MetricRegistry();
+//
+//     /**
+//      * 获取默认
+//      *
+//      * @return
+//      * @author WANGWEI
+//      */
+//     public static MetricRegistry getDefalut() {
+//         return defaultMetricRegistry;
+//     }
+//
+// }

+ 48 - 48
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/actuator/ReportInfo.java

@@ -1,48 +1,48 @@
-package cn.com.qmth.examcloud.web.actuator;
-
-import java.util.Date;
-import java.util.List;
-
-public class ReportInfo {
-
-    private List<HistogramInfo> histogramInfoList;
-
-    private List<MeterInfo> meterInfoList;
-
-    private List<TimerInfo> timerInfoList;
-
-    private Date dateTime;
-
-    public List<HistogramInfo> getHistogramInfoList() {
-        return histogramInfoList;
-    }
-
-    public void setHistogramInfoList(List<HistogramInfo> histogramInfoList) {
-        this.histogramInfoList = histogramInfoList;
-    }
-
-    public List<MeterInfo> getMeterInfoList() {
-        return meterInfoList;
-    }
-
-    public void setMeterInfoList(List<MeterInfo> meterInfoList) {
-        this.meterInfoList = meterInfoList;
-    }
-
-    public List<TimerInfo> getTimerInfoList() {
-        return timerInfoList;
-    }
-
-    public void setTimerInfoList(List<TimerInfo> timerInfoList) {
-        this.timerInfoList = timerInfoList;
-    }
-
-    public Date getDateTime() {
-        return dateTime;
-    }
-
-    public void setDateTime(Date dateTime) {
-        this.dateTime = dateTime;
-    }
-
-}
+// package cn.com.qmth.examcloud.web.actuator;
+//
+// import java.util.Date;
+// import java.util.List;
+//
+// public class ReportInfo {
+//
+//     private List<HistogramInfo> histogramInfoList;
+//
+//     private List<MeterInfo> meterInfoList;
+//
+//     private List<TimerInfo> timerInfoList;
+//
+//     private Date dateTime;
+//
+//     public List<HistogramInfo> getHistogramInfoList() {
+//         return histogramInfoList;
+//     }
+//
+//     public void setHistogramInfoList(List<HistogramInfo> histogramInfoList) {
+//         this.histogramInfoList = histogramInfoList;
+//     }
+//
+//     public List<MeterInfo> getMeterInfoList() {
+//         return meterInfoList;
+//     }
+//
+//     public void setMeterInfoList(List<MeterInfo> meterInfoList) {
+//         this.meterInfoList = meterInfoList;
+//     }
+//
+//     public List<TimerInfo> getTimerInfoList() {
+//         return timerInfoList;
+//     }
+//
+//     public void setTimerInfoList(List<TimerInfo> timerInfoList) {
+//         this.timerInfoList = timerInfoList;
+//     }
+//
+//     public Date getDateTime() {
+//         return dateTime;
+//     }
+//
+//     public void setDateTime(Date dateTime) {
+//         this.dateTime = dateTime;
+//     }
+//
+// }

+ 22 - 22
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/actuator/ReportorHolder.java

@@ -1,22 +1,22 @@
-package cn.com.qmth.examcloud.web.actuator;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Reportor Holder
- *
- * @author WANGWEI
- * @date 2019年7月25日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
- */
-public class ReportorHolder {
-
-    private static DataReportor apiReporter = DataReportor
-            .forRegistry(MetricRegistryHolder.getDefalut()).convertRatesTo(TimeUnit.SECONDS)
-            .convertDurationsTo(TimeUnit.MILLISECONDS).build();
-
-    public static DataReportor getApiDataReportor() {
-        return apiReporter;
-    }
-
-}
+// package cn.com.qmth.examcloud.web.actuator;
+//
+// import java.util.concurrent.TimeUnit;
+//
+// /**
+//  * Reportor Holder
+//  *
+//  * @author WANGWEI
+//  * @date 2019年7月25日
+//  * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+//  */
+// public class ReportorHolder {
+//
+//     private static DataReportor apiReporter = DataReportor
+//             .forRegistry(MetricRegistryHolder.getDefalut()).convertRatesTo(TimeUnit.SECONDS)
+//             .convertDurationsTo(TimeUnit.MILLISECONDS).build();
+//
+//     public static DataReportor getApiDataReportor() {
+//         return apiReporter;
+//     }
+//
+// }

+ 175 - 175
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/actuator/TimerInfo.java

@@ -1,175 +1,175 @@
-package cn.com.qmth.examcloud.web.actuator;
-
-public class TimerInfo {
-
-    private String key;
-
-    private Long count;
-
-    private double meanRate;
-
-    private double oneMinuteRate;
-
-    private double fiveMinuteRate;
-
-    private double fifteenMinuteRate;
-
-    private String rateUnit;
-
-    private double min;
-
-    private double max;
-
-    private double mean;
-
-    private String durationUnit;
-
-    private double p50;
-
-    private double p75;
-
-    private double p95;
-
-    private double p98;
-
-    private double p99;
-
-    private double p999;
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public Long getCount() {
-        return count;
-    }
-
-    public void setCount(Long count) {
-        this.count = count;
-    }
-
-    public double getMeanRate() {
-        return meanRate;
-    }
-
-    public void setMeanRate(double meanRate) {
-        this.meanRate = meanRate;
-    }
-
-    public double getOneMinuteRate() {
-        return oneMinuteRate;
-    }
-
-    public void setOneMinuteRate(double oneMinuteRate) {
-        this.oneMinuteRate = oneMinuteRate;
-    }
-
-    public double getFiveMinuteRate() {
-        return fiveMinuteRate;
-    }
-
-    public void setFiveMinuteRate(double fiveMinuteRate) {
-        this.fiveMinuteRate = fiveMinuteRate;
-    }
-
-    public double getFifteenMinuteRate() {
-        return fifteenMinuteRate;
-    }
-
-    public void setFifteenMinuteRate(double fifteenMinuteRate) {
-        this.fifteenMinuteRate = fifteenMinuteRate;
-    }
-
-    public String getRateUnit() {
-        return rateUnit;
-    }
-
-    public void setRateUnit(String rateUnit) {
-        this.rateUnit = rateUnit;
-    }
-
-    public double getMin() {
-        return min;
-    }
-
-    public void setMin(double min) {
-        this.min = min;
-    }
-
-    public double getMax() {
-        return max;
-    }
-
-    public void setMax(double max) {
-        this.max = max;
-    }
-
-    public double getMean() {
-        return mean;
-    }
-
-    public void setMean(double mean) {
-        this.mean = mean;
-    }
-
-    public String getDurationUnit() {
-        return durationUnit;
-    }
-
-    public void setDurationUnit(String durationUnit) {
-        this.durationUnit = durationUnit;
-    }
-
-    public double getP50() {
-        return p50;
-    }
-
-    public void setP50(double p50) {
-        this.p50 = p50;
-    }
-
-    public double getP75() {
-        return p75;
-    }
-
-    public void setP75(double p75) {
-        this.p75 = p75;
-    }
-
-    public double getP95() {
-        return p95;
-    }
-
-    public void setP95(double p95) {
-        this.p95 = p95;
-    }
-
-    public double getP98() {
-        return p98;
-    }
-
-    public void setP98(double p98) {
-        this.p98 = p98;
-    }
-
-    public double getP99() {
-        return p99;
-    }
-
-    public void setP99(double p99) {
-        this.p99 = p99;
-    }
-
-    public double getP999() {
-        return p999;
-    }
-
-    public void setP999(double p999) {
-        this.p999 = p999;
-    }
-
-}
+// package cn.com.qmth.examcloud.web.actuator;
+//
+// public class TimerInfo {
+//
+//     private String key;
+//
+//     private Long count;
+//
+//     private double meanRate;
+//
+//     private double oneMinuteRate;
+//
+//     private double fiveMinuteRate;
+//
+//     private double fifteenMinuteRate;
+//
+//     private String rateUnit;
+//
+//     private double min;
+//
+//     private double max;
+//
+//     private double mean;
+//
+//     private String durationUnit;
+//
+//     private double p50;
+//
+//     private double p75;
+//
+//     private double p95;
+//
+//     private double p98;
+//
+//     private double p99;
+//
+//     private double p999;
+//
+//     public String getKey() {
+//         return key;
+//     }
+//
+//     public void setKey(String key) {
+//         this.key = key;
+//     }
+//
+//     public Long getCount() {
+//         return count;
+//     }
+//
+//     public void setCount(Long count) {
+//         this.count = count;
+//     }
+//
+//     public double getMeanRate() {
+//         return meanRate;
+//     }
+//
+//     public void setMeanRate(double meanRate) {
+//         this.meanRate = meanRate;
+//     }
+//
+//     public double getOneMinuteRate() {
+//         return oneMinuteRate;
+//     }
+//
+//     public void setOneMinuteRate(double oneMinuteRate) {
+//         this.oneMinuteRate = oneMinuteRate;
+//     }
+//
+//     public double getFiveMinuteRate() {
+//         return fiveMinuteRate;
+//     }
+//
+//     public void setFiveMinuteRate(double fiveMinuteRate) {
+//         this.fiveMinuteRate = fiveMinuteRate;
+//     }
+//
+//     public double getFifteenMinuteRate() {
+//         return fifteenMinuteRate;
+//     }
+//
+//     public void setFifteenMinuteRate(double fifteenMinuteRate) {
+//         this.fifteenMinuteRate = fifteenMinuteRate;
+//     }
+//
+//     public String getRateUnit() {
+//         return rateUnit;
+//     }
+//
+//     public void setRateUnit(String rateUnit) {
+//         this.rateUnit = rateUnit;
+//     }
+//
+//     public double getMin() {
+//         return min;
+//     }
+//
+//     public void setMin(double min) {
+//         this.min = min;
+//     }
+//
+//     public double getMax() {
+//         return max;
+//     }
+//
+//     public void setMax(double max) {
+//         this.max = max;
+//     }
+//
+//     public double getMean() {
+//         return mean;
+//     }
+//
+//     public void setMean(double mean) {
+//         this.mean = mean;
+//     }
+//
+//     public String getDurationUnit() {
+//         return durationUnit;
+//     }
+//
+//     public void setDurationUnit(String durationUnit) {
+//         this.durationUnit = durationUnit;
+//     }
+//
+//     public double getP50() {
+//         return p50;
+//     }
+//
+//     public void setP50(double p50) {
+//         this.p50 = p50;
+//     }
+//
+//     public double getP75() {
+//         return p75;
+//     }
+//
+//     public void setP75(double p75) {
+//         this.p75 = p75;
+//     }
+//
+//     public double getP95() {
+//         return p95;
+//     }
+//
+//     public void setP95(double p95) {
+//         this.p95 = p95;
+//     }
+//
+//     public double getP98() {
+//         return p98;
+//     }
+//
+//     public void setP98(double p98) {
+//         this.p98 = p98;
+//     }
+//
+//     public double getP99() {
+//         return p99;
+//     }
+//
+//     public void setP99(double p99) {
+//         this.p99 = p99;
+//     }
+//
+//     public double getP999() {
+//         return p999;
+//     }
+//
+//     public void setP999(double p999) {
+//         this.p999 = p999;
+//     }
+//
+// }

+ 120 - 120
examcloud-support/src/main/java/cn/com/qmth/examcloud/web/interceptor/ApiStatisticInterceptor.java

@@ -1,120 +1,120 @@
-package cn.com.qmth.examcloud.web.interceptor;
-
-import cn.com.qmth.examcloud.web.actuator.MetricNames;
-import cn.com.qmth.examcloud.web.actuator.MetricRegistryHolder;
-import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
-import cn.com.qmth.examcloud.web.enums.HttpServletRequestAttribute;
-import cn.com.qmth.examcloud.web.support.ApiInfo;
-import com.codahale.metrics.Histogram;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.Timer;
-import com.codahale.metrics.Timer.Context;
-import org.springframework.web.servlet.HandlerInterceptor;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * API统计拦截器<br>
- * Timer 和 Histogram 只能使用一个<br>
- * Timer 为最近耗时<br>
- * Histogram 为全局耗时<br>
- *
- * @author WANGWEI
- * @date 2019年7月24日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
- */
-@Deprecated
-public class ApiStatisticInterceptor implements HandlerInterceptor {
-
-    private static boolean enable = false;
-
-    private static String algorithm;
-
-    static {
-        // init();
-    }
-
-    private static void init() {
-        // 耗时直方图算法:U:uniform ; B:biased
-        algorithm = PropertyHolder.getString("$API.statistic.histograms.algorithm", "B");
-        if (!(algorithm.equals("B") || algorithm.equals("U"))) {
-            throw new RuntimeException("histograms algorithm must be 'U' or 'B'");
-        }
-    }
-
-    @Override
-    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
-        if (!enable) {
-            return true;
-        }
-
-        ApiInfo apiInfo = (ApiInfo) request
-                .getAttribute(HttpServletRequestAttribute.$_API_INFO.name());
-
-        if (null == apiInfo) {
-            return true;
-        }
-
-        // Timer 统计
-        if (algorithm.equals("B")) {
-            Timer timer = MetricRegistryHolder.getDefalut()
-                    .timer(MetricRegistry.name(MetricNames.API_TIMER.name(), apiInfo.getMapping()));
-            Context ctx = timer.time();
-            request.setAttribute(HttpServletRequestAttribute.$_METRICS_TIMER_CTX.name(), ctx);
-        }
-
-        if (algorithm.equals("U")) {
-            request.setAttribute(
-                    HttpServletRequestAttribute.API_STATISTIC_INTERCEPTOR_START_TIME.name(),
-                    System.currentTimeMillis());
-        }
-
-        return true;
-    }
-
-    @Override
-    public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
-                                Object handler, Exception ex) throws Exception {
-        if (!enable) {
-            return;
-        }
-
-        ApiInfo apiInfo = (ApiInfo) request.getAttribute(HttpServletRequestAttribute.$_API_INFO.name());
-        if (null == apiInfo) {
-            return;
-        }
-
-        // Timer 统计
-        if (algorithm.equals("B")) {
-            Context ctx = (Context) request.getAttribute(HttpServletRequestAttribute.$_METRICS_TIMER_CTX.name());
-            if (null != ctx) {
-                ctx.stop();
-            }
-        }
-
-        // Histogram 统计
-        if (algorithm.equals("U")) {
-            Histogram histogram = MetricRegistryHolder.getDefalut().histogram(MetricRegistry.name(MetricNames.API_HISTOGRAM.name(), apiInfo.getMapping()));
-            Long startTime = (Long) request.getAttribute(HttpServletRequestAttribute.API_STATISTIC_INTERCEPTOR_START_TIME.name());
-            histogram.update(System.currentTimeMillis() - startTime);
-        }
-
-        // 失败速率
-        Boolean hasException = (Boolean) request.getAttribute(HttpServletRequestAttribute.$_EXCEPTION_HAPPENED.name());
-
-        if (null != hasException && hasException) {
-            Meter apiErrorMeter = MetricRegistryHolder.getDefalut().meter(
-                    MetricRegistry.name(MetricNames.API_ERROR_METER.name(), apiInfo.getMapping()));
-            apiErrorMeter.mark();
-        }
-
-        // 请求速率
-        Meter apiMeter = MetricRegistryHolder.getDefalut()
-                .meter(MetricRegistry.name(MetricNames.API_METER.name(), apiInfo.getMapping()));
-        apiMeter.mark();
-
-    }
-
-}
+// package cn.com.qmth.examcloud.web.interceptor;
+//
+// import cn.com.qmth.examcloud.web.actuator.MetricNames;
+// import cn.com.qmth.examcloud.web.actuator.MetricRegistryHolder;
+// import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
+// import cn.com.qmth.examcloud.web.enums.HttpServletRequestAttribute;
+// import cn.com.qmth.examcloud.web.support.ApiInfo;
+// import com.codahale.metrics.Histogram;
+// import com.codahale.metrics.Meter;
+// import com.codahale.metrics.MetricRegistry;
+// import com.codahale.metrics.Timer;
+// import com.codahale.metrics.Timer.Context;
+// import org.springframework.web.servlet.HandlerInterceptor;
+//
+// import javax.servlet.http.HttpServletRequest;
+// import javax.servlet.http.HttpServletResponse;
+//
+// /**
+//  * API统计拦截器<br>
+//  * Timer 和 Histogram 只能使用一个<br>
+//  * Timer 为最近耗时<br>
+//  * Histogram 为全局耗时<br>
+//  *
+//  * @author WANGWEI
+//  * @date 2019年7月24日
+//  * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+//  */
+// @Deprecated
+// public class ApiStatisticInterceptor implements HandlerInterceptor {
+//
+//     private static boolean enable = false;
+//
+//     private static String algorithm;
+//
+//     static {
+//         // init();
+//     }
+//
+//     private static void init() {
+//         // 耗时直方图算法:U:uniform ; B:biased
+//         algorithm = PropertyHolder.getString("$API.statistic.histograms.algorithm", "B");
+//         if (!(algorithm.equals("B") || algorithm.equals("U"))) {
+//             throw new RuntimeException("histograms algorithm must be 'U' or 'B'");
+//         }
+//     }
+//
+//     @Override
+//     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+//         if (!enable) {
+//             return true;
+//         }
+//
+//         ApiInfo apiInfo = (ApiInfo) request
+//                 .getAttribute(HttpServletRequestAttribute.$_API_INFO.name());
+//
+//         if (null == apiInfo) {
+//             return true;
+//         }
+//
+//         // Timer 统计
+//         if (algorithm.equals("B")) {
+//             Timer timer = MetricRegistryHolder.getDefalut()
+//                     .timer(MetricRegistry.name(MetricNames.API_TIMER.name(), apiInfo.getMapping()));
+//             Context ctx = timer.time();
+//             request.setAttribute(HttpServletRequestAttribute.$_METRICS_TIMER_CTX.name(), ctx);
+//         }
+//
+//         if (algorithm.equals("U")) {
+//             request.setAttribute(
+//                     HttpServletRequestAttribute.API_STATISTIC_INTERCEPTOR_START_TIME.name(),
+//                     System.currentTimeMillis());
+//         }
+//
+//         return true;
+//     }
+//
+//     @Override
+//     public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
+//                                 Object handler, Exception ex) throws Exception {
+//         if (!enable) {
+//             return;
+//         }
+//
+//         ApiInfo apiInfo = (ApiInfo) request.getAttribute(HttpServletRequestAttribute.$_API_INFO.name());
+//         if (null == apiInfo) {
+//             return;
+//         }
+//
+//         // Timer 统计
+//         if (algorithm.equals("B")) {
+//             Context ctx = (Context) request.getAttribute(HttpServletRequestAttribute.$_METRICS_TIMER_CTX.name());
+//             if (null != ctx) {
+//                 ctx.stop();
+//             }
+//         }
+//
+//         // Histogram 统计
+//         if (algorithm.equals("U")) {
+//             Histogram histogram = MetricRegistryHolder.getDefalut().histogram(MetricRegistry.name(MetricNames.API_HISTOGRAM.name(), apiInfo.getMapping()));
+//             Long startTime = (Long) request.getAttribute(HttpServletRequestAttribute.API_STATISTIC_INTERCEPTOR_START_TIME.name());
+//             histogram.update(System.currentTimeMillis() - startTime);
+//         }
+//
+//         // 失败速率
+//         Boolean hasException = (Boolean) request.getAttribute(HttpServletRequestAttribute.$_EXCEPTION_HAPPENED.name());
+//
+//         if (null != hasException && hasException) {
+//             Meter apiErrorMeter = MetricRegistryHolder.getDefalut().meter(
+//                     MetricRegistry.name(MetricNames.API_ERROR_METER.name(), apiInfo.getMapping()));
+//             apiErrorMeter.mark();
+//         }
+//
+//         // 请求速率
+//         Meter apiMeter = MetricRegistryHolder.getDefalut()
+//                 .meter(MetricRegistry.name(MetricNames.API_METER.name(), apiInfo.getMapping()));
+//         apiMeter.mark();
+//
+//     }
+//
+// }