refactor and remove thtat bug of briefing behaviorsBrief

refactor and remove thtat bug of briefing behaviorsBrief
This commit is contained in:
coderfengyun 2014-09-15 15:07:39 +08:00
parent 37579cbcfb
commit 093f2d0a84
43 changed files with 624 additions and 179 deletions

View File

@ -13,7 +13,6 @@ import org.bench4q.agent.scenario.engine.ScenarioContext;
import org.bench4q.agent.scenario.engine.ScenarioEngine;
import org.bench4q.agent.scenario.engine.Schedule;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.CleanTestResultModel;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.RunScenarioResultModel;
@ -24,6 +23,7 @@ import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel;
import org.bench4q.share.models.agent.statistics.AgentPageBriefModel;
import org.bench4q.share.models.agent.statistics.AgentPagesBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
@ -93,7 +93,7 @@ public class TestController {
ScheduleModel scheduleModel = (ScheduleModel) MarshalHelper
.unmarshal(ScheduleModel.class, scheduleContent);
this.getScenarioEngine().submitScenario(runId,
Scenario.scenarioBuilderWithCompile(runScenarioModel),
Scenario.scenarioCompiler(runScenarioModel),
Schedule.build(scheduleModel), realStartTime);
return MarshalHelper.tryMarshal(buildWith(runId));
} catch (Exception e) {
@ -159,10 +159,18 @@ public class TestController {
if (!(behavior instanceof UserBehavior)) {
continue;
}
BehaviorBriefModel briefModel = behavior
.getBehaviorBriefResult(scenarioContext.getDataCollector());
briefModel.setBehaviorUrl(behavior.getSpecificParamValue("url"));
behaviorBriefModels.add(briefModel);
try {
BehaviorBriefModel briefModel = behavior
.getBehaviorBriefResult(scenarioContext
.getDataCollector());
logger.info(behavior.getId());
briefModel
.setBehaviorUrl(behavior.getSpecificParamValue("url"));
behaviorBriefModels.add(briefModel);
} catch (Exception e) {
logger.info("where behaviorId is " + behavior.getId(), e);
}
}
ret.setBehaviorBriefModels(behaviorBriefModels);
return ret;

View File

@ -3,7 +3,7 @@ package org.bench4q.agent.datacollector.impl;
import java.lang.reflect.Field;
import org.bench4q.agent.scenario.engine.BehaviorResult;
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.agent.statistics.BehaviorStatusCodeResultModel;
public class BehaviorStatusCodeCollector {
private int behaviorId;

View File

@ -8,8 +8,8 @@ import java.util.Map;
import org.bench4q.agent.datacollector.DataStatistics;
import org.bench4q.agent.scenario.engine.BehaviorResult;
import org.bench4q.agent.scenario.engine.UnderStatistics;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorStatusCodeResultModel;
public class BehaviorsResultCollector {
private final Map<Integer, BehaviorResultCollector> behaviorResultMap;

View File

@ -67,11 +67,11 @@ public class Scenario {
}
public static Scenario scenarioBuilderWithCompile(String scenarioContent) {
return scenarioBuilderWithCompile((RunScenarioModel) MarshalHelper
return scenarioCompiler((RunScenarioModel) MarshalHelper
.tryUnmarshal(RunScenarioModel.class, scenarioContent));
}
public static Scenario scenarioBuilderWithCompile(
public static Scenario scenarioCompiler(
RunScenarioModel scenarioModel) {
if (scenarioModel == null) {
throw new NullPointerException();

View File

@ -2,9 +2,9 @@ package org.bench4q.agent.scenario.behavior;
import org.bench4q.agent.datacollector.DataCollector;
import org.bench4q.agent.scenario.Parameter;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.ParameterModel;
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
public abstract class Behavior {
private static final String CONTROL_BEHAVIOR = "CONTROLBEHAVIOR";

View File

@ -1,7 +1,7 @@
package org.bench4q.agent.scenario.behavior;
import org.bench4q.agent.datacollector.DataCollector;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
public class ControlBehavior extends Behavior {

View File

@ -1,7 +1,7 @@
package org.bench4q.agent.scenario.behavior;
import org.bench4q.agent.datacollector.DataCollector;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
public class TestBehavior extends Behavior {

View File

@ -1,7 +1,7 @@
package org.bench4q.agent.scenario.behavior;
import org.bench4q.agent.datacollector.DataCollector;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
public class TimerBehavior extends Behavior {

View File

@ -1,7 +1,7 @@
package org.bench4q.agent.scenario.behavior;
import org.bench4q.agent.datacollector.DataCollector;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
public class TransactionBehavior extends Behavior {

View File

@ -1,7 +1,7 @@
package org.bench4q.agent.scenario.behavior;
import org.bench4q.agent.datacollector.DataCollector;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
public class UserBehavior extends Behavior {
@Override

View File

@ -20,7 +20,7 @@ public class ExtractScenarioTest {
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
.unmarshal(RunScenarioModel.class, FileUtils
.readFileToString(new File("Scripts/goodForPage.xml")));
Scenario scenario = Scenario.scenarioBuilderWithCompile(runScenarioModel);
Scenario scenario = Scenario.scenarioCompiler(runScenarioModel);
assertTrue(scenario.getPages().length > 0);
}

View File

@ -23,12 +23,12 @@ import org.bench4q.share.communication.HttpRequester;
import org.bench4q.share.communication.HttpRequester.HttpResponse;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.helper.TestHelper;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.RunScenarioResultModel;
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel;
import org.bench4q.share.models.agent.statistics.AgentPageBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
import org.junit.Test;
public class TestWithScriptFile extends TestBase {

View File

@ -5,8 +5,8 @@ import static org.junit.Assert.*;
import org.bench4q.agent.datacollector.impl.BehaviorsResultCollector;
import org.bench4q.agent.datacollector.impl.BehaviorsResultCollector.BehaviorResultCollector;
import org.bench4q.agent.scenario.engine.BehaviorResult;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorStatusCodeResultModel;
import org.junit.Test;
public class Test_BehaviorResultCollector {

View File

@ -6,7 +6,7 @@ import java.util.Date;
import org.bench4q.agent.datacollector.impl.BehaviorStatusCodeCollector;
import org.bench4q.agent.scenario.engine.BehaviorResult;
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.agent.statistics.BehaviorStatusCodeResultModel;
import org.junit.Test;
public class Test_BehaviorStatusResultStatistics {

View File

@ -11,8 +11,8 @@ import java.util.UUID;
import org.bench4q.agent.datacollector.impl.DataCollectorImpl;
import org.bench4q.agent.scenario.engine.BehaviorResult;
import org.bench4q.agent.storage.StorageHelper;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.ApplicationContext;

View File

@ -54,7 +54,7 @@ public class Test_ContextPlugin extends TestBase {
batchModel.getBehaviors().add(logIt);
// System.out.println(MarshalHelper.tryMarshal(scenarioModel));
VUser vuser = createVUser(
Scenario.scenarioBuilderWithCompile(scenarioModel),
Scenario.scenarioCompiler(scenarioModel),
UUID.randomUUID());
vuser.run();
}

View File

@ -87,7 +87,7 @@ public class Test_CsvProvider extends TestBase {
createFileAndWriteContent(testId, fileName, CONTENT);
RunScenarioModel runScenarioModel = buildRunScenarioModel(fileName);
Scenario scenario = Scenario
.scenarioBuilderWithCompile(runScenarioModel);
.scenarioCompiler(runScenarioModel);
VUser vUser = createVUser(scenario, testId);
try {
HashMap<String, Object> plugins = new HashMap<String, Object>();
@ -120,7 +120,7 @@ public class Test_CsvProvider extends TestBase {
UUID testId = UUID.randomUUID();
createFileAndWriteContent(testId, fileName, CONTENT);
Scenario scenario = Scenario
.scenarioBuilderWithCompile(buildRunScenarioModel(fileName));
.scenarioCompiler(buildRunScenarioModel(fileName));
VUser vUser = createVUser(scenario, testId);
HashMap<String, Object> plugins = new HashMap<String, Object>();
TestHelper

View File

@ -95,7 +95,7 @@ public class Test_HBasePlugin extends TestBase {
TestHelper.createFileIfNotExist(file);
FileUtils.writeStringToFile(file,
MarshalHelper.tryMarshal(runScenarioModel));
createVUser(Scenario.scenarioBuilderWithCompile(runScenarioModel),
createVUser(Scenario.scenarioCompiler(runScenarioModel),
UUID.randomUUID()).run();
}
}

View File

@ -154,7 +154,7 @@ public class Test_HttpPlugin extends TestBase {
.readFileToString(new File(
"Scripts/httpWithoutTimer.xml")));
VUser vUser = createVUser(
Scenario.scenarioBuilderWithCompile(scenarioMode),
Scenario.scenarioCompiler(scenarioMode),
UUID.randomUUID());
vUser.run();
}

View File

@ -97,7 +97,7 @@ public class Test_MongoDBPlugin extends TestBase {
@Test
public void test_BuildScenario() throws IOException {
RunScenarioModel result = buildUpMongoDBScenario();
VUser vUser = createVUser(Scenario.scenarioBuilderWithCompile(result),
VUser vUser = createVUser(Scenario.scenarioCompiler(result),
UUID.randomUUID());
vUser.run();
}

View File

@ -78,7 +78,7 @@ public class Test_Scenario extends TestBase {
TestHelper.createFileIfNotExist(file);
FileUtils.writeStringToFile(file,
MarshalHelper.tryMarshal(runScenarioModel));
createVUser(Scenario.scenarioBuilderWithCompile(runScenarioModel),
createVUser(Scenario.scenarioCompiler(runScenarioModel),
UUID.randomUUID()).run();
}
@ -101,7 +101,7 @@ public class Test_Scenario extends TestBase {
TestHelper.createFileIfNotExist(file);
FileUtils.writeStringToFile(file,
MarshalHelper.tryMarshal(runScenarioModel));
createVUser(Scenario.scenarioBuilderWithCompile(runScenarioModel),
createVUser(Scenario.scenarioCompiler(runScenarioModel),
UUID.randomUUID()).run();
}
@ -117,7 +117,7 @@ public class Test_Scenario extends TestBase {
"withParamPart", TEST_CASE));
}
}));
Scenario scenario = Scenario.scenarioBuilderWithCompile(inputModel);
Scenario scenario = Scenario.scenarioCompiler(inputModel);
for (Behavior behavior : scenario.getAllBehaviors()) {
assertEquals("first", behavior.getName());
assertEquals(0, behavior.getId());

View File

@ -52,7 +52,7 @@ public class Test_ScenarioContext extends TestBase {
pluginManager, this.storageHelper);
scenarioContext = scenarioContext
.addScenrio(
Scenario.scenarioBuilderWithCompile(buildRunScenarioModelWith(new LinkedList<UsePluginModel>())),
Scenario.scenarioCompiler(buildRunScenarioModelWith(new LinkedList<UsePluginModel>())),
Schedule.build(buildScheduleModel()), new Date()
.getTime());
return scenarioContext;

View File

@ -45,7 +45,7 @@ public class Test_ScenarioEngine extends TestBase {
@Test
public void test_UpdatePopulation() {
ScenarioContext scenarioContext = buildScenarioContext(testId,
Scenario.scenarioBuilderWithCompile(buildRunScenarioModelWith(
Scenario.scenarioCompiler(buildRunScenarioModelWith(
new ArrayList<UsePluginModel>(), BehaviorModel
.UserBehaviorBuilder(1, "ok", "http",
new ArrayList<ParameterModel>()))),

View File

@ -51,7 +51,7 @@ public class Test_VUser extends TestBase {
}
}, behaviorModel);
Scenario scenario = Scenario
.scenarioBuilderWithCompile(runScenarioModel);
.scenarioCompiler(runScenarioModel);
VUser vUser = createVUser(scenario, testId);
Map<String, Object> plugins = new HashMap<String, Object>();
TestHelper

View File

@ -1 +1,7 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=GBK"><script type='text/javascript'>document.domain='baidu.com';</script></head><body></body><script>try{parent.bdcallback({"CNYBA.fx":{na:"美元人民币",pc:"6.1295",op:"0.0000",la:"6.1327",hi:"6.1335",lo:"6.1304",bp1:"6.1330",ap1:"6.1327",zde:"0.0032",zdf:"0.05",type:"4",time:"2014-09-12 15:37:06"},"HKCNBA.fx":{na:"港元人民币",pc:"0.7907",op:"0.0000",la:"0.7911",hi:"0.7914",lo:"0.7907",bp1:"0.7913",ap1:"0.7912",zde:"0.0004",zdf:"0.05",type:"4",time:"2014-09-12 15:37:06"},"ERCNBA.fx":{na:"欧元人民币",pc:"7.9224",op:"0.0000",la:"7.9234",hi:"7.9308",lo:"7.9156",bp1:"7.9257",ap1:"7.9234",zde:"0.0010",zdf:"0.01",type:"4",time:"2014-09-12 15:37:08"},"UKCNBA.fx":{na:"英镑人民币",pc:"9.9629",op:"0.0000",la:"9.9693",hi:"9.9705",lo:"9.9440",bp1:"9.9735",ap1:"9.9693",zde:"0.0064",zdf:"0.06",type:"4",time:"2014-09-12 15:37:08"},"USDJPY.fx":{na:"美元日元",pc:"107.0900",op:"107.1100",la:"107.1900",hi:"107.3900",lo:"107.0400",bp1:"107.1900",ap1:"107.2300",zde:"0.1000",zdf:"0.09",type:"1",time:"2014-09-12 15:38:53"},"EURUSD.fx":{na:"欧元美元",pc:"1.2922",op:"1.2921",la:"1.2923",hi:"1.2932",lo:"1.2913",bp1:"1.2923",ap1:"1.2926",zde:"0.0001",zdf:"0.01",type:"1",time:"2014-09-12 15:38:55"},"GBPUSD.fx":{na:"英镑美元",pc:"1.6250",op:"1.6248",la:"1.6259",hi:"1.6261",lo:"1.6216",bp1:"1.6259",ap1:"1.6262",zde:"0.0009",zdf:"0.06",type:"1",time:"2014-09-12 15:38:55"},"tofnow":{time:"2014-09-12 15:44:14"}})}catch(e){}</script></html
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
</body>
</html

View File

@ -250,9 +250,9 @@ public class RunningAgentDB implements RunningAgentInterface {
}
public TestBriefStatusModel briefAll() {
if (this.isStoped()) {
return null;
}
// if (this.isStoped()) {
// return null;
// }
return this.getAgentMessenger().scriptBriefAll(this.getAgent(),
this.getAgentRunId());
}

View File

@ -1,29 +1,26 @@
package org.bench4q.master.domain.valueobject.datastatistics.impl;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.agent.statistics.DataStatisticsModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorStatusCodeModel;
public class BehaviorBriefStatistics extends ScriptStatistics {
private long countFromBegin;
private long countThisTime;
private long successCountThisTime;
private final int behaviorId;
private final String behaviorUrl;
private long successCountFromBegin;
private long maxResponseTimeFromBegin;
private long minResponseTimeFromBegin;
private long totalResponseTimeThisTime;
private long totalCountFromBegin;
private volatile Map<Integer, BehaviorStatusCodeStatistics> detailStatisticsMap;
private volatile Map<Integer, BehaviorStatusCodeResultModel> behaviorStatusMap;
public BehaviorBriefStatistics() {
this.behaviorStatusMap = new HashMap<Integer, BehaviorStatusCodeResultModel>();
public BehaviorBriefStatistics(int behaviorId, String behaviorUrl) {
this.behaviorId = behaviorId;
this.behaviorUrl = behaviorUrl;
this.detailStatisticsMap = new ConcurrentHashMap<Integer, BehaviorStatusCodeStatistics>();
resetTempraryFields();
this.maxResponseTimeFromBegin = 0;
this.minResponseTimeFromBegin = Long.MAX_VALUE;
}
/**
@ -33,11 +30,8 @@ public class BehaviorBriefStatistics extends ScriptStatistics {
* one.
*/
private void resetTempraryFields() {
this.countFromBegin = 0;
this.countThisTime = 0;
this.successCountThisTime = 0;
this.successCountFromBegin = 0;
this.totalResponseTimeThisTime = 0;
this.totalCountFromBegin = 0;
}
@Override
@ -46,25 +40,35 @@ public class BehaviorBriefStatistics extends ScriptStatistics {
return;
}
BehaviorBriefModel behaviorBriefModel = (BehaviorBriefModel) dataUnit;
this.countFromBegin += behaviorBriefModel.getTotalCount();
this.totalCountFromBegin += behaviorBriefModel.getTotalCount();
this.successCountFromBegin += behaviorBriefModel.getSuccessfulCount();
for (BehaviorStatusCodeResultModel newOne : behaviorBriefModel
.getDetailStatusCodeResultModels()) {
if (!this.behaviorStatusMap.containsKey(newOne.getStatusCode())) {
behaviorStatusMap.put(newOne.getStatusCode(), newOne);
continue;
if (!this.detailStatisticsMap.containsKey(newOne.getStatusCode())) {
detailStatisticsMap
.put(newOne.getStatusCode(),
new BehaviorStatusCodeStatistics(
this.behaviorId,
newOne.getStatusCode(), newOne
.getContentType()));
}
BehaviorStatusCodeResultModel origin = behaviorStatusMap.get(newOne
.getStatusCode());
origin.plus(newOne);
detailStatisticsMap.get(newOne.getStatusCode()).add(newOne);
}
}
@Override
public Object getStatistics() {
ScriptBehaviorBriefModel result = new ScriptBehaviorBriefModel();
return null;
result.setBehaviorId(this.behaviorId);
result.setBehaviorUrl(this.behaviorUrl);
result.setSuccessCountFromBegin(this.successCountFromBegin);
result.setTotalCountFromBegin(this.totalCountFromBegin);
for (BehaviorStatusCodeStatistics item : this.detailStatisticsMap
.values()) {
result.getList().add(
(ScriptBehaviorStatusCodeModel) item.getStatistics());
}
return result;
}
}

View File

@ -0,0 +1,82 @@
package org.bench4q.master.domain.valueobject.datastatistics.impl;
import org.bench4q.master.domain.valueobject.datastatistics.DataStatistics;
import org.bench4q.share.models.agent.statistics.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.agent.statistics.DataStatisticsModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorStatusCodeModel;
public class BehaviorStatusCodeStatistics implements DataStatistics {
private final int behaviorId;
private final int statusCode;
private final String contentType;
private long countThisTime;
private long countFromBegin;
private long contentLengthFromBegin;
private long contentLengthThisTime;
private long minResponseTime;
private long maxResponseTime;
private long totalResponseThisTime;
public BehaviorStatusCodeStatistics(int behaviorId, int statusCode,
String contentType) {
this.behaviorId = behaviorId;
this.statusCode = statusCode;
this.contentType = contentType;
resetTemperaryField();
}
@Override
public void add(DataStatisticsModel dataUnit) {
if (dataUnit == null
|| !(dataUnit instanceof BehaviorStatusCodeResultModel)) {
return;
}
BehaviorStatusCodeResultModel statusCodeResult = (BehaviorStatusCodeResultModel) dataUnit;
this.countThisTime++;
this.countFromBegin++;
this.contentLengthFromBegin += statusCodeResult.getContentLength();
this.contentLengthThisTime += statusCodeResult
.getContentLengthThisTime();
this.maxResponseTime = Math.max(this.maxResponseTime,
statusCodeResult.getMaxResponseTime());
this.minResponseTime = Math.min(this.minResponseTime,
statusCodeResult.getMinResponseTime());
this.totalResponseThisTime += statusCodeResult
.getTotalResponseTimeThisTime();
}
/**
* Now, for totalCount, i just collect all result from agent, and add their
* countFromBegin together. But there will be a error there. if an agent
* doesn't give back its result, the the countFromBegin maybe less that last
* one.
*/
private void resetTemperaryField() {
this.totalResponseThisTime = 0;
this.countFromBegin = 0;
this.countThisTime = 0;
this.maxResponseTime = Long.MIN_VALUE;
this.minResponseTime = Long.MAX_VALUE;
this.contentLengthFromBegin = 0;
this.contentLengthThisTime = 0;
}
@Override
public Object getStatistics() {
ScriptBehaviorStatusCodeModel result = new ScriptBehaviorStatusCodeModel();
result.setBehaviorId(this.behaviorId);
result.setContentLength(this.contentLengthFromBegin);
result.setContentType(this.contentType);
result.setCount(this.countFromBegin);
result.setMaxResponseTime(this.maxResponseTime);
result.setMinResponseTime(this.minResponseTime);
result.setStatusCode(this.statusCode);
result.setAverageResponseTime(this.countThisTime == 0 ? 0
: this.totalResponseThisTime / this.countThisTime);
result.setContentLength(this.contentLengthFromBegin);
result.setContentLengthThisTime(this.contentLengthThisTime);
resetTemperaryField();
return result;
}
}

View File

@ -5,26 +5,16 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
import org.bench4q.share.models.agent.statistics.DataStatisticsModel;
import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
public class BehaviorsBriefStatistics extends ScriptStatistics {
private Map<Integer, Map<Integer, BehaviorStatusCodeResultModel>> map;
private Map<Integer, String> idUrlMap;
private Map<Integer, BehaviorBriefStatistics> behaviorStatisticsMap;
private Map<Integer, Map<Integer, BehaviorStatusCodeResultModel>> getMap() {
return map;
}
private void setMap(
Map<Integer, Map<Integer, BehaviorStatusCodeResultModel>> map) {
this.map = map;
}
private Map<Integer, String> getIdUrlMap() {
return idUrlMap;
}
@ -43,49 +33,22 @@ public class BehaviorsBriefStatistics extends ScriptStatistics {
}
public BehaviorsBriefStatistics() {
this.setMap(new ConcurrentHashMap<Integer, Map<Integer, BehaviorStatusCodeResultModel>>());
this.setIdUrlMap(new ConcurrentHashMap<Integer, String>());
this.setBehaviorStatisticsMap(new ConcurrentHashMap<Integer, BehaviorBriefStatistics>());
}
public ScriptBehaviorsBriefModel getStatistics() {
ScriptBehaviorsBriefModel result = new ScriptBehaviorsBriefModel();
AgentBehaviorsBriefModel agentBehaviorsBriefModel = new AgentBehaviorsBriefModel();
List<BehaviorBriefModel> list = new ArrayList<BehaviorBriefModel>();
for (int behaviorId : this.getMap().keySet()) {
BehaviorBriefModel behaviorBriefModel = new BehaviorBriefModel();
behaviorBriefModel.setBehaviorId(behaviorId);
behaviorBriefModel.setBehaviorUrl(this.getIdUrlMap()
.get(behaviorId));
List<BehaviorStatusCodeResultModel> statusList = new ArrayList<BehaviorStatusCodeResultModel>();
for (int statusCode : this.getMap().get(behaviorId).keySet()) {
statusList.add(this.getMap().get(behaviorId).get(statusCode)
.getCopy());
}
behaviorBriefModel.setDetailStatusCodeResultModels(statusList);
this.setBehaviorCount(behaviorBriefModel);
list.add(behaviorBriefModel);
List<ScriptBehaviorBriefModel> list = new ArrayList<ScriptBehaviorBriefModel>();
for (int behaviorId : this.behaviorStatisticsMap.keySet()) {
list.add((ScriptBehaviorBriefModel) this.behaviorStatisticsMap.get(
behaviorId).getStatistics());
}
agentBehaviorsBriefModel.setBehaviorBriefModels(list);
result.setBehaviorBriefModels(agentBehaviorsBriefModel
.getBehaviorBriefModels());
result.setBehaviorBriefModels(list);
makeUpResultModelWithSamplingTime(result);
return result;
}
private void setBehaviorCount(BehaviorBriefModel behaviorBriefModel) {
long totalCount = 0, successfulCount = 0;
for (BehaviorStatusCodeResultModel behaviorStatusCodeResultModel : behaviorBriefModel
.getDetailStatusCodeResultModels()) {
totalCount += behaviorStatusCodeResultModel.getCount();
if (behaviorStatusCodeResultModel.isSuccess()) {
successfulCount += behaviorStatusCodeResultModel.getCount();
}
}
behaviorBriefModel.setTotalCount(totalCount);
behaviorBriefModel.setSuccessfulCount(successfulCount);
}
public void add(DataStatisticsModel dataUnit) {
if (!(dataUnit instanceof AgentBehaviorsBriefModel)) {
return;
@ -94,19 +57,6 @@ public class BehaviorsBriefStatistics extends ScriptStatistics {
for (BehaviorBriefModel behaviorBriefModel : input
.getBehaviorBriefModels()) {
guardAllMapsKeyExists(behaviorBriefModel);
// Map<Integer, BehaviorStatusCodeResultModel> behaviorStatusMap =
// this
// .getMap().get(behaviorBriefModel.getBehaviorId());
// for (BehaviorStatusCodeResultModel newOne : behaviorBriefModel
// .getDetailStatusCodeResultModels()) {
// if (!behaviorStatusMap.containsKey(newOne.getStatusCode())) {
// behaviorStatusMap.put(newOne.getStatusCode(), newOne);
// continue;
// }
// BehaviorStatusCodeResultModel origin = behaviorStatusMap
// .get(newOne.getStatusCode());
// origin.plus(newOne);
// }
this.getBehaviorStatisticsMap()
.get(behaviorBriefModel.getBehaviorId())
.add(behaviorBriefModel);
@ -117,18 +67,15 @@ public class BehaviorsBriefStatistics extends ScriptStatistics {
private synchronized void guardAllMapsKeyExists(
BehaviorBriefModel behaviorBriefModel) {
int behaviorId = behaviorBriefModel.getBehaviorId();
if (!this.getMap().containsKey(behaviorId)) {
this.getMap()
.put(behaviorId,
new ConcurrentHashMap<Integer, BehaviorStatusCodeResultModel>());
}
if (!this.getIdUrlMap().containsKey(behaviorId)) {
this.getIdUrlMap().put(behaviorId,
behaviorBriefModel.getBehaviorUrl());
}
if (!this.getBehaviorStatisticsMap().containsKey(behaviorId)) {
this.getBehaviorStatisticsMap().put(behaviorId,
new BehaviorBriefStatistics());
this.getBehaviorStatisticsMap().put(
behaviorId,
new BehaviorBriefStatistics(behaviorId, behaviorBriefModel
.getBehaviorUrl()));
}
}
}

View File

@ -128,10 +128,10 @@ public class ScriptBriefStatistics extends ScriptStatistics {
if (!(dataUnit instanceof AgentBriefStatusModel)) {
return;
}
add((AgentBriefStatusModel) dataUnit);
addCore((AgentBriefStatusModel) dataUnit);
}
private void add(AgentBriefStatusModel briefModel) {
private void addCore(AgentBriefStatusModel briefModel) {
if (briefModel == null) {
return;
}

View File

@ -17,7 +17,9 @@ import org.bench4q.master.unitTest.TestBase_MakeUpTestPlan;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.RunScenarioResultModel;
import org.bench4q.share.models.agent.TestBriefStatusModel;
import org.bench4q.share.models.agent.scriptrecord.ScheduleModel;
import org.bench4q.share.models.agent.scriptrecord.ScheduleModel.PointModel;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@ -45,7 +47,7 @@ public class Test_AgentMessenger extends TestBase_MakeUpTestPlan {
// TODO: modify this to adapt to new code
@Test
public void testSubmitScenarioWithParamsAndRun() throws IOException,
JAXBException {
JAXBException, InterruptedException {
List<File> paramFiles = new ArrayList<File>();
int scriptId = getUserFirstScript(this.getUserRepository().getUser(
@ -60,7 +62,7 @@ public class Test_AgentMessenger extends TestBase_MakeUpTestPlan {
paramFiles.add(file1);
paramFiles.add(file2);
File scenarioFile = new File("Scripts" + FILE_SEPARATOR
+ "forGoodRecord.xml");
+ "homepage.xml");
assertTrue(scenarioFile.exists());
RunScenarioModel inputModel = (RunScenarioModel) MarshalHelper
.unmarshal(RunScenarioModel.class,
@ -74,14 +76,22 @@ public class Test_AgentMessenger extends TestBase_MakeUpTestPlan {
assertNotNull(model);
assertNotNull(model.getRunId());
System.out.println(model.getRunId());
ScheduleModel scheduleModel = new ScheduleModel();
scheduleModel.getPoints().add(new PointModel(0, 0));
scheduleModel.getPoints().add(new PointModel(20, 20));
scheduleModel.getPoints().add(new PointModel(40, 20));
RunScenarioResultModel modelAfter = this.getAgentMessenger()
.submitScenrioWithParams(agent, model.getRunId(), paramFiles,
inputModel, new ScheduleModel(), new Date());
inputModel, scheduleModel, new Date());
assertEquals(model.getRunId(), modelAfter.getRunId());
model = this.getAgentMessenger().runWithParams(agent, model.getRunId());
assertNotNull(model);
assertNotNull(model.getRunId());
System.out.println(model.getRunId());
// Thread.sleep(2000);
TestBriefStatusModel briefModel = this.getAgentMessenger()
.scriptBriefAll(agent, model.getRunId());
assertNotNull(briefModel);
}
private File createParameterFile(int scriptId, String paramName)

View File

@ -0,0 +1,58 @@
package org.bench4q.master.unitTest.datastatistics;
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.bench4q.master.domain.valueobject.datastatistics.impl.BehaviorBriefStatistics;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorStatusCodeModel;
import org.junit.Test;
public class Test_BehaviorBriefStatistics {
@Test
public void test() {
String url = "www.baidu.com";
int behaviorId = 1;
BehaviorBriefStatistics behaviorStatistics = new BehaviorBriefStatistics(
behaviorId, url);
behaviorStatistics.add(buildBehaviorBriefModel(behaviorId, url, 2, 3));
behaviorStatistics.add(buildBehaviorBriefModel(behaviorId, url, 3, 5));
ScriptBehaviorBriefModel result = (ScriptBehaviorBriefModel) behaviorStatistics
.getStatistics();
System.out.println(MarshalHelper.tryMarshal(result));
assertEquals(5, result.getSuccessCountFromBegin());
assertEquals(8, result.getTotalCountFromBegin());
int countForAllDetail = 0;
for (ScriptBehaviorStatusCodeModel behaviorStatusCodeModel : result
.getList()) {
countForAllDetail += behaviorStatusCodeModel.getCount();
}
assertEquals(result.getTotalCountFromBegin(), countForAllDetail);
}
private BehaviorBriefModel buildBehaviorBriefModel(int behaviorId,
String url, int successCount, int totalCount) {
BehaviorBriefModel e = new BehaviorBriefModel();
e.setBehaviorId(behaviorId);
e.setBehaviorUrl(url);
e.setDetailStatusCodeResultModels(new ArrayList<BehaviorStatusCodeResultModel>());
for (int i = 0; i < successCount; i++) {
e.getDetailStatusCodeResultModels().add(
new BehaviorStatusCodeResultModel(1, 200, 1, i + 1,
"text/html", 320, 10, 190, 260, 450));
}
for (int i = 0; i < totalCount - successCount; i++) {
e.getDetailStatusCodeResultModels().add(
new BehaviorStatusCodeResultModel(1, 400, 1, successCount
+ i + 1, "text/html", 320, 10, 190, 260, 450));
}
e.setSuccessfulCount(successCount);
e.setTotalCount(totalCount);
return e;
}
}

View File

@ -0,0 +1,11 @@
package org.bench4q.master.unitTest.datastatistics;
import org.junit.Test;
public class Test_BehaviorStatusStatistics {
@Test
public void test() {
}
}

View File

@ -0,0 +1,50 @@
package org.bench4q.master.unitTest.datastatistics;
import java.util.ArrayList;
import org.bench4q.master.domain.valueobject.datastatistics.impl.BehaviorsBriefStatistics;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
import org.junit.Test;
public class Test_BehaviorsBriefStatistics {
@Test
public void testAddNull() {
BehaviorsBriefStatistics behaviorsBriefStatistics = new BehaviorsBriefStatistics();
AgentBehaviorsBriefModel dataUnit = new AgentBehaviorsBriefModel();
String url = "www.baidu.com";
dataUnit.getBehaviorBriefModels().add(
buildBehaviorBriefModel(1, url, 2, 3));
dataUnit.getBehaviorBriefModels().add(
buildBehaviorBriefModel(1, url, 3, 5));
behaviorsBriefStatistics.add(dataUnit);
ScriptBehaviorsBriefModel result = behaviorsBriefStatistics
.getStatistics();
System.out.println(MarshalHelper.tryMarshal(result));
}
private BehaviorBriefModel buildBehaviorBriefModel(int behaviorId,
String url, int successCount, int totalCount) {
BehaviorBriefModel e = new BehaviorBriefModel();
e.setBehaviorId(behaviorId);
e.setBehaviorUrl(url);
e.setDetailStatusCodeResultModels(new ArrayList<BehaviorStatusCodeResultModel>());
for (int i = 0; i < successCount; i++) {
e.getDetailStatusCodeResultModels().add(
new BehaviorStatusCodeResultModel(1, 200, 2, 10,
"text/html", 320, 10, 190, 260, 450));
}
for (int i = 0; i < totalCount - successCount; i++) {
e.getDetailStatusCodeResultModels().add(
new BehaviorStatusCodeResultModel(1, 400, 2, 10,
"text/html", 320, 10, 190, 260, 450));
}
e.setSuccessfulCount(successCount);
e.setTotalCount(totalCount);
return e;
}
}

View File

@ -10,7 +10,6 @@ import java.util.concurrent.Future;
import org.bench4q.master.domain.entity.Agent;
import org.bench4q.master.infrastructure.communication.AgentMessenger;
import org.bench4q.share.enums.master.AgentStatus;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.RunScenarioResultModel;
import org.bench4q.share.models.agent.ServerStatusModel;
@ -20,6 +19,7 @@ import org.bench4q.share.models.agent.scriptrecord.ScheduleModel;
import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel;
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
import org.bench4q.share.models.agent.statistics.AgentPagesBriefModel;
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

View File

@ -7,8 +7,6 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import org.bench4q.share.models.agent.BehaviorBriefModel;
@XmlRootElement(name = "testBehaviorBriefModel")
public class AgentBehaviorsBriefModel extends DataStatisticsModel {
private List<BehaviorBriefModel> behaviorBriefModels;

View File

@ -0,0 +1,68 @@
package org.bench4q.share.models.agent.statistics;
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;
@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

@ -0,0 +1,164 @@
package org.bench4q.share.models.agent.statistics;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "BehaviorStatusCodeResultModel")
public class BehaviorStatusCodeResultModel extends DataStatisticsModel {
private int behaviorId;
private int statusCode;
private long countThisTime;
private long count;
private String contentType;
private long contentLengthThisTime;
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 getContentLengthThisTime() {
return contentLengthThisTime;
}
public void setContentLengthThisTime(long contentLengthThisTime) {
this.contentLengthThisTime = contentLengthThisTime;
}
@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() {
}
public BehaviorStatusCodeResultModel(int behaviorId, int statusCode,
long countThisTime, long count, String contentType,
long contentLength, long contentLengthThisTime,
long minResponseTime, long maxResponseTime,
long totalResponseTimeThisTime) {
this.behaviorId = behaviorId;
this.statusCode = statusCode;
this.countThisTime = countThisTime;
this.count = count;
this.contentType = contentType;
this.contentLength = contentLength;
this.contentLengthThisTime = contentLengthThisTime;
this.minResponseTime = minResponseTime;
this.maxResponseTime = maxResponseTime;
this.totalResponseTimeThisTime = totalResponseTimeThisTime;
}
}

View File

@ -7,18 +7,16 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
@XmlRootElement
public class ScriptBehaviorBriefModel {
private int behaviorId;
private String BehaviorUrl;
private int successCount;
private int totalCount;
private List<BehaviorStatusCodeResultModel> list;
private long successCountFromBegin;
private long totalCountFromBegin;
private List<ScriptBehaviorStatusCodeModel> list;
public ScriptBehaviorBriefModel() {
this.setList(new LinkedList<BehaviorStatusCodeResultModel>());
this.setList(new LinkedList<ScriptBehaviorStatusCodeModel>());
}
@XmlElement
@ -40,30 +38,30 @@ public class ScriptBehaviorBriefModel {
}
@XmlElement
public int getSuccessCount() {
return successCount;
public long getSuccessCountFromBegin() {
return successCountFromBegin;
}
public void setSuccessCount(int successCount) {
this.successCount = successCount;
public void setSuccessCountFromBegin(long successCountFromBegin) {
this.successCountFromBegin = successCountFromBegin;
}
@XmlElement
public int getTotalCount() {
return totalCount;
public long getTotalCountFromBegin() {
return totalCountFromBegin;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
public void setTotalCountFromBegin(long totalCountFromBegin) {
this.totalCountFromBegin = totalCountFromBegin;
}
@XmlElementWrapper(name = "statusResults")
@XmlElement
public List<BehaviorStatusCodeResultModel> getList() {
public List<ScriptBehaviorStatusCodeModel> getList() {
return list;
}
public void setList(List<BehaviorStatusCodeResultModel> list) {
public void setList(List<ScriptBehaviorStatusCodeModel> list) {
this.list = list;
}

View File

@ -1,13 +1,30 @@
package org.bench4q.share.models.master.statistics;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class ScriptBehaviorStatusCodeModel {
private int behaviorId;
private int statusCode;
private long count;
private String contentType;
private long contentLength;
private long contentLengthThisTime;
private long minResponseTime;
private long maxResponseTime;
private long averageResponseTime;
@XmlElement
public int getBehaviorId() {
return behaviorId;
}
public void setBehaviorId(int behaviorId) {
this.behaviorId = behaviorId;
}
@XmlElement
public int getStatusCode() {
return statusCode;
}
@ -16,6 +33,7 @@ public class ScriptBehaviorStatusCodeModel {
this.statusCode = statusCode;
}
@XmlElement
public long getCount() {
return count;
}
@ -24,6 +42,7 @@ public class ScriptBehaviorStatusCodeModel {
this.count = count;
}
@XmlElement
public String getContentType() {
return contentType;
}
@ -32,6 +51,7 @@ public class ScriptBehaviorStatusCodeModel {
this.contentType = contentType;
}
@XmlElement
public long getContentLength() {
return contentLength;
}
@ -40,6 +60,16 @@ public class ScriptBehaviorStatusCodeModel {
this.contentLength = contentLength;
}
@XmlElement
public long getContentLengthThisTime() {
return contentLengthThisTime;
}
public void setContentLengthThisTime(long contentLengthThisTime) {
this.contentLengthThisTime = contentLengthThisTime;
}
@XmlElement
public long getMinResponseTime() {
return minResponseTime;
}
@ -48,6 +78,7 @@ public class ScriptBehaviorStatusCodeModel {
this.minResponseTime = minResponseTime;
}
@XmlElement
public long getMaxResponseTime() {
return maxResponseTime;
}
@ -56,4 +87,13 @@ public class ScriptBehaviorStatusCodeModel {
this.maxResponseTime = maxResponseTime;
}
@XmlElement
public long getAverageResponseTime() {
return averageResponseTime;
}
public void setAverageResponseTime(long averageResponseTime) {
this.averageResponseTime = averageResponseTime;
}
}

View File

@ -5,19 +5,19 @@ 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.BehaviorBriefModel;
@XmlRootElement(name = "scriptBehaviorsBriefModel")
public class ScriptBehaviorsBriefModel extends SampleModel {
private List<BehaviorBriefModel> behaviorBriefModels;
private List<ScriptBehaviorBriefModel> behaviorBriefModels;
@XmlElementWrapper(name = "behaviorBriefList")
@XmlElement(name = "behaviorBrief")
public List<BehaviorBriefModel> getBehaviorBriefModels() {
public List<ScriptBehaviorBriefModel> getBehaviorBriefModels() {
return behaviorBriefModels;
}
public void setBehaviorBriefModels(
List<BehaviorBriefModel> behaviorBriefModels) {
List<ScriptBehaviorBriefModel> behaviorBriefModels) {
this.behaviorBriefModels = behaviorBriefModels;
}

View File

@ -15,7 +15,6 @@ import javax.xml.bind.JAXBException;
import org.apache.log4j.Logger;
import org.bench4q.share.helper.ExceptionLog;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.master.MonitorModel;
import org.bench4q.share.models.master.ScriptHandleModel;
import org.bench4q.share.models.master.TestPlanDBModel;
@ -23,6 +22,7 @@ import org.bench4q.share.models.master.TestPlanModel;
import org.bench4q.share.models.master.TestPlanResponseModel;
import org.bench4q.share.models.master.TestPlanResultModel;
import org.bench4q.share.models.master.TestPlanScriptBriefResultModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorStatusCodeModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
import org.bench4q.share.models.master.statistics.ScriptPagesBriefModel;
@ -129,7 +129,7 @@ public class TestPlanController extends BaseController {
Map<String, Object> map = new HashMap<String, Object>();
TestPlanResultModel testPlanResultModel = this.getTestPlanMessager()
.getRunningTestInfo(accessToken, testPlanId);
if (testPlanResultModel == null) {
return fail(map, "");
} else {
@ -369,7 +369,7 @@ public class TestPlanController extends BaseController {
@PathVariable String testPlanId) {
Map<String, Object> map = new HashMap<String, Object>();
List<BehaviorStatusCodeResultModel> behaviorStatusCodeResultModels = this
List<ScriptBehaviorStatusCodeModel> behaviorStatusCodeResultModels = this
.getTestPlanService().getAllBehaviorStatusCodeResultModels(
accessToken, testPlanId);
if (behaviorStatusCodeResultModels == null) {
@ -377,7 +377,7 @@ public class TestPlanController extends BaseController {
return fail(map, "");
}
Map<String, Long> urlContentCountMap = new HashMap<String, Long>();
for (BehaviorStatusCodeResultModel behaviorStatusCodeResultModel : behaviorStatusCodeResultModels) {
for (ScriptBehaviorStatusCodeModel behaviorStatusCodeResultModel : behaviorStatusCodeResultModels) {
if (urlContentCountMap.get(behaviorStatusCodeResultModel
.getContentType()) == null)
urlContentCountMap.put(
@ -419,17 +419,18 @@ public class TestPlanController extends BaseController {
return fail(map, testPlanResponseModel.getFailCause());
}
}
@RequestMapping("loadFilterTypeList")
public @ResponseBody
Map<String, Object> loadFilterTypeList(HttpServletRequest request,
public @ResponseBody Map<String, Object> loadFilterTypeList(
HttpServletRequest request,
@ModelAttribute("accessToken") String accessToken) {
TestPlanResponseModel responseModel = this.getTestPlanMessager().loadFilterTypeList(accessToken);
Map<String,Object> map = new HashMap<String, Object>();
if(responseModel.isSuccess()){
TestPlanResponseModel responseModel = this.getTestPlanMessager()
.loadFilterTypeList(accessToken);
Map<String, Object> map = new HashMap<String, Object>();
if (responseModel.isSuccess()) {
map.put("filterTypeList", responseModel.getFilterTypeList());
success(map);
}else{
} else {
fail(map, responseModel.getFailCause());
}
return map;

View File

@ -9,8 +9,6 @@ import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.agent.ScriptFilterOptionsModel;
import org.bench4q.share.models.master.MonitorModel;
import org.bench4q.share.models.master.RunningScriptModel;
@ -18,6 +16,8 @@ import org.bench4q.share.models.master.ScriptHandleModel;
import org.bench4q.share.models.master.TestPlanModel;
import org.bench4q.share.models.master.TestPlanResultModel;
import org.bench4q.share.models.master.TestPlanScriptBriefResultModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorStatusCodeModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
import org.bench4q.web.masterMessager.TestPlanMessager;
@ -121,7 +121,7 @@ public class TestPlanService {
}
public List<BehaviorStatusCodeResultModel> getAllBehaviorStatusCodeResultModels(
public List<ScriptBehaviorStatusCodeModel> getAllBehaviorStatusCodeResultModels(
String accessToken, String testPlanId) {
TestPlanResultModel testPlanResultModel = this.getTestPlanMessager()
.getRunningTestInfo(accessToken, testPlanId);
@ -134,7 +134,7 @@ public class TestPlanService {
if (scriptList == null) {
return null;
}
List<BehaviorStatusCodeResultModel> behaviorStatusCodeResultModels = new LinkedList<BehaviorStatusCodeResultModel>();
List<ScriptBehaviorStatusCodeModel> behaviorStatusCodeResultModels = new LinkedList<ScriptBehaviorStatusCodeModel>();
for (ScriptHandleModel scriptHandleModel : scriptList) {
ScriptBehaviorsBriefModel scriptBehaviorBriefModel = this
.getTestPlanMessager().getScriptBehaviorsBriefResult(
@ -147,19 +147,19 @@ public class TestPlanService {
}
private List<BehaviorStatusCodeResultModel> extractBehaviorStatusCodeResultModels(
private List<ScriptBehaviorStatusCodeModel> extractBehaviorStatusCodeResultModels(
ScriptBehaviorsBriefModel scriptBehaviorsBriefModel) {
List<BehaviorStatusCodeResultModel> behaviorStatusCodeResultModels = new ArrayList<BehaviorStatusCodeResultModel>();
List<ScriptBehaviorStatusCodeModel> behaviorStatusCodeResultModels = new ArrayList<ScriptBehaviorStatusCodeModel>();
if (scriptBehaviorsBriefModel == null
|| scriptBehaviorsBriefModel.getBehaviorBriefModels() == null) {
return behaviorStatusCodeResultModels;
}
for (BehaviorBriefModel behaviorBriefModel : scriptBehaviorsBriefModel
for (ScriptBehaviorBriefModel behaviorBriefModel : scriptBehaviorsBriefModel
.getBehaviorBriefModels()) {
if (behaviorBriefModel.getDetailStatusCodeResultModels() != null)
if (behaviorBriefModel.getList() != null)
behaviorStatusCodeResultModels.addAll(behaviorBriefModel
.getDetailStatusCodeResultModels());
.getList());
}
return behaviorStatusCodeResultModels;
}