refactor for behaviorsBrief

This commit is contained in:
Tienan Chen 2013-11-27 09:40:07 +08:00
parent 9cdaf9462e
commit c32e58c19d
5 changed files with 21 additions and 32 deletions

View File

@ -223,7 +223,6 @@ public class TestController {
behaviorBriefModel.setBehaviorId(behaviorId);
behaviorBriefModel
.setDetailStatusCodeResultModels(detailStatusCodeResultModels);
behaviorBriefModel.setTestId(runId);
return behaviorBriefModel;
}

View File

@ -1,28 +1,16 @@
package org.bench4q.agent.api.model;
import java.util.List;
import java.util.UUID;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "BehaviorBriefModel")
public class BehaviorBriefModel {
private UUID testId;
private int behaviorId;
private int behaviorUrl;
private String behaviorUrl;
private List<BehaviorStatusCodeResultModel> detailStatusCodeResultModels;
@XmlElement
public UUID getTestId() {
return testId;
}
public void setTestId(UUID testId) {
this.testId = testId;
}
@XmlElement
public int getBehaviorId() {
return behaviorId;
@ -33,11 +21,11 @@ public class BehaviorBriefModel {
}
@XmlElement
public int getBehaviorUrl() {
public String getBehaviorUrl() {
return behaviorUrl;
}
public void setBehaviorUrl(int behaviorUrl) {
public void setBehaviorUrl(String behaviorUrl) {
this.behaviorUrl = behaviorUrl;
}

View File

@ -84,14 +84,10 @@ public class AgentResultDataCollector extends AbstractDataCollector {
return testID == null ? "default" : testID.toString();
}
public void setTestID(UUID testID) {
private void setTestID(UUID testID) {
this.testID = testID;
}
public Map<Integer, Map<Integer, DetailStatusCodeResult>> getDetailMap() {
return detailMap;
}
private void setDetailMap(
Map<Integer, Map<Integer, DetailStatusCodeResult>> detailMap) {
this.detailMap = detailMap;
@ -103,7 +99,7 @@ public class AgentResultDataCollector extends AbstractDataCollector {
init();
}
public void init() {
private void init() {
reset();
this.setCumulativeFailCount(0);
this.setCumulativeSucessfulCount(0);
@ -191,16 +187,15 @@ public class AgentResultDataCollector extends AbstractDataCollector {
}
private void dealWithDetailResult(BehaviorResult behaviorResult) {
if (!this.detailMap.containsKey(behaviorResult.getBehaviorId())) {
this.detailMap.put(new Integer(behaviorResult.getBehaviorId()),
new HashMap<Integer, DetailStatusCodeResult>());
}
insertWhenNotExist(behaviorResult);
Map<Integer, DetailStatusCodeResult> detailStatusMap = this.detailMap
.get(behaviorResult.getBehaviorId());
if (!detailStatusMap.containsKey(behaviorResult.getStatusCode())) {
detailStatusMap.put(new Integer(behaviorResult.getStatusCode()),
new DetailStatusCodeResult());
detailStatusMap
.put(new Integer(behaviorResult.getStatusCode()),
new DetailStatusCodeResult(behaviorResult
.getContentType()));
}
DetailStatusCodeResult detailResult = detailStatusMap
@ -212,7 +207,6 @@ public class AgentResultDataCollector extends AbstractDataCollector {
detailResult.contentLength = 0;
return;
}
detailResult.contentType = behaviorResult.getContentType();
detailResult.contentLength += behaviorResult.getContentLength();
if (behaviorResult.getResponseTime() > detailResult.maxResponseTime) {
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
public void add(BehaviorResult behaviorResult) {
super.add(behaviorResult);

View File

@ -9,7 +9,8 @@ public class DetailStatusCodeResult {
public long maxResponseTime;
public String contentType;
public DetailStatusCodeResult() {
public DetailStatusCodeResult(String contentType) {
this.contentType = contentType;
this.count = 0;
this.contentLength = 0;
this.minResponseTime = Long.MAX_VALUE;

View File

@ -66,7 +66,7 @@ public class DetailStatisticsTest {
}
private DetailStatusCodeResult makeExpectedResultForOne() {
DetailStatusCodeResult ret = new DetailStatusCodeResult();
DetailStatusCodeResult ret = new DetailStatusCodeResult("");
ret.contentLength = 20;
ret.count = 1;
ret.maxResponseTime = 200;
@ -95,7 +95,7 @@ public class DetailStatisticsTest {
private DetailStatusCodeResult buildCodeResult(long contentLength,
long count, long maxResponseTime, long minResponseTime) {
DetailStatusCodeResult ret = new DetailStatusCodeResult();
DetailStatusCodeResult ret = new DetailStatusCodeResult("");
ret.contentLength = contentLength;
ret.count = count;
ret.maxResponseTime = maxResponseTime;