Comment resource clean logic
This commit is contained in:
@@ -17,11 +17,8 @@
|
|||||||
|
|
||||||
package we.stats;
|
package we.stats;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
@@ -565,7 +562,7 @@ public class FlowStat {
|
|||||||
long lastSlotId = stat.currentTimeSlotId() - n;
|
long lastSlotId = stat.currentTimeSlotId() - n;
|
||||||
while (true) {
|
while (true) {
|
||||||
long slotId = stat.currentTimeSlotId() - n;
|
long slotId = stat.currentTimeSlotId() - n;
|
||||||
if (log.isDebugEnabled()) {
|
/*if (log.isDebugEnabled()) {
|
||||||
log.debug("{} - {} resource stats size {}", lastSlotId, slotId, stat.resourceStats.size());
|
log.debug("{} - {} resource stats size {}", lastSlotId, slotId, stat.resourceStats.size());
|
||||||
}
|
}
|
||||||
Set<Map.Entry<String, ResourceStat>> es = stat.resourceStats.entrySet();
|
Set<Map.Entry<String, ResourceStat>> es = stat.resourceStats.entrySet();
|
||||||
@@ -575,21 +572,46 @@ public class FlowStat {
|
|||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("{} - {} {} has {} timeslot", lastSlotId, slotId, resourceId, timeSlots.size());
|
log.debug("{} - {} {} has {} timeslot", lastSlotId, slotId, resourceId, timeSlots.size());
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
for (long i = lastSlotId; i < slotId;) {
|
for (long i = lastSlotId; i < slotId;) {
|
||||||
Set<Map.Entry<String, ResourceStat>> entrys = stat.resourceStats.entrySet();
|
Set<Map.Entry<String, ResourceStat>> entrys = stat.resourceStats.entrySet();
|
||||||
for (Entry<String, ResourceStat> entry : entrys) {
|
for (Entry<String, ResourceStat> entry : entrys) {
|
||||||
String resourceId = entry.getKey();
|
String resourceId = entry.getKey();
|
||||||
ConcurrentMap<Long, TimeSlot> timeSlots = entry.getValue().getTimeSlots();
|
ConcurrentMap<Long, TimeSlot> timeSlots = entry.getValue().getTimeSlots();
|
||||||
if (log.isDebugEnabled()) {
|
/*if (log.isDebugEnabled()) {
|
||||||
log.debug("{} - {} {} remove {} timeslot", lastSlotId, slotId, resourceId, i);
|
log.debug("{} - {} {} remove {} timeslot", lastSlotId, slotId, resourceId, i);
|
||||||
}
|
}*/
|
||||||
timeSlots.remove(i);
|
timeSlots.remove(i);
|
||||||
}
|
}
|
||||||
i = i + FlowStat.INTERVAL;
|
i = i + FlowStat.INTERVAL;
|
||||||
}
|
}
|
||||||
lastSlotId = slotId;
|
lastSlotId = slotId;
|
||||||
// log.debug("housekeeping done");
|
// log.debug("housekeeping done");
|
||||||
|
|
||||||
|
|
||||||
|
/*long currentTimeSlot = stat.currentTimeSlotId();
|
||||||
|
long startTimeSlot = currentTimeSlot - n;
|
||||||
|
for (Entry<String, ResourceStat> 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 {
|
try {
|
||||||
Thread.sleep(10 * 1000);
|
Thread.sleep(10 * 1000);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user