add function filter type of behavior and timer

This commit is contained in:
hmm 2014-09-02 10:57:50 +08:00
parent f3816e8304
commit 3c46fdda89
20 changed files with 230 additions and 116 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- <!DOCTYPE ui SYSTEM "../../dtd/ui.dtd"> -->
<!DOCTYPE ui SYSTEM "../../dtd/ui.dtd">
<ui>
<plugin name="Http">
<params>

View File

@ -102,14 +102,14 @@ public class ScriptController extends BaseController {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildReponseModel(false,
"has no power for recording script!!!", "", -1, null, null,
null,null);
null);
}
Port port = new Port();
synchronized (PORT_LOCK) {
port = this.getPortPoolService().getAPortNotInUse();
if (port == null) {
return buildReponseModel(false, "port is in use!", "", -1,
null, null, null,null);
null, null, null);
}
}
UUID uuid = UUID.randomUUID();
@ -118,7 +118,7 @@ public class ScriptController extends BaseController {
return buildReponseModel(true, "", this.getScriptCapturer()
.getIpHttpCaptureServerAdress(), port.getPort(), null, null,
uuid.toString(),null);
uuid.toString());
}
@RequestMapping(value = "/startScriptRecording", method = {
@ -129,13 +129,13 @@ public class ScriptController extends BaseController {
if (!checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildReponseModel(false,
"has no power for stopScriptCapture!!!", "", -1, null,
null, null,null);
null, null);
}
this.getScriptCapturer().startRecording(port);
return buildReponseModel(true, "RecordServer stop", "", port, null,
null, fileNameUUID,null);
null, fileNameUUID);
}
private String buildScriptSavePath() {
@ -158,7 +158,7 @@ public class ScriptController extends BaseController {
if (!checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildReponseModel(false,
"has no power for stopScriptCapture!!!", "", -1, null,
null, null,null);
null, null);
}
this.getScriptCapturer().stopCurrentRecord(port);
@ -167,7 +167,7 @@ public class ScriptController extends BaseController {
}
return buildReponseModel(true, "RecordServer stop", "", port, null,
null, fileNameUUID,null);
null, fileNameUUID);
}
@RequestMapping(value = "/saveScriptToDB", method = { RequestMethod.GET,
@ -179,14 +179,14 @@ public class ScriptController extends BaseController {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildReponseModel(false,
"saveScriptToDB check your scope fail!", "", -1, null,
null, null,null);
null, null);
}
File file = new File(buildScriptSavePath()
+ System.getProperty("file.separator") + fileNameUUID + ".xml");
if (!file.exists()) {
return buildReponseModel(false, "no that script", null, -1, null,
null, fileNameUUID,null);
null, fileNameUUID);
}
try {
String content = FileUtils.readFileToString(file);
@ -195,10 +195,10 @@ public class ScriptController extends BaseController {
this.getPrincipal().getId(), content, null);
// this.getUserService().add
return buildReponseModel(success, "Save to DataBase!!", "", port,
null, null, null,null);
null, null, null);
} catch (Exception e) {
return buildReponseModel(false, "exception when read from file",
null, -1, null, null, fileNameUUID,null);
null, -1, null, null, fileNameUUID);
}
}
@ -218,12 +218,12 @@ public class ScriptController extends BaseController {
boolean success = this.getScriptService().saveScript(scriptName,
this.getPrincipal().getId(), scenarioModel, paramFiles);
logger.info("upload script:" + scenarioModel);
return buildReponseModel(success, null, null, -1, null, null, null,null);
return buildReponseModel(success, null, null, -1, null, null, null);
} catch (Exception e) {
this.logger.error(ExceptionLog.getStackTrace(e));
return buildReponseModel(false,
"The script is not in the right format", null, -1, null,
null, null,null);
null, null);
}
}
@ -238,23 +238,9 @@ public class ScriptController extends BaseController {
this.getPrincipal());
return this.buildReponseModel(true, null, null, 0,
dealWithCollection(scripts), null, null,null);
dealWithCollection(scripts), null, null);
}
@RequestMapping(value = "/loadFilterTypeList", method = { RequestMethod.POST,
RequestMethod.GET })
@ResponseBody
public OperateScriptServerResponseModel loadFilterTypeList() {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return null;
}
String[] filterTypeList = this.getScriptService().loadFilterTypeList();
return this.buildReponseModel(true, null, null, 0,
null, null, null,filterTypeList);
}
@RequestMapping(value = "/queryScriptsByDate", method = RequestMethod.POST)
@ResponseBody
public OperateScriptServerResponseModel queryScriptsByDate(
@ -266,7 +252,7 @@ public class ScriptController extends BaseController {
.queryScriptsByCreateTime(startDate, endDate,
this.getPrincipal());
return this.buildReponseModel(true, null, null, 0,
dealWithCollection(scripts), null, null,null);
dealWithCollection(scripts), null, null);
}
private List<ScriptModel> dealWithCollection(Collection<Script> scripts) {
@ -287,7 +273,7 @@ public class ScriptController extends BaseController {
}
return this.buildReponseModel(true, null, null, 0, null,
BusinessModelMapFactory.toModel(this.getScriptService()
.getScript(scriptId)), null,null);
.getScript(scriptId)), null);
}
@RequestMapping(value = "/queryScriptByName", method = { RequestMethod.GET,
@ -301,7 +287,7 @@ public class ScriptController extends BaseController {
}
return this.buildReponseModel(true, null, null, 0, null,
BusinessModelMapFactory.toModel(this.getScriptService()
.getScriptByName(name)), null,null);
.getScriptByName(name)), null);
}
@RequestMapping(value = "/deleteScript", method = { RequestMethod.GET,
@ -315,7 +301,7 @@ public class ScriptController extends BaseController {
return this.buildReponseModel(
this.getScriptService().deleteScript(scriptId,
this.getPrincipal().getId()), "", "", 0, null, null,
null,null);
null);
}
@RequestMapping(value = "updateScript/{scriptId}", method = {
@ -330,7 +316,7 @@ public class ScriptController extends BaseController {
return this.buildReponseModel(
this.getScriptService().alterScriptContent(scriptId,
this.getPrincipal().getId(),content,scriptName), "", "", 0, null,
null, null,null);
null, null);
}
// @RequestMapping(value = "updateScript/{scriptId}", method = {
@ -361,7 +347,7 @@ public class ScriptController extends BaseController {
private OperateScriptServerResponseModel buildReponseModel(
boolean isSuccess, String failCauseString, String hostName,
int port, List<ScriptModel> scriptModels, ScriptModel scriptModel,
String fileName,String[] filterTypeList) {
String fileName) {
OperateScriptServerResponseModel responseModel = new OperateScriptServerResponseModel();
responseModel.setSuccess(isSuccess);
responseModel.setFailCauseString(failCauseString);
@ -373,7 +359,6 @@ public class ScriptController extends BaseController {
scriptModels.add(scriptModel);
}
responseModel.setScriptModels(scriptModels);
responseModel.setFilterTypeList(filterTypeList);
return responseModel;
}

View File

@ -21,6 +21,7 @@ import org.bench4q.master.exception.Bench4QException;
import org.bench4q.master.exception.Bench4QRunTimeException;
import org.bench4q.share.enums.master.TestPlanStatus;
import org.bench4q.share.models.master.MonitorModel;
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
import org.bench4q.share.models.master.ScriptHandleModel;
import org.bench4q.share.models.master.TestPlanScriptBriefResultModel;
import org.bench4q.share.models.master.TestPlanModel;
@ -206,13 +207,13 @@ public class TestPlanController extends BaseController {
@ResponseBody
public TestPlanResponseModel loadTestPlans() {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildTestPlanResponseModel(false, "no scope", null);
return buildTestPlanResponseModel(false, "no scope", null,null);
}
List<TestPlan> testPlanDBs = this.testPlanService.loadTestPlans(this
.getPrincipal());
return testPlanDBs == null ? buildTestPlanResponseModel(false,
"exception", null) : buildTestPlanResponseModel(true, null,
testPlanDBs);
"exception", null,null) : buildTestPlanResponseModel(true, null,
testPlanDBs,null);
}
@RequestMapping(value = "/queryTestPlan/{runId}", method = RequestMethod.GET)
@ -233,14 +234,14 @@ public class TestPlanController extends BaseController {
@ResponseBody
public TestPlanResponseModel removeTestPlanFromPool(int testPlanId) {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildTestPlanResponseModel(false, "no scope", null);
return buildTestPlanResponseModel(false, "no scope", null,null);
}
return buildTestPlanResponseModel(
this.testPlanService.removeTestPlanInDB(testPlanId), null, null);
this.testPlanService.removeTestPlanInDB(testPlanId), null, null,null);
}
private TestPlanResponseModel buildTestPlanResponseModel(boolean success,
String failCause, List<TestPlan> testPlanDBs) {
String failCause, List<TestPlan> testPlanDBs,String[] filterTypeList) {
TestPlanResponseModel result = new TestPlanResponseModel();
result.setSuccess(success);
result.setFailCause(failCause);
@ -251,6 +252,7 @@ public class TestPlanController extends BaseController {
}
}
result.setTestPlanDBModels(modelList);
result.setFilterTypeList(filterTypeList);
return result;
}
@ -312,7 +314,7 @@ public class TestPlanController extends BaseController {
guardIsTheOwner(testPlanId);
return buildTestPlanResponseModel(
this.getTestPlanRunner().stop(testPlanId), "",
Collections.<TestPlan> emptyList());
Collections.<TestPlan> emptyList(),null);
}
private void guardIsTheOwner(UUID testPlanId) {
@ -322,4 +324,18 @@ public class TestPlanController extends BaseController {
throw new Bench4QRunTimeException("You are not the owner");
}
}
@RequestMapping(value = "/loadFilterTypeList", method = { RequestMethod.POST,
RequestMethod.GET })
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanResponseModel loadFilterTypeList() throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER,
"You don't have enough power to get filter type list!",
"/loadFilterTypeList");
}
String[] filterTypeList = this.getTestPlanService().loadFilterTypeList();
return this.buildTestPlanResponseModel(true, null, null,filterTypeList);
}
}

