refactor
This commit is contained in:
coderfengyun 2014-09-15 15:08:56 +08:00
parent 093f2d0a84
commit 030794d5ca
3 changed files with 0 additions and 238 deletions

View File

@ -1,30 +0,0 @@
package org.bench4q.master.unitTest.datastatistics;
import java.util.Arrays;
import org.bench4q.master.domain.valueobject.datastatistics.impl.BehaviorsBriefStatistics;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel;
import org.junit.Test;
public class BehaviorsBriefStatisticsTest {
@Test
public void testAddNull() {
BehaviorsBriefStatistics behaviorsBriefStatistics = new BehaviorsBriefStatistics();
AgentBehaviorsBriefModel dataUnit = new AgentBehaviorsBriefModel();
BehaviorBriefModel e = new BehaviorBriefModel();
e.setBehaviorId(1);
e.setBehaviorUrl("www.baidu.com");
e.setDetailStatusCodeResultModels(Arrays
.asList(new BehaviorStatusCodeResultModel()));
e.setSuccessfulCount(2);
e.setTotalCount(3);
dataUnit.getBehaviorBriefModels().add(e);
behaviorsBriefStatistics.add(dataUnit);
System.out.println(MarshalHelper.tryMarshal(behaviorsBriefStatistics
.getStatistics()));
}
}

View File

@ -1,70 +0,0 @@
package org.bench4q.share.models.agent;
import java.util.LinkedList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import org.bench4q.share.models.agent.statistics.DataStatisticsModel;
@XmlRootElement(name = "BehaviorBriefModel")
public class BehaviorBriefModel extends DataStatisticsModel {
private int behaviorId;
private String behaviorUrl;
private long totalCount;
private long successfulCount;
private List<BehaviorStatusCodeResultModel> detailStatusCodeResultModels;
@XmlElement
public int getBehaviorId() {
return behaviorId;
}
public void setBehaviorId(int behaviorId) {
this.behaviorId = behaviorId;
}
@XmlElement
public String getBehaviorUrl() {
return behaviorUrl;
}
public void setBehaviorUrl(String behaviorUrl) {
this.behaviorUrl = behaviorUrl;
}
@XmlElementWrapper(name = "detailStatusCodeResultList")
@XmlElement(name = "detailStatusCodeResult")
public List<BehaviorStatusCodeResultModel> getDetailStatusCodeResultModels() {
return detailStatusCodeResultModels;
}
public void setDetailStatusCodeResultModels(
List<BehaviorStatusCodeResultModel> detailStatusCodeResultModels) {
this.detailStatusCodeResultModels = detailStatusCodeResultModels;
}
@XmlElement
public long getTotalCount() {
return totalCount;
}
public void setTotalCount(long totalCount) {
this.totalCount = totalCount;
}
@XmlElement
public long getSuccessfulCount() {
return successfulCount;
}
public void setSuccessfulCount(long successfulCount) {
this.successfulCount = successfulCount;
}
public BehaviorBriefModel() {
this.setDetailStatusCodeResultModels(new LinkedList<BehaviorStatusCodeResultModel>());
}
}

View File

@ -1,138 +0,0 @@
package org.bench4q.share.models.agent;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "BehaviorStatusCodeResultModel")
public class BehaviorStatusCodeResultModel {
private int behaviorId;
private int statusCode;
private long countThisTime;
private long count;
private String contentType;
private long contentLength;
private long minResponseTime;
private long maxResponseTime;
private long totalResponseTimeThisTime;
@XmlElement
public int getBehaviorId() {
return behaviorId;
}
public void setBehaviorId(int behaviorId) {
this.behaviorId = behaviorId;
}
@XmlElement
public int getStatusCode() {
return statusCode;
}
public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}
@XmlElement
public long getCount() {
return count;
}
public void setCount(long count) {
this.count = count;
}
@XmlElement
public long getCountThisTime() {
return countThisTime;
}
public void setCountThisTime(long countThisTime) {
this.countThisTime = countThisTime;
}
@XmlElement
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
@XmlElement
public long getContentLength() {
return contentLength;
}
public void setContentLength(long contentLength) {
this.contentLength = contentLength;
}
@XmlElement
public long getMinResponseTime() {
return minResponseTime;
}
public void setMinResponseTime(long minResponseTime) {
this.minResponseTime = minResponseTime;
}
@XmlElement
public long getMaxResponseTime() {
return maxResponseTime;
}
public void setMaxResponseTime(long maxResponseTime) {
this.maxResponseTime = maxResponseTime;
}
@XmlElement
public long getTotalResponseTimeThisTime() {
return totalResponseTimeThisTime;
}
public void setTotalResponseTimeThisTime(long totalResponseTimeThisTime) {
this.totalResponseTimeThisTime = totalResponseTimeThisTime;
}
/**
* It's just the http's success judgement, if we'll turn to other protocal,
* we should build a inheritance system
*
* @return
*/
public boolean isSuccess() {
return this.getStatusCode() == 200;
}
public BehaviorStatusCodeResultModel getCopy() {
BehaviorStatusCodeResultModel ret = new BehaviorStatusCodeResultModel();
ret.setStatusCode(getStatusCode());
ret.setContentLength(getContentLength());
ret.setContentType(getContentType());
ret.setCount(getCount());
ret.setMaxResponseTime(getMaxResponseTime());
ret.setMinResponseTime(getMinResponseTime());
ret.setTotalResponseTimeThisTime(getTotalResponseTimeThisTime());
return ret;
}
public synchronized void plus(BehaviorStatusCodeResultModel newOne) {
this.setContentLength(this.getContentLength()
+ newOne.getContentLength());
this.setCount(this.getCount() + newOne.getCount());
this.setTotalResponseTimeThisTime(this.getTotalResponseTimeThisTime()
+ newOne.getTotalResponseTimeThisTime());
if (newOne.getMaxResponseTime() > this.getMaxResponseTime()) {
this.setMaxResponseTime(newOne.getMaxResponseTime());
}
if (newOne.getMinResponseTime() < this.getMinResponseTime()) {
this.setMinResponseTime(newOne.getMinResponseTime());
}
}
public BehaviorStatusCodeResultModel() {
}
}