refactor for behaviorsBrief
This commit is contained in:
parent
9cdaf9462e
commit
c32e58c19d
|
@ -223,7 +223,6 @@ public class TestController {
|
||||||
behaviorBriefModel.setBehaviorId(behaviorId);
|
behaviorBriefModel.setBehaviorId(behaviorId);
|
||||||
behaviorBriefModel
|
behaviorBriefModel
|
||||||
.setDetailStatusCodeResultModels(detailStatusCodeResultModels);
|
.setDetailStatusCodeResultModels(detailStatusCodeResultModels);
|
||||||
behaviorBriefModel.setTestId(runId);
|
|
||||||
return behaviorBriefModel;
|
return behaviorBriefModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,16 @@
|
||||||
package org.bench4q.agent.api.model;
|
package org.bench4q.agent.api.model;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
@XmlRootElement(name = "BehaviorBriefModel")
|
@XmlRootElement(name = "BehaviorBriefModel")
|
||||||
public class BehaviorBriefModel {
|
public class BehaviorBriefModel {
|
||||||
private UUID testId;
|
|
||||||
private int behaviorId;
|
private int behaviorId;
|
||||||
private int behaviorUrl;
|
private String behaviorUrl;
|
||||||
private List<BehaviorStatusCodeResultModel> detailStatusCodeResultModels;
|
private List<BehaviorStatusCodeResultModel> detailStatusCodeResultModels;
|
||||||
|
|
||||||
@XmlElement
|
|
||||||
public UUID getTestId() {
|
|
||||||
return testId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTestId(UUID testId) {
|
|
||||||
this.testId = testId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlElement
|
@XmlElement
|
||||||
public int getBehaviorId() {
|
public int getBehaviorId() {
|
||||||
return behaviorId;
|
return behaviorId;
|
||||||
|
@ -33,11 +21,11 @@ public class BehaviorBriefModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement
|
@XmlElement
|
||||||
public int getBehaviorUrl() {
|
public String getBehaviorUrl() {
|
||||||
return behaviorUrl;
|
return behaviorUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBehaviorUrl(int behaviorUrl) {
|
public void setBehaviorUrl(String behaviorUrl) {
|
||||||
this.behaviorUrl = behaviorUrl;
|
this.behaviorUrl = behaviorUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,14 +84,10 @@ public class AgentResultDataCollector extends AbstractDataCollector {
|
||||||
return testID == null ? "default" : testID.toString();
|
return testID == null ? "default" : testID.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTestID(UUID testID) {
|
private void setTestID(UUID testID) {
|
||||||
this.testID = testID;
|
this.testID = testID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, Map<Integer, DetailStatusCodeResult>> getDetailMap() {
|
|
||||||
return detailMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDetailMap(
|
private void setDetailMap(
|
||||||
Map<Integer, Map<Integer, DetailStatusCodeResult>> detailMap) {
|
Map<Integer, Map<Integer, DetailStatusCodeResult>> detailMap) {
|
||||||
this.detailMap = detailMap;
|
this.detailMap = detailMap;
|
||||||
|
@ -103,7 +99,7 @@ public class AgentResultDataCollector extends AbstractDataCollector {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
private void init() {
|
||||||
reset();
|
reset();
|
||||||
this.setCumulativeFailCount(0);
|
this.setCumulativeFailCount(0);
|
||||||
this.setCumulativeSucessfulCount(0);
|
this.setCumulativeSucessfulCount(0);
|
||||||
|
@ -191,16 +187,15 @@ public class AgentResultDataCollector extends AbstractDataCollector {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dealWithDetailResult(BehaviorResult behaviorResult) {
|
private void dealWithDetailResult(BehaviorResult behaviorResult) {
|
||||||
if (!this.detailMap.containsKey(behaviorResult.getBehaviorId())) {
|
insertWhenNotExist(behaviorResult);
|
||||||
this.detailMap.put(new Integer(behaviorResult.getBehaviorId()),
|
|
||||||
new HashMap<Integer, DetailStatusCodeResult>());
|
|
||||||
}
|
|
||||||
Map<Integer, DetailStatusCodeResult> detailStatusMap = this.detailMap
|
Map<Integer, DetailStatusCodeResult> detailStatusMap = this.detailMap
|
||||||
.get(behaviorResult.getBehaviorId());
|
.get(behaviorResult.getBehaviorId());
|
||||||
|
|
||||||
if (!detailStatusMap.containsKey(behaviorResult.getStatusCode())) {
|
if (!detailStatusMap.containsKey(behaviorResult.getStatusCode())) {
|
||||||
detailStatusMap.put(new Integer(behaviorResult.getStatusCode()),
|
detailStatusMap
|
||||||
new DetailStatusCodeResult());
|
.put(new Integer(behaviorResult.getStatusCode()),
|
||||||
|
new DetailStatusCodeResult(behaviorResult
|
||||||
|
.getContentType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DetailStatusCodeResult detailResult = detailStatusMap
|
DetailStatusCodeResult detailResult = detailStatusMap
|
||||||
|
@ -212,7 +207,6 @@ public class AgentResultDataCollector extends AbstractDataCollector {
|
||||||
detailResult.contentLength = 0;
|
detailResult.contentLength = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
detailResult.contentType = behaviorResult.getContentType();
|
|
||||||
detailResult.contentLength += behaviorResult.getContentLength();
|
detailResult.contentLength += behaviorResult.getContentLength();
|
||||||
if (behaviorResult.getResponseTime() > detailResult.maxResponseTime) {
|
if (behaviorResult.getResponseTime() > detailResult.maxResponseTime) {
|
||||||
detailResult.maxResponseTime = behaviorResult.getResponseTime();
|
detailResult.maxResponseTime = behaviorResult.getResponseTime();
|
||||||
|
@ -222,6 +216,13 @@ public class AgentResultDataCollector extends AbstractDataCollector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void insertWhenNotExist(BehaviorResult behaviorResult) {
|
||||||
|
if (!this.detailMap.containsKey(behaviorResult.getBehaviorId())) {
|
||||||
|
this.detailMap.put(new Integer(behaviorResult.getBehaviorId()),
|
||||||
|
new HashMap<Integer, DetailStatusCodeResult>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(BehaviorResult behaviorResult) {
|
public void add(BehaviorResult behaviorResult) {
|
||||||
super.add(behaviorResult);
|
super.add(behaviorResult);
|
||||||
|
|
|
@ -9,7 +9,8 @@ public class DetailStatusCodeResult {
|
||||||
public long maxResponseTime;
|
public long maxResponseTime;
|
||||||
public String contentType;
|
public String contentType;
|
||||||
|
|
||||||
public DetailStatusCodeResult() {
|
public DetailStatusCodeResult(String contentType) {
|
||||||
|
this.contentType = contentType;
|
||||||
this.count = 0;
|
this.count = 0;
|
||||||
this.contentLength = 0;
|
this.contentLength = 0;
|
||||||
this.minResponseTime = Long.MAX_VALUE;
|
this.minResponseTime = Long.MAX_VALUE;
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class DetailStatisticsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private DetailStatusCodeResult makeExpectedResultForOne() {
|
private DetailStatusCodeResult makeExpectedResultForOne() {
|
||||||
DetailStatusCodeResult ret = new DetailStatusCodeResult();
|
DetailStatusCodeResult ret = new DetailStatusCodeResult("");
|
||||||
ret.contentLength = 20;
|
ret.contentLength = 20;
|
||||||
ret.count = 1;
|
ret.count = 1;
|
||||||
ret.maxResponseTime = 200;
|
ret.maxResponseTime = 200;
|
||||||
|
@ -95,7 +95,7 @@ public class DetailStatisticsTest {
|
||||||
|
|
||||||
private DetailStatusCodeResult buildCodeResult(long contentLength,
|
private DetailStatusCodeResult buildCodeResult(long contentLength,
|
||||||
long count, long maxResponseTime, long minResponseTime) {
|
long count, long maxResponseTime, long minResponseTime) {
|
||||||
DetailStatusCodeResult ret = new DetailStatusCodeResult();
|
DetailStatusCodeResult ret = new DetailStatusCodeResult("");
|
||||||
ret.contentLength = contentLength;
|
ret.contentLength = contentLength;
|
||||||
ret.count = count;
|
ret.count = count;
|
||||||
ret.maxResponseTime = maxResponseTime;
|
ret.maxResponseTime = maxResponseTime;
|
||||||
|
|
Loading…
Reference in New Issue