From 7dbf805decc31a83ad0ec5c27435d2e93a761c4a Mon Sep 17 00:00:00 2001 From: hongqiaowei Date: Sat, 9 Jan 2021 17:28:00 +0800 Subject: [PATCH] update: 210109-04 --- .../java/we/controller/FlowControlController.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/we/controller/FlowControlController.java b/src/main/java/we/controller/FlowControlController.java index f72fca1..e6440e5 100644 --- a/src/main/java/we/controller/FlowControlController.java +++ b/src/main/java/we/controller/FlowControlController.java @@ -66,14 +66,17 @@ public class FlowControlController { try { FlowStat flowStat = flowControlFilter.getFlowStat(); long currentTimeSlot = flowStat.currentTimeSlotId(); + // recent = 30; long startTimeSlot = currentTimeSlot - recent * 1000; + TimeWindowStat timeWindowStat = null; + // System.err.println("startTimeSlot: " + startTimeSlot + ", currentTimeSlot: " + currentTimeSlot + ", recent: " + recent); List wins = flowStat.getResourceTimeWindowStats(ResourceRateLimitConfig.GLOBAL, startTimeSlot, currentTimeSlot, recent); if (wins == null || wins.isEmpty()) { result.put("rps", 0); } else { concurrents = flowStat.getConcurrentRequests(ResourceRateLimitConfig.GLOBAL); result.put("concurrents", concurrents); - TimeWindowStat timeWindowStat = wins.get(0).getWindows().get(0); + timeWindowStat = wins.get(0).getWindows().get(0); BigDecimal winrps = timeWindowStat.getRps(); if (winrps == null) { rps = 0; @@ -81,9 +84,13 @@ public class FlowControlController { rps = winrps.doubleValue(); } result.put("rps", rps); - // if (log.isDebugEnabled()) { - // log.debug(toDP19(startTimeSlot) + " - " + toDP19(currentTimeSlot) + " global completes " + timeWindowStat.getCompReqs() + " concurrents " + concurrents + " rps " + rps); - // } + } + if (log.isDebugEnabled()) { + long compReqs = -1; + if (timeWindowStat != null) { + compReqs = timeWindowStat.getCompReqs(); + } + log.debug(toDP19(startTimeSlot) + " - " + toDP19(currentTimeSlot) + " result: " + JacksonUtils.writeValueAsString(result) + ", complete reqs: " + compReqs); } } catch (Throwable t) {