This commit is contained in:
hmm 2014-09-04 10:40:23 +08:00
commit 0aef526482
11 changed files with 102 additions and 111 deletions

View File

@ -11,9 +11,8 @@ import javax.persistence.Table;
@Table(name = "planedConfig")
public class PlanedConfig {
private int id;
private long warmUp;
private long executeRange;
private long coolDown;
private String scheduleContent;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ -26,16 +25,7 @@ public class PlanedConfig {
this.id = id;
}
@Column(name = "warmUp", nullable = false)
public long getWarmUp() {
return warmUp;
}
public void setWarmUp(long warmUp) {
this.warmUp = warmUp;
}
@Column(name = "excuteRange", nullable = false)
@Column(name = "executeRange", nullable = false)
public long getExecuteRange() {
return executeRange;
}
@ -44,13 +34,13 @@ public class PlanedConfig {
this.executeRange = executeRange;
}
@Column(name = "coolDown", nullable = false)
public long getCoolDown() {
return coolDown;
@Column(name = "scheduleContent", columnDefinition = "LONGTEXT", nullable = false)
public String getScheduleContent() {
return scheduleContent;
}
public void setCoolDown(long coolDown) {
this.coolDown = coolDown;
public void setScheduleContent(String scheduleContent) {
this.scheduleContent = scheduleContent;
}
}

View File

@ -5,7 +5,6 @@ import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import javax.persistence.CascadeType;
@ -28,7 +27,6 @@ import org.bench4q.master.domain.RunningScriptInterface;
import org.bench4q.master.domain.factory.TestPlanFactory;
import org.bench4q.master.domain.valueobject.datastatistics.RunningScriptSampler;
import org.bench4q.master.domain.valueobject.schedulscript.ExecutionOverTask;
import org.bench4q.master.domain.valueobject.schedulscript.WarmUpOverTask;
import org.bench4q.master.domain.valueobject.transaction.Transaction;
import org.bench4q.master.domain.valueobject.transaction.TransactionFactory;
import org.bench4q.master.exception.ExceptionLog;
@ -197,25 +195,10 @@ public class TestPlanScript implements RunningScriptInterface {
return false;
}
Timer timer = new Timer();
timer.schedule(new WarmUpOverTask(), testScriptConfig.getWarmUp()
ExecutionOverTask executionOverTask = new ExecutionOverTask(this);
timer.schedule(executionOverTask, (testScriptConfig.getExecuteRange())
* SECOND_MILISECOND_UNIT_CONVERSION);
ExecutionOverTask executionOverTask = new ExecutionOverTask(this);
timer.schedule(
executionOverTask,
(testScriptConfig.getWarmUp() + testScriptConfig
.getExecuteRange()) * SECOND_MILISECOND_UNIT_CONVERSION);
timer.schedule(
new TimerTask() {
@Override
public void run() {
System.out.println("cool down over!");
}
},
(testScriptConfig.getWarmUp()
+ testScriptConfig.getExecuteRange() + testScriptConfig
.getCoolDown()) * SECOND_MILISECOND_UNIT_CONVERSION);
return true;
}

View File

@ -3,7 +3,6 @@ package org.bench4q.master.domain.factory;
import org.bench4q.master.domain.RunningAgentInterface;
import org.bench4q.master.domain.entity.Agent;
import org.bench4q.master.domain.entity.Monitor;
import org.bench4q.master.domain.entity.PlanedConfig;
import org.bench4q.master.domain.entity.Port;
import org.bench4q.master.domain.entity.Script;
import org.bench4q.master.domain.entity.TestPlan;
@ -14,7 +13,6 @@ import org.bench4q.share.models.master.PortModel;
import org.bench4q.share.models.master.RunningAgentModel;
import org.bench4q.share.models.master.ScriptModel;
import org.bench4q.share.models.master.TestPlanDBModel;
import org.bench4q.share.models.master.TestScriptConfig;
import org.bench4q.share.models.master.UserModel;
import org.springframework.stereotype.Component;
@ -46,14 +44,6 @@ public class BusinessModelMapFactory {
return ret;
}
public TestScriptConfig toModel(PlanedConfig config) {
TestScriptConfig result = new TestScriptConfig();
result.setWarmUp(config.getWarmUp());
result.setExecuteRange(config.getExecuteRange());
result.setCoolDown(config.getCoolDown());
return result;
}
public static Monitor toBusiness(MonitorModel monitorModel) {
Monitor monitor = new Monitor();
monitor.setHostName(monitorModel.getHostName());

View File

@ -37,11 +37,11 @@ import org.bench4q.share.models.agent.ScriptFilterOptionsModel;
import org.bench4q.share.models.agent.scriptrecord.BatchModel;
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
import org.bench4q.share.models.agent.scriptrecord.PageModel;
import org.bench4q.share.models.agent.scriptrecord.ScheduleModel;
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
import org.bench4q.share.models.master.MonitorModel;
import org.bench4q.share.models.master.RunningScriptModel;
import org.bench4q.share.models.master.TestPlanModel;
import org.bench4q.share.models.master.TestScriptConfig;
import org.bench4q.share.models.master.statistics.ScriptResultModel;
import org.bench4q.share.models.monitor.MonitorMain;
import org.springframework.beans.factory.annotation.Autowired;
@ -127,7 +127,7 @@ public class TestPlanFactory {
testPlanScripts.add(createATestPlanScriptWithoutId(
runningScriptModel.getRequireLoad(),
runningScriptModel.getScriptId(),
runningScriptModel.getConfig(), result,
runningScriptModel.getScheduleModel(), result,
runningScriptModel.getScriptFilterOptionsModel()));
}
result.setRequiredLoad(requiredLoad);
@ -151,7 +151,7 @@ public class TestPlanFactory {
}
public TestPlanScript createATestPlanScriptWithoutId(int requireLoad,
int scriptId, TestScriptConfig config, TestPlan testPlanDB,
int scriptId, ScheduleModel config, TestPlan testPlanDB,
ScriptFilterOptionsModel scriptFilterOptionsModel) {
TestPlanScript testPlanScript = new TestPlanScript();
testPlanScript.setRequireLoad(requireLoad);
@ -217,12 +217,10 @@ public class TestPlanFactory {
}
private PlanedConfig createAPlanedConfigWithoutId(TestScriptConfig config) {
PlanedConfig planedConfig = new PlanedConfig();
planedConfig.setWarmUp(config.getWarmUp());
planedConfig.setExecuteRange(config.getExecuteRange());
planedConfig.setCoolDown(config.getCoolDown());
return planedConfig;
private PlanedConfig createAPlanedConfigWithoutId(ScheduleModel schedule) {
PlanedConfig result = new PlanedConfig();
result.setScheduleContent(MarshalHelper.tryMarshal(schedule));
return result;
}
public TestPlanScriptResult createScriptResultWithoutId(Object model,

View File

@ -25,10 +25,11 @@ import org.bench4q.master.infrastructure.communication.AgentMessenger;
import org.bench4q.master.infrastructure.highavailable.HighAvailablePool;
import org.bench4q.master.unitTest.controller.TestBase;
import org.bench4q.share.enums.master.TestPlanStatus;
import org.bench4q.share.models.agent.scriptrecord.ScheduleModel;
import org.bench4q.share.models.agent.scriptrecord.ScheduleModel.PointModel;
import org.bench4q.share.models.master.MonitorModel;
import org.bench4q.share.models.master.RunningScriptModel;
import org.bench4q.share.models.master.TestPlanModel;
import org.bench4q.share.models.master.TestScriptConfig;
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
import org.springframework.beans.factory.annotation.Autowired;
@ -374,11 +375,11 @@ public class TestBase_MakeUpTestPlan extends TestBase {
RunningScriptModel model = new RunningScriptModel();
model.setScriptId(scriptID);
model.setRequireLoad(EACH_SCRIPT_LOAD_SMALLSCALE);
TestScriptConfig config = new TestScriptConfig();
config.setWarmUp(20);
config.setExecuteRange(60);
config.setCoolDown(10);
model.setConfig(config);
ScheduleModel config = new ScheduleModel();
config.getPoints().add(new PointModel(0, 0));
config.getPoints().add(new PointModel(20, 10));
config.getPoints().add(new PointModel(60, 10));
model.setScheduleModel(config);
return model;
}

View File

@ -67,7 +67,7 @@ public class Test_TestPlanService extends TestBase_MakeUpTestPlan {
assertEquals(1, testPlan.getMonitors().size());
for (TestPlanScript testPlanScript : testPlanScripts) {
assertEquals(getScriptId(), testPlanScript.getScript().getId());
assertEquals(20, testPlanScript.getPlanedConfig().getWarmUp());
assertEquals(20, testPlanScript.getPlanedConfig().getExecuteRange());
}
assertTrue(this.getTestPlanRepository().detach(testPlan.getId()));
}

View File

@ -25,6 +25,18 @@ public class ScheduleModel {
this.points = new LinkedList<PointModel>();
}
public long getExecuteRange() {
if (this.points.size() == 0) {
return 0;
}
long startTime = this.points.get(0).getTime(), endTime = startTime;
for (PointModel point : this.getPoints()) {
startTime = Math.min(point.getTime(), startTime);
endTime = Math.max(point.getTime(), endTime);
}
return endTime - startTime;
}
@XmlRootElement
public static class PointModel {
private long time;
@ -48,8 +60,10 @@ public class ScheduleModel {
this.load = load;
}
public PointModel(){}
public PointModel(long time, int load){
public PointModel() {
}
public PointModel(long time, int load) {
this.time = time;
this.load = load;
}

View File

@ -10,12 +10,13 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.ScriptFilterOptionsModel;
import org.bench4q.share.models.agent.scriptrecord.ScheduleModel;
@XmlRootElement(name = "runningScripModel")
public class RunningScriptModel {
private int scriptId;
private int requireLoad;
private TestScriptConfig config;
private ScheduleModel scheduleModel;
private ScriptFilterOptionsModel scriptFilterOptionsModel;
private RunScenarioModel scenarioModel;
private String scriptName;
@ -42,12 +43,12 @@ public class RunningScriptModel {
}
@XmlElement
public TestScriptConfig getConfig() {
return config;
public ScheduleModel getScheduleModel() {
return scheduleModel;
}
public void setConfig(TestScriptConfig config) {
this.config = config;
public void setScheduleModel(ScheduleModel scheduleModel) {
this.scheduleModel = scheduleModel;
}
@XmlElement
@ -100,7 +101,8 @@ public class RunningScriptModel {
return scriptFilterOptionsModel;
}
public void setScriptFilterOptionsModel(ScriptFilterOptionsModel scriptFilterOptionsModel) {
public void setScriptFilterOptionsModel(
ScriptFilterOptionsModel scriptFilterOptionsModel) {
this.scriptFilterOptionsModel = scriptFilterOptionsModel;
}
}

View File

@ -1,39 +0,0 @@
package org.bench4q.share.models.master;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class TestScriptConfig {
private long warmUp;
private long executeRange;
private long coolDown;
@XmlElement
public long getWarmUp() {
return warmUp;
}
public void setWarmUp(long warmUp) {
this.warmUp = warmUp;
}
@XmlElement
public long getExecuteRange() {
return executeRange;
}
public void setExecuteRange(long executeRange) {
this.executeRange = executeRange;
}
@XmlElement
public long getCoolDown() {
return coolDown;
}
public void setCoolDown(long coolDown) {
this.coolDown = coolDown;
}
}

View File

@ -0,0 +1,52 @@
package org.bench4q.share.models.master;
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
public class TestScriptConfigModel {
private List<PointModel> points;
@XmlElementWrapper(name = "points")
@XmlElement(name = "point")
public List<PointModel> getPoints() {
return points;
}
private void setPoints(List<PointModel> points) {
this.points = points;
}
public TestScriptConfigModel() {
this.setPoints(new LinkedList<PointModel>());
}
@XmlRootElement
public static class PointModel {
private int load;
private long relativeTime;
@XmlElement
public int getLoad() {
return load;
}
public void setLoad(int load) {
this.load = load;
}
@XmlElement
public long getRelativeTime() {
return relativeTime;
}
public void setRelativeTime(long relativeTime) {
this.relativeTime = relativeTime;
}
}
}

View File

@ -18,7 +18,7 @@ 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.TestScriptConfig;
import org.bench4q.share.models.master.TestScriptConfigModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
import org.bench4q.web.masterMessager.TestPlanMessager;
@ -73,7 +73,7 @@ public class TestPlanService {
scriptFilterOptionsModel.setFilterTypeMatches(scriptModel.getFilterTypeMatches());
scriptFilterOptionsModel.setFilterTimer(scriptModel.isFilterTimer());
TestScriptConfig testScriptConfig = new TestScriptConfig();
TestScriptConfigModel testScriptConfig = new TestScriptConfigModel();
testScriptConfig.setCoolDown(scriptModel.getCooldown());
testScriptConfig.setExecuteRange(scriptModel.getExecuteRange());
testScriptConfig.setWarmUp(scriptModel.getWarmup());