View File

@ -180,7 +180,7 @@ public class RunningAgentDB implements RunningAgentInterface {
Script script2 = this.getTestPlanScript().getScript();
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
.tryUnmarshal(RunScenarioModel.class,
script2.getScriptContent());
script2.getFilteredScriptCnt());
runScenarioModel.setPoolSize(getLoadInUse());
RunScenarioResultModel runScenarioResultModel = this
.getAgentMessenger().submitScenrioWithParams(this.getAgent(),

View File

@ -27,6 +27,7 @@ public class Script {
private int id;
private String name;
private String scriptContent;
private String filteredScriptCnt;
private int behaviorCount;
private Date createDateTime;
private User user;
@ -134,4 +135,12 @@ public class Script {
}
return Arrays.asList(folder.listFiles());
}
public String getFilteredScriptCnt() {
return filteredScriptCnt;
}
public void setFilteredScriptCnt(String filteredScriptCnt) {
this.filteredScriptCnt = filteredScriptCnt;
}
}

View File

@ -1,6 +1,7 @@
package org.bench4q.master.domain.factory;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedList;
@ -16,6 +17,7 @@ import org.bench4q.master.domain.entity.Monitor;
import org.bench4q.master.domain.entity.MonitorResult;
import org.bench4q.master.domain.entity.PlanedConfig;
import org.bench4q.master.domain.entity.RunningAgentDB;
import org.bench4q.master.domain.entity.Script;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.entity.TestPlanScript;
import org.bench4q.master.domain.entity.TestPlanScriptResult;
@ -28,12 +30,20 @@ import org.bench4q.master.exception.ExceptionLog;
import org.bench4q.master.exception.ExceptionUtils.IllegalParameterException;
import org.bench4q.share.enums.master.TestPlanStatus;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.agent.ParameterModel;
import org.bench4q.share.models.agent.RunScenarioModel;
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.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.python.antlr.PythonParser.return_stmt_return;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -117,7 +127,7 @@ public class TestPlanFactory {
testPlanScripts.add(createATestPlanScriptWithoutId(
runningScriptModel.getRequireLoad(),
runningScriptModel.getScriptId(),
runningScriptModel.getConfig(), result));
runningScriptModel.getConfig(), result, runningScriptModel.getScriptFilterOptionsModel()));
}
result.setRequiredLoad(requiredLoad);
result.setTestPlanScripts(testPlanScripts);
@ -140,15 +150,59 @@ public class TestPlanFactory {
}
public TestPlanScript createATestPlanScriptWithoutId(int requireLoad,
int scriptId, TestScriptConfig config, TestPlan testPlanDB) {
int scriptId, TestScriptConfig config, TestPlan testPlanDB, ScriptFilterOptionsModel scriptFilterOptionsModel) {
TestPlanScript testPlanScript = new TestPlanScript();
testPlanScript.setRequireLoad(requireLoad);
testPlanScript.setScript(this.getScriptService().getScript(scriptId));
//filter the script
testPlanScript.setScript(createAScriptWithFilter(scriptFilterOptionsModel, this.getScriptService().getScript(scriptId)));
testPlanScript.setPlanedConfig(createAPlanedConfigWithoutId(config));
testPlanScript.setTestPlan(testPlanDB);
return testPlanScript;
}
private Script createAScriptWithFilter(ScriptFilterOptionsModel scriptFilterOptionsModel, Script script){
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
.tryUnmarshal(RunScenarioModel.class,
script.getFilteredScriptCnt());
List<String> filterPluginId = new ArrayList<String>();
if(scriptFilterOptionsModel.isFilterTimer()){
for(UsePluginModel pluginModel: runScenarioModel.getUsePlugins()){
if(pluginModel.getName().equals("ConstantTimer")){
filterPluginId.add(pluginModel.getId());
}
}
}
if(scriptFilterOptionsModel.getFilterTypeMatches() != null && !scriptFilterOptionsModel.getFilterTypeMatches().equals("")){
for(PageModel pageModel: runScenarioModel.getPages()){
for(BatchModel batchModel : pageModel.getBatches()){
for(BehaviorModel behaviorModel: batchModel.getBehaviors()){
if(filterPluginId.contains(behaviorModel.getUse()) || isFilterType(scriptFilterOptionsModel.getFilterTypeMatches(), behaviorModel)){
batchModel.getBehaviors().remove(behaviorModel);
}
}
}
}
}
String contentString = MarshalHelper.tryMarshal(runScenarioModel);
script.setFilteredScriptCnt(contentString);
return script;
}
private boolean isFilterType(String filterTypeMatch, BehaviorModel behaviorModel){
for(ParameterModel parameterModel:behaviorModel.getParameters()){
if(parameterModel.getKey().equals("expResCnttype")){
if(parameterModel.getValue().matches(filterTypeMatch)){
return true;
}else{
return false;
}
}
}
return false;
}
private PlanedConfig createAPlanedConfigWithoutId(TestScriptConfig config) {
PlanedConfig planedConfig = new PlanedConfig();
planedConfig.setWarmUp(config.getWarmUp());

View File

@ -28,8 +28,6 @@ public class ScriptService {
private UserRepository userRepository;
private Logger logger = Logger.getLogger(ScriptService.class);
private Properties properties = null;
private ScriptRepositoty getScriptRepositoty() {
return scriptRepositoty;
}
@ -82,11 +80,6 @@ public class ScriptService {
return this.getScriptRepositoty().loadEntities(user);
}
public String[] loadFilterTypeList() {
return getFilterTypeList();
}
public List<Script> queryScriptsByCreateTime(Date startDate, Date endDate,
User user) {
return this.getScriptRepositoty().getWith(
@ -131,19 +124,4 @@ public class ScriptService {
return this.getScriptRepositoty().update(script);
}
private String[] getFilterTypeList(){
if(properties == null){
try {
properties = new Properties();
InputStream inputStream = ScriptService.class.getClassLoader()
.getResourceAsStream(
"org/bench4q/master/config/FilterType.properties");
properties.load(inputStream);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return properties.getProperty("filter.type.list","").split(",");
}
}

View File

@ -1,8 +1,11 @@
package org.bench4q.master.domain.service;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
import org.apache.log4j.Logger;
@ -26,6 +29,8 @@ public class TestPlanService {
private BusinessModelMapFactory businessMapFactory;
private TestPlanRepository testPlanRepository;
private Properties properties = null;
private TestPlanRepository getTestPlanRepository() {
return testPlanRepository;
}
@ -96,4 +101,23 @@ public class TestPlanService {
public Collection<TestPlan> loadAllRunningTestPlans() {
return this.getTestPlanRepository().loadRunningTestPlans();
}
public String[] loadFilterTypeList() {
return getFilterTypeList();
}
private String[] getFilterTypeList(){
if(properties == null){
try {
properties = new Properties();
InputStream inputStream = ScriptService.class.getClassLoader()
.getResourceAsStream(
"org/bench4q/master/config/FilterType.properties");
properties.load(inputStream);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return properties.getProperty("filter.type.list","").split(",");
}
}

View File

@ -16,7 +16,6 @@ public class RunScenarioModel {
private int poolSize;
private List<UsePluginModel> usePlugins;
private List<PageModel> pages;
private List<String> filteredTypes;
private TestScheduleModel scheduleModel;
@XmlElement
public int getPoolSize() {
@ -61,13 +60,4 @@ public class RunScenarioModel {
this.setPages(new LinkedList<PageModel>());
}
@XmlElementWrapper(name = "filteredTypes")
@XmlElement(name = "filteredType")
public List<String> getFilteredTypes() {
return filteredTypes;
}
public void setFilteredTypes(List<String> filteredTypes) {
this.filteredTypes = filteredTypes;
}
}

View File

@ -0,0 +1,27 @@
package org.bench4q.share.models.agent;
import java.util.List;
public class ScriptFilterOptionsModel {
private boolean isFilterTimer = false;
private String filterTypeMatches;
public boolean isFilterTimer() {
return isFilterTimer;
}
public void setFilterTimer(boolean isFilterTimer) {
this.isFilterTimer = isFilterTimer;
}
public String getFilterTypeMatches() {
return filterTypeMatches;
}
public void setFilterTypeMatches(String filterTypeMatches) {
this.filterTypeMatches = filterTypeMatches;
}
}

View File

@ -19,7 +19,6 @@ public class OperateScriptServerResponseModel {
private int port;
private String fileName;
private List<ScriptModel> scriptModels;
private String[] filterTypeList;
@XmlElement
public boolean isSuccess() {
@ -75,13 +74,5 @@ public class OperateScriptServerResponseModel {
this.scriptModels = scriptModels;
}
@XmlElement
public String[] getFilterTypeList() {
return filterTypeList;
}
public void setFilterTypeList(String[] filterTypeList) {
this.filterTypeList = filterTypeList;
}
}

View File

@ -9,12 +9,14 @@ import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.ScriptFilterOptionsModel;
@XmlRootElement(name = "runningScripModel")
public class RunningScriptModel {
private int scriptId;
private int requireLoad;
private TestScriptConfig config;
private ScriptFilterOptionsModel scriptFilterOptionsModel;
private RunScenarioModel scenarioModel;
private String scriptName;
private boolean finished;
@ -92,4 +94,13 @@ public class RunningScriptModel {
public void setTestPlanID(UUID testPlanID) {
this.testPlanID = testPlanID;
}
@XmlElement
public ScriptFilterOptionsModel getScriptFilterOptionsModel() {
return scriptFilterOptionsModel;
}
public void setScriptFilterOptionsModel(ScriptFilterOptionsModel scriptFilterOptionsModel) {
this.scriptFilterOptionsModel = scriptFilterOptionsModel;
}
}

View File

@ -11,6 +11,7 @@ public class TestPlanResponseModel {
private boolean success;
private String failCause;
private List<TestPlanDBModel> testPlanDBModels;
private String[] filterTypeList;
@XmlElement
public boolean isSuccess() {
@ -40,4 +41,12 @@ public class TestPlanResponseModel {
this.testPlanDBModels = testPlanDBModels;
}
public String[] getFilterTypeList() {
return filterTypeList;
}
public void setFilterTypeList(String[] filterTypeList) {
this.filterTypeList = filterTypeList;
}
}

View File

@ -359,21 +359,6 @@ public class ScriptController extends BaseController {
return map;
}
@RequestMapping("loadFilterTypeList")
public @ResponseBody
Map<String, Object> loadFilterTypeList(HttpServletRequest request,
@ModelAttribute("accessToken") String accessToken) {
OperateScriptServerResponseModel responseModel = this.getScriptMessager().loadFilterTypeList(accessToken);
Map<String,Object> map = new HashMap<String, Object>();
if(responseModel.isSuccess()){
map.put("filterTypeList", responseModel.getFilterTypeList());
success(map);
}else{
fail(map, responseModel.getFailCauseString());
}
return map;
}
private void updateRunScenarioModel(RunScenarioModel runScenarioModel) {
List<BehaviorModel> behaviorModels = new LinkedList<BehaviorModel>();
for (PageModel pageModel : runScenarioModel.getPages()) {

View File

@ -9,6 +9,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.JAXBException;
import org.apache.log4j.Logger;
@ -16,6 +17,7 @@ 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.OperateScriptServerResponseModel;
import org.bench4q.share.models.master.ScriptHandleModel;
import org.bench4q.share.models.master.TestPlanDBModel;
import org.bench4q.share.models.master.TestPlanModel;
@ -418,4 +420,19 @@ public class TestPlanController extends BaseController {
return fail(map, testPlanResponseModel.getFailCause());
}
}
@RequestMapping("loadFilterTypeList")
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()){
map.put("filterTypeList", responseModel.getFilterTypeList());
success(map);
}else{
fail(map, responseModel.getFailCause());
}
return map;
}
}

View File

@ -189,11 +189,7 @@ public class ScriptMessager extends MasterMessager {
accessToken);
}
public OperateScriptServerResponseModel loadFilterTypeList(String accessToken) {
String url = this.getBaseUrl() + "/loadFilterTypeList";
return this.getOperateScriptServerResponseModelByPost(url, null,
accessToken);
}
private OperateScriptServerResponseModel getOperateScriptServerResponseModelByPost(
String url, Map<String, String> params, String accessToken) {

View File

@ -4,9 +4,12 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.JAXBException;
import org.bench4q.share.communication.HttpRequester.HttpResponse;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
import org.bench4q.share.models.master.TestPlanDBModel;
import org.bench4q.share.models.master.TestPlanResponseModel;
import org.bench4q.share.models.master.TestPlanResultModel;
@ -268,4 +271,9 @@ public class TestPlanMessager extends MasterMessager {
String url = this.baseUrl + "/stop" + "/" + testPlanRunId;
return getTestPlanResponseModel(url, null, accessToken);
}
public TestPlanResponseModel loadFilterTypeList(String accessToken) {
String url = this.getBaseUrl() + "/loadFilterTypeList";
return getTestPlanResponseModel(url, null, accessToken);
}
}

View File

@ -1,5 +1,9 @@
package org.bench4q.web.model;
import java.util.ArrayList;
import java.util.List;
public class WebScriptModel {
private int id;
private int load;
@ -8,14 +12,16 @@ public class WebScriptModel {
private long cooldown;
private boolean staticResources;
private boolean timer;
private String filterTypeMatches = null;
public WebScriptModel() {
}
public WebScriptModel(int id,int load,long warmup,long executeRange,long cooldown){
public WebScriptModel(int id,int load,long warmup,long executeRange,long cooldown,String filterTypeMatches){
this.id=id;
this.load=load;
this.warmup=warmup;
this.executeRange=executeRange;
this.cooldown=cooldown;
this.filterTypeMatches = filterTypeMatches;
}
public int getId() {
@ -69,6 +75,12 @@ public class WebScriptModel {
public void setTimer(boolean timer) {
this.timer = timer;
}
public String getFilterTypeMatches() {
return filterTypeMatches;
}
public void setFilterTypeMatches(String filterTypeMatches) {
this.filterTypeMatches = filterTypeMatches;
}
}

View File

@ -7,9 +7,11 @@ import java.util.LinkedList;
import java.util.List;
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;
import org.bench4q.share.models.master.ScriptHandleModel;
@ -67,17 +69,17 @@ public class TestPlanService {
RunningScriptModel runnningScriptModel = new RunningScriptModel();
runnningScriptModel.setScriptId(scriptModel.getId());
runnningScriptModel.setRequireLoad(scriptModel.getLoad());
// ScriptFilterOptionsModel scriptFilterOptionsModel = new ScriptFilterOptionsModel();
// scriptFilterOptionsModel.setStaticResources(scriptModel
// .isStaticResources());
// scriptFilterOptionsModel.setTimer(scriptModel.isTimer());
ScriptFilterOptionsModel scriptFilterOptionsModel = new ScriptFilterOptionsModel();
scriptFilterOptionsModel.setFilterTypeMatches(scriptModel.getFilterTypeMatches());
scriptFilterOptionsModel.setFilterTimer(scriptModel.isTimer());
TestScriptConfig testScriptConfig = new TestScriptConfig();
testScriptConfig.setCoolDown(scriptModel.getCooldown());
testScriptConfig.setExecuteRange(scriptModel.getExecuteRange());
testScriptConfig.setWarmUp(scriptModel.getWarmup());
runnningScriptModel.setConfig(testScriptConfig);
// runnningScriptModel
// .setScriptFilterOptionsModel(scriptFilterOptionsModel);
runnningScriptModel
.setScriptFilterOptionsModel(scriptFilterOptionsModel);
scriptList.add(runnningScriptModel);
}
return scriptList;

View File

@ -1 +1 @@
masterAddress=133.133.2.105:8901
masterAddress=localhost:8901