diff --git a/fizz-core/src/main/java/we/stats/FlowStat.java b/fizz-core/src/main/java/we/stats/FlowStat.java index 306fc9b..5a9b322 100644 --- a/fizz-core/src/main/java/we/stats/FlowStat.java +++ b/fizz-core/src/main/java/we/stats/FlowStat.java @@ -17,11 +17,8 @@ package we.stats; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutorService; @@ -565,7 +562,7 @@ public class FlowStat { long lastSlotId = stat.currentTimeSlotId() - n; while (true) { long slotId = stat.currentTimeSlotId() - n; - if (log.isDebugEnabled()) { + /*if (log.isDebugEnabled()) { log.debug("{} - {} resource stats size {}", lastSlotId, slotId, stat.resourceStats.size()); } Set> es = stat.resourceStats.entrySet(); @@ -575,21 +572,46 @@ public class FlowStat { if (log.isDebugEnabled()) { log.debug("{} - {} {} has {} timeslot", lastSlotId, slotId, resourceId, timeSlots.size()); } - } + }*/ for (long i = lastSlotId; i < slotId;) { Set> entrys = stat.resourceStats.entrySet(); for (Entry entry : entrys) { String resourceId = entry.getKey(); ConcurrentMap timeSlots = entry.getValue().getTimeSlots(); - if (log.isDebugEnabled()) { + /*if (log.isDebugEnabled()) { log.debug("{} - {} {} remove {} timeslot", lastSlotId, slotId, resourceId, i); - } + }*/ timeSlots.remove(i); } i = i + FlowStat.INTERVAL; } lastSlotId = slotId; // log.debug("housekeeping done"); + + + /*long currentTimeSlot = stat.currentTimeSlotId(); + long startTimeSlot = currentTimeSlot - n; + for (Entry entry : stat.resourceStats.entrySet()) { + String resource = entry.getKey(); + if (ResourceIdUtils.NODE_RESOURCE.equals(resource)) { + continue; + } + ResourceStat resourceStat = entry.getValue(); + boolean noTraffic = true; + long timeSlot = startTimeSlot; + for ( ; timeSlot < currentTimeSlot; timeSlot += FlowStat.INTERVAL) { + int reqCnt = resourceStat.getTimeSlot(timeSlot).getCounter(); + if (reqCnt > 0) { + noTraffic = false; + break; + } + } + if (noTraffic) { + stat.resourceStats.remove(resource); + } + }*/ + + try { Thread.sleep(10 * 1000); } catch (Exception e) {