update unit tests and typo
This commit is contained in:
@@ -73,9 +73,9 @@ public class FlowStat {
|
|||||||
* @param resourceId Resource ID
|
* @param resourceId Resource ID
|
||||||
*/
|
*/
|
||||||
public void incrConcurrentRequest(String resourceId) {
|
public void incrConcurrentRequest(String resourceId) {
|
||||||
ResourceStat ResourceStat = getResourceStat(resourceId);
|
ResourceStat resourceStat = getResourceStat(resourceId);
|
||||||
ResourceStat allResourceStat = getResourceStat(ALL_RESOURCES);
|
ResourceStat allResourceStat = getResourceStat(ALL_RESOURCES);
|
||||||
ResourceStat.incrConcurrentRequest();
|
resourceStat.incrConcurrentRequest();
|
||||||
allResourceStat.incrConcurrentRequest();
|
allResourceStat.incrConcurrentRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,8 +88,8 @@ public class FlowStat {
|
|||||||
* @param resourceId Resource ID
|
* @param resourceId Resource ID
|
||||||
*/
|
*/
|
||||||
public int getConcurrentRequests(String resourceId) {
|
public int getConcurrentRequests(String resourceId) {
|
||||||
ResourceStat ResourceStat = getResourceStat(resourceId);
|
ResourceStat resourceStat = getResourceStat(resourceId);
|
||||||
return ResourceStat.getConcurrentRequests().get();
|
return resourceStat.getConcurrentRequests().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,24 +117,24 @@ public class FlowStat {
|
|||||||
if (resourceId == null) {
|
if (resourceId == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ResourceStat ResourceStat = getResourceStat(resourceId);
|
ResourceStat resourceStat = getResourceStat(resourceId);
|
||||||
ResourceStat allResourceStat = getResourceStat(ALL_RESOURCES);
|
ResourceStat allResourceStat = getResourceStat(ALL_RESOURCES);
|
||||||
ResourceStat.incrRequestToTimeSlot(timeSlotId, rt, isSuccess);
|
resourceStat.incrRequestToTimeSlot(timeSlotId, rt, isSuccess);
|
||||||
allResourceStat.incrRequestToTimeSlot(timeSlotId, rt, isSuccess);
|
allResourceStat.incrRequestToTimeSlot(timeSlotId, rt, isSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResourceStat getResourceStat(String resourceId) {
|
private ResourceStat getResourceStat(String resourceId) {
|
||||||
ResourceStat ResourceStat = null;
|
ResourceStat resourceStat = null;
|
||||||
if (resourceStats.containsKey(resourceId)) {
|
if (resourceStats.containsKey(resourceId)) {
|
||||||
ResourceStat = resourceStats.get(resourceId);
|
resourceStat = resourceStats.get(resourceId);
|
||||||
} else {
|
} else {
|
||||||
ResourceStat = new ResourceStat(resourceId);
|
resourceStat = new ResourceStat(resourceId);
|
||||||
ResourceStat rs = resourceStats.putIfAbsent(resourceId, ResourceStat);
|
ResourceStat rs = resourceStats.putIfAbsent(resourceId, resourceStat);
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
ResourceStat = rs;
|
resourceStat = rs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ResourceStat;
|
return resourceStat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -175,8 +175,8 @@ public class FlowStat {
|
|||||||
endSlotId = endSlotId + INTERVAL;
|
endSlotId = endSlotId + INTERVAL;
|
||||||
}
|
}
|
||||||
if (resourceStats.containsKey(resourceId)) {
|
if (resourceStats.containsKey(resourceId)) {
|
||||||
ResourceStat ResourceStat = resourceStats.get(resourceId);
|
ResourceStat resourceStat = resourceStats.get(resourceId);
|
||||||
return ResourceStat.getTimeWindowStat(startSlotId, endSlotId);
|
return resourceStat.getTimeWindowStat(startSlotId, endSlotId);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class FlowStatTests {
|
|||||||
int rtBase3 = 3;
|
int rtBase3 = 3;
|
||||||
TimeWindowStat tws1 = stat.getTimeWindowStat("resource-" + resource1, start, end);
|
TimeWindowStat tws1 = stat.getTimeWindowStat("resource-" + resource1, start, end);
|
||||||
TimeWindowStat tws2 = stat.getTimeWindowStat("resource-" + resource2, start, end);
|
TimeWindowStat tws2 = stat.getTimeWindowStat("resource-" + resource2, start, end);
|
||||||
TimeWindowStat tws = stat.getTimeWindowStat(FlowStat.ALL_TOUTES, start, end);
|
TimeWindowStat tws = stat.getTimeWindowStat(FlowStat.ALL_RESOURCES, start, end);
|
||||||
|
|
||||||
assertEquals(totalRequests / resources, tws1.getTotal());
|
assertEquals(totalRequests / resources, tws1.getTotal());
|
||||||
assertEquals(rt * rtBase1, tws1.getAvgRt());
|
assertEquals(rt * rtBase1, tws1.getAvgRt());
|
||||||
@@ -124,6 +124,7 @@ public class FlowStatTests {
|
|||||||
// System.out.println(JacksonUtils.writeValueAsString(stat.resourceStats));
|
// System.out.println(JacksonUtils.writeValueAsString(stat.resourceStats));
|
||||||
|
|
||||||
List<ResourceTimeWindowStat> list = stat.getResourceTimeWindowStats("resource-" + 1, start, end, 10);
|
List<ResourceTimeWindowStat> list = stat.getResourceTimeWindowStats("resource-" + 1, start, end, 10);
|
||||||
|
assertEquals(nsecs / 10, list.get(0).getWindows().size());
|
||||||
System.out.println(JacksonUtils.writeValueAsString(list));
|
System.out.println(JacksonUtils.writeValueAsString(list));
|
||||||
} else {
|
} else {
|
||||||
System.out.println("timeout");
|
System.out.println("timeout");
|
||||||
|
|||||||
Reference in New Issue
Block a user