Add briefCycleInMillis to bookTest
Add briefCycleInMillis to bookTest q
This commit is contained in:
parent
e0392650dd
commit
91a64883d0
|
@ -3,7 +3,6 @@ package org.bench4q.agent.api;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.bench4q.agent.plugin.ParameterFileCollector;
|
import org.bench4q.agent.plugin.ParameterFileCollector;
|
||||||
|
@ -59,14 +58,11 @@ public class TestController {
|
||||||
RequestMethod.GET, RequestMethod.POST })
|
RequestMethod.GET, RequestMethod.POST })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RunScenarioResultModel bookTest(@PathVariable int poolSize,
|
public RunScenarioResultModel bookTest(@PathVariable int poolSize,
|
||||||
@RequestParam(value = "briefCycle") int briefCycle,
|
@RequestParam(value = "briefCycleInMillis") long briefCycleInMillis) {
|
||||||
@RequestParam(value = "briefUnit") String briefUnit) {
|
|
||||||
try {
|
try {
|
||||||
UUID runId = UUID.randomUUID();
|
UUID runId = UUID.randomUUID();
|
||||||
long sampleCycleInMillis = TimeUnit.valueOf(briefUnit).toMillis(
|
|
||||||
briefCycle);
|
|
||||||
this.getScenarioEngine().addRunningTestWithoutScenario(runId,
|
this.getScenarioEngine().addRunningTestWithoutScenario(runId,
|
||||||
poolSize);
|
poolSize, briefCycleInMillis);
|
||||||
RunScenarioResultModel runScenarioResultModel = new RunScenarioResultModel();
|
RunScenarioResultModel runScenarioResultModel = new RunScenarioResultModel();
|
||||||
runScenarioResultModel.setRunId(runId);
|
runScenarioResultModel.setRunId(runId);
|
||||||
return runScenarioResultModel;
|
return runScenarioResultModel;
|
||||||
|
|
|
@ -30,20 +30,23 @@ import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
|
||||||
public class ScenarioContext implements Observer {
|
public class ScenarioContext implements Observer {
|
||||||
private static final long keepAliveTime = 10;
|
private static final long keepAliveTime = 10;
|
||||||
private final UUID testId;
|
private final UUID testId;
|
||||||
|
private final long briefCycleInMillis;
|
||||||
private final Date startDate;
|
private final Date startDate;
|
||||||
private Date endDate;
|
private Date endDate;
|
||||||
private final ThreadPoolExecutor executor;
|
private final ThreadPoolExecutor executor;
|
||||||
private Scenario scenario;
|
private final Scenario scenario;
|
||||||
private boolean finished;
|
private boolean finished;
|
||||||
private final DataCollector dataCollector;
|
private final DataCollector dataCollector;
|
||||||
private final PluginManager pluginManager;
|
private final PluginManager pluginManager;
|
||||||
private Schedule schedule;
|
private Schedule schedule;
|
||||||
private Logger logger = Logger.getLogger(this.getClass());
|
private Logger logger = Logger.getLogger(this.getClass());
|
||||||
|
|
||||||
private ScenarioContext(UUID testId, Date startDate,
|
private ScenarioContext(UUID testId, Scenario scenario, Date startDate,
|
||||||
ThreadPoolExecutor executor, DataCollector dataCollector,
|
ThreadPoolExecutor executor, DataCollector dataCollector,
|
||||||
PluginManager pluginManager) {
|
PluginManager pluginManager, long briefCycleInMillis) {
|
||||||
this.testId = testId;
|
this.testId = testId;
|
||||||
|
this.briefCycleInMillis = briefCycleInMillis;
|
||||||
|
this.scenario = scenario;
|
||||||
this.startDate = startDate;
|
this.startDate = startDate;
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.dataCollector = dataCollector;
|
this.dataCollector = dataCollector;
|
||||||
|
@ -74,10 +77,6 @@ public class ScenarioContext implements Observer {
|
||||||
return scenario;
|
return scenario;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setScenario(Scenario scenario) {
|
|
||||||
this.scenario = scenario;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return finished;
|
return finished;
|
||||||
}
|
}
|
||||||
|
@ -104,29 +103,29 @@ public class ScenarioContext implements Observer {
|
||||||
|
|
||||||
public static ScenarioContext buildScenarioContextWithoutScenario(
|
public static ScenarioContext buildScenarioContextWithoutScenario(
|
||||||
UUID testId, int poolSize, PluginManager pluginManager,
|
UUID testId, int poolSize, PluginManager pluginManager,
|
||||||
StorageHelper storageHelper) {
|
StorageHelper storageHelper, long briefCycleInMillis) {
|
||||||
final ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<Runnable>(
|
final ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<Runnable>(
|
||||||
poolSize);
|
poolSize);
|
||||||
ThreadPoolExecutor executor = new ThreadPoolExecutor(poolSize,
|
ThreadPoolExecutor executor = new ThreadPoolExecutor(poolSize,
|
||||||
poolSize, keepAliveTime, TimeUnit.MINUTES, workQueue,
|
poolSize, keepAliveTime, TimeUnit.MINUTES, workQueue,
|
||||||
new DiscardPolicy());
|
new DiscardPolicy());
|
||||||
ScenarioContext scenarioContext = new ScenarioContext(testId, new Date(
|
ScenarioContext scenarioContext = new ScenarioContext(testId, null,
|
||||||
System.currentTimeMillis()), executor, new DataCollectorImpl(
|
new Date(System.currentTimeMillis()), executor,
|
||||||
testId, storageHelper), pluginManager);
|
new DataCollectorImpl(testId, storageHelper), pluginManager,
|
||||||
|
briefCycleInMillis);
|
||||||
return scenarioContext;
|
return scenarioContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScenarioContext addScenrio(final Scenario scenario,
|
public ScenarioContext addScenrio(final Scenario scenario,
|
||||||
Schedule schedule, final long realStartTime) {
|
Schedule schedule, final long realStartTime) {
|
||||||
ScenarioContext result = new ScenarioContext(this.testId, new Date(
|
ScenarioContext result = new ScenarioContext(this.testId, scenario,
|
||||||
realStartTime), this.executor, this.dataCollector,
|
new Date(realStartTime), this.executor, this.dataCollector,
|
||||||
this.pluginManager);
|
this.pluginManager, this.briefCycleInMillis);
|
||||||
result.setSchedule(schedule);
|
result.setSchedule(schedule);
|
||||||
result.setEndDate(new Date(result.getSchedule()
|
result.setEndDate(new Date(result.getSchedule()
|
||||||
.getScheduleRangeInMilliSecond()
|
.getScheduleRangeInMilliSecond()
|
||||||
+ result.getStartDate().getTime()));
|
+ result.getStartDate().getTime()));
|
||||||
result.setFinished(this.isFinished());
|
result.setFinished(this.isFinished());
|
||||||
result.setScenario(scenario);
|
|
||||||
result.getSchedule().addObserver(result);
|
result.getSchedule().addObserver(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,11 +50,13 @@ public class ScenarioEngine implements Observer {
|
||||||
this.storageHelper = storageHelper;
|
this.storageHelper = storageHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRunningTestWithoutScenario(UUID runId, int poolSize) {
|
public void addRunningTestWithoutScenario(UUID runId, int poolSize,
|
||||||
|
long sampleCycleInMillis) {
|
||||||
try {
|
try {
|
||||||
final ScenarioContext scenarioContext = ScenarioContext
|
final ScenarioContext scenarioContext = ScenarioContext
|
||||||
.buildScenarioContextWithoutScenario(runId, poolSize,
|
.buildScenarioContextWithoutScenario(runId, poolSize,
|
||||||
getPluginManager(), this.getStorageHelper());
|
getPluginManager(), this.getStorageHelper(),
|
||||||
|
sampleCycleInMillis);
|
||||||
this.getRunningTests().put(runId, scenarioContext);
|
this.getRunningTests().put(runId, scenarioContext);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.bench4q.share.models.agent.scriptrecord.ScheduleModel.PointModel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
public abstract class TestBase {
|
public abstract class TestBase {
|
||||||
|
protected static final int BRIEF_CYCLE_IN_MILLIS = 3000;
|
||||||
private ParameterBarn basePara;
|
private ParameterBarn basePara;
|
||||||
private PluginManager pluginManager;
|
private PluginManager pluginManager;
|
||||||
private StorageHelper storageHelper;
|
private StorageHelper storageHelper;
|
||||||
|
@ -137,7 +138,7 @@ public abstract class TestBase {
|
||||||
StorageHelper storageHelper) {
|
StorageHelper storageHelper) {
|
||||||
ScenarioContext scenarioContext = ScenarioContext
|
ScenarioContext scenarioContext = ScenarioContext
|
||||||
.buildScenarioContextWithoutScenario(testId, poolSize,
|
.buildScenarioContextWithoutScenario(testId, poolSize,
|
||||||
pluginManager, storageHelper);
|
pluginManager, storageHelper, BRIEF_CYCLE_IN_MILLIS);
|
||||||
return scenarioContext.addScenrio(scenario,
|
return scenarioContext.addScenrio(scenario,
|
||||||
Schedule.build(buildScheduleModel()), new Date().getTime());
|
Schedule.build(buildScheduleModel()), new Date().getTime());
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -191,8 +192,10 @@ public class TestWithScriptFile extends TestBase {
|
||||||
+ "testForBrief.xml"));
|
+ "testForBrief.xml"));
|
||||||
files.add(new File("Scripts" + System.getProperty("file.separator")
|
files.add(new File("Scripts" + System.getProperty("file.separator")
|
||||||
+ "testJD.xml"));
|
+ "testJD.xml"));
|
||||||
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
params.put("briefCycleInMillis", String.valueOf(BRIEF_CYCLE_IN_MILLIS));
|
||||||
HttpResponse httpResponse1 = this.getHttpRequester().sendPost(
|
HttpResponse httpResponse1 = this.getHttpRequester().sendPost(
|
||||||
url + "/bookTest/20", null, null);
|
url + "/bookTest/20", params, null);
|
||||||
RunScenarioResultModel bookResponse = MarshalHelper.tryUnmarshal(
|
RunScenarioResultModel bookResponse = MarshalHelper.tryUnmarshal(
|
||||||
RunScenarioResultModel.class, httpResponse1.getContent());
|
RunScenarioResultModel.class, httpResponse1.getContent());
|
||||||
assertNotNull(bookResponse);
|
assertNotNull(bookResponse);
|
||||||
|
|
|
@ -49,7 +49,8 @@ public class Test_ScenarioContext extends TestBase {
|
||||||
private ScenarioContext getScenarioWithScenarioAndSchedule() {
|
private ScenarioContext getScenarioWithScenarioAndSchedule() {
|
||||||
ScenarioContext scenarioContext = ScenarioContext
|
ScenarioContext scenarioContext = ScenarioContext
|
||||||
.buildScenarioContextWithoutScenario(UUID.randomUUID(), 100,
|
.buildScenarioContextWithoutScenario(UUID.randomUUID(), 100,
|
||||||
pluginManager, this.storageHelper);
|
pluginManager, this.storageHelper,
|
||||||
|
BRIEF_CYCLE_IN_MILLIS);
|
||||||
scenarioContext = scenarioContext
|
scenarioContext = scenarioContext
|
||||||
.addScenrio(
|
.addScenrio(
|
||||||
Scenario.scenarioCompiler(buildRunScenarioModelWith(new LinkedList<UsePluginModel>())),
|
Scenario.scenarioCompiler(buildRunScenarioModelWith(new LinkedList<UsePluginModel>())),
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class Main {
|
||||||
public static int PICK_CYCLE_IN_SECONDS = 60;
|
public static int PICK_CYCLE_IN_SECONDS = 60;
|
||||||
public static String SCRIPT_PARAM_ROOT_FOLDER = "ScriptParameterization";
|
public static String SCRIPT_PARAM_ROOT_FOLDER = "ScriptParameterization";
|
||||||
public static String FILE_SEPARATOR = System.getProperty("file.separator");
|
public static String FILE_SEPARATOR = System.getProperty("file.separator");
|
||||||
|
public static long briefCycleInMillis = 10000;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
try {
|
||||||
|
@ -47,6 +48,8 @@ public class Main {
|
||||||
.getProperty("minSampleCycleInSeconds"));
|
.getProperty("minSampleCycleInSeconds"));
|
||||||
SCRIPT_PARAM_ROOT_FOLDER = prop
|
SCRIPT_PARAM_ROOT_FOLDER = prop
|
||||||
.getProperty("scriptParamRootFolder");
|
.getProperty("scriptParamRootFolder");
|
||||||
|
briefCycleInMillis = Long.parseLong(prop
|
||||||
|
.getProperty("briefCycleInMillis"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
MAX_FAIL_TIMES = 10;
|
MAX_FAIL_TIMES = 10;
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
@ -25,7 +24,6 @@ import org.bench4q.master.domain.factory.TestPlanFactory;
|
||||||
import org.bench4q.master.domain.valueobject.datastatistics.TestMonitorSampler;
|
import org.bench4q.master.domain.valueobject.datastatistics.TestMonitorSampler;
|
||||||
import org.bench4q.master.exception.ExceptionLog;
|
import org.bench4q.master.exception.ExceptionLog;
|
||||||
import org.bench4q.master.helper.ApplicationContextHelper;
|
import org.bench4q.master.helper.ApplicationContextHelper;
|
||||||
import org.bench4q.master.infrastructure.communication.MonitorMessenger;
|
|
||||||
import org.bench4q.share.helper.MarshalHelper;
|
import org.bench4q.share.helper.MarshalHelper;
|
||||||
import org.bench4q.share.models.monitor.MemoryModel;
|
import org.bench4q.share.models.monitor.MemoryModel;
|
||||||
import org.bench4q.share.models.monitor.MonitorMain;
|
import org.bench4q.share.models.monitor.MonitorMain;
|
||||||
|
@ -35,7 +33,6 @@ import org.bench4q.share.models.monitor.ProcessModel;
|
||||||
import org.bench4q.share.models.monitor.ProcessModelChild;
|
import org.bench4q.share.models.monitor.ProcessModelChild;
|
||||||
import org.bench4q.share.models.monitor.ProcessorModel;
|
import org.bench4q.share.models.monitor.ProcessorModel;
|
||||||
import org.bench4q.share.models.monitor.ProcessorModelChild;
|
import org.bench4q.share.models.monitor.ProcessorModelChild;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "monitor")
|
@Table(name = "monitor")
|
||||||
|
@ -124,7 +121,7 @@ public class Monitor {
|
||||||
MonitorMain monitorMain = getTestMonitorSampler().getMonitorResult(
|
MonitorMain monitorMain = getTestMonitorSampler().getMonitorResult(
|
||||||
hostName, port, this.testPlan.getTestPlanRunId());
|
hostName, port, this.testPlan.getTestPlanRunId());
|
||||||
System.out.println(MarshalHelper.tryMarshal(monitorMain));
|
System.out.println(MarshalHelper.tryMarshal(monitorMain));
|
||||||
//tell test plan has to stop itself
|
// tell test plan has to stop itself
|
||||||
testPlan.setHasToStop(monitorMain.isTouchLimit());
|
testPlan.setHasToStop(monitorMain.isTouchLimit());
|
||||||
List<MonitorResult> monitorResults = this.getTestPlanFactory()
|
List<MonitorResult> monitorResults = this.getTestPlanFactory()
|
||||||
.createMonitorResultListWithOutId(monitorMain, testPlan,
|
.createMonitorResultListWithOutId(monitorMain, testPlan,
|
||||||
|
@ -137,8 +134,10 @@ public class Monitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(){
|
public void start() {
|
||||||
this.getTestMonitorSampler().startMonitor(hostName, port, this.testPlan.getTestPlanRunId(), this.testPlan.getLimitModel());
|
this.getTestMonitorSampler()
|
||||||
|
.startMonitor(hostName, port, this.testPlan.getTestPlanRunId(),
|
||||||
|
this.testPlan.getLimitModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MonitorResult> createFinishedResult() {
|
public List<MonitorResult> createFinishedResult() {
|
||||||
|
|
|
@ -223,7 +223,7 @@ public class RunningAgentDB implements RunningAgentInterface {
|
||||||
public boolean run() {
|
public boolean run() {
|
||||||
// TODO: refactor this function to transaction
|
// TODO: refactor this function to transaction
|
||||||
RunScenarioResultModel runScenarioResultModel = this
|
RunScenarioResultModel runScenarioResultModel = this
|
||||||
.getAgentMessenger().runWithParams(this.getAgent(),
|
.getAgentMessenger().run(this.getAgent(),
|
||||||
this.getAgentRunId());
|
this.getAgentRunId());
|
||||||
return runScenarioResultModel != null;
|
return runScenarioResultModel != null;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ public class RunningAgentDB implements RunningAgentInterface {
|
||||||
// if (this.isStoped()) {
|
// if (this.isStoped()) {
|
||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
return this.getAgentMessenger().scriptBriefAll(this.getAgent(),
|
return this.getAgentMessenger().brief(this.getAgent(),
|
||||||
this.getAgentRunId());
|
this.getAgentRunId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.bench4q.master.domain.service;
|
package org.bench4q.master.domain.service;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -13,7 +11,6 @@ import org.bench4q.master.exception.Bench4QException;
|
||||||
import org.bench4q.master.exception.ExceptionLog;
|
import org.bench4q.master.exception.ExceptionLog;
|
||||||
import org.bench4q.master.helper.SessionHelper;
|
import org.bench4q.master.helper.SessionHelper;
|
||||||
import org.bench4q.master.infrastructure.communication.MonitorMessenger;
|
import org.bench4q.master.infrastructure.communication.MonitorMessenger;
|
||||||
import org.bench4q.recorder.httpcapture.generator.HtmlDocumentParser;
|
|
||||||
import org.bench4q.share.helper.MarshalHelper;
|
import org.bench4q.share.helper.MarshalHelper;
|
||||||
import org.bench4q.share.models.master.MonitorMemoryResponseModel;
|
import org.bench4q.share.models.master.MonitorMemoryResponseModel;
|
||||||
import org.bench4q.share.models.master.MonitorNetworkReponseModel;
|
import org.bench4q.share.models.master.MonitorNetworkReponseModel;
|
||||||
|
@ -29,7 +26,6 @@ import org.bench4q.share.models.monitor.ProcessorModel;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.criterion.Order;
|
import org.hibernate.criterion.Order;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
import org.python.antlr.PythonParser.return_stmt_return;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -37,7 +33,6 @@ import org.springframework.stereotype.Component;
|
||||||
public class MonitorResultService {
|
public class MonitorResultService {
|
||||||
private TestPlanRepository testPlanRepository;
|
private TestPlanRepository testPlanRepository;
|
||||||
private SessionHelper sessionHelper;
|
private SessionHelper sessionHelper;
|
||||||
private LimitableFieldsModel limitableField = null;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MonitorMessenger monitorMessenger;
|
private MonitorMessenger monitorMessenger;
|
||||||
private static Logger logger = Logger.getLogger(MonitorResult.class);
|
private static Logger logger = Logger.getLogger(MonitorResult.class);
|
||||||
|
@ -181,29 +176,7 @@ public class MonitorResultService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initLimitableFields(){
|
public LimitableFieldsModel getLimitableFields(String hostName, int port) {
|
||||||
String pathSep = System.getProperty("file.separator");
|
|
||||||
String limitableFieldsPath = "org" + pathSep + "bench4q" + pathSep
|
|
||||||
+ "master" + pathSep + "config" + pathSep + "MonitorLimitableFields.xml";
|
|
||||||
|
|
||||||
InputStream is = HtmlDocumentParser.class.getClassLoader()
|
|
||||||
.getResourceAsStream(limitableFieldsPath);
|
|
||||||
if (is == null)
|
|
||||||
return;
|
|
||||||
StringBuffer out = new StringBuffer();
|
|
||||||
byte[] b = new byte[4096];
|
|
||||||
int n;
|
|
||||||
try {
|
|
||||||
while ((n = is.read(b)) != -1) {
|
|
||||||
out.append(new String(b, 0, n));
|
|
||||||
}
|
|
||||||
limitableField = MarshalHelper.tryUnmarshal(LimitableFieldsModel.class, out.toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public LimitableFieldsModel getLimitableFields(String hostName, int port){
|
|
||||||
return monitorMessenger.getLimitableFields(hostName, port);
|
return monitorMessenger.getLimitableFields(hostName, port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,13 @@ public interface AgentMessenger {
|
||||||
final RunScenarioModel runScenarioModel,
|
final RunScenarioModel runScenarioModel,
|
||||||
final ScheduleModel scheduleModel, Date realStartDate);
|
final ScheduleModel scheduleModel, Date realStartDate);
|
||||||
|
|
||||||
public RunScenarioResultModel runWithParams(Agent agent, UUID agentRunId);
|
public RunScenarioResultModel run(Agent agent, UUID agentRunId);
|
||||||
|
|
||||||
public TestBriefStatusModel scriptBriefAll(Agent agent, UUID runId);
|
public TestBriefStatusModel brief(Agent agent, UUID runId);
|
||||||
|
|
||||||
public StopTestModel stop(Agent agent, UUID runId);
|
public StopTestModel stop(Agent agent, UUID runId);
|
||||||
|
|
||||||
public ServerStatusModel getStatus(Agent agent);
|
public ServerStatusModel status(Agent agent);
|
||||||
|
|
||||||
public Future<ServerStatusModel> getStatusAsync(Agent agent);
|
public Future<ServerStatusModel> statusAsync(Agent agent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.bench4q.master.infrastructure.communication.impl;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -50,6 +51,8 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
public RunScenarioResultModel bookTest(Agent agent, int requireLoad) {
|
public RunScenarioResultModel bookTest(Agent agent, int requireLoad) {
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
try {
|
try {
|
||||||
|
Map<String, String> parms = new HashMap<String, String>(1);
|
||||||
|
parms.put("briefCycleInMillis", String.valueOf(3000));
|
||||||
httpResponse = this.getHttpRequester().sendGet(
|
httpResponse = this.getHttpRequester().sendGet(
|
||||||
buildBaseUrl(agent) + "/test/bookTest/" + requireLoad,
|
buildBaseUrl(agent) + "/test/bookTest/" + requireLoad,
|
||||||
null, null);
|
null, null);
|
||||||
|
@ -113,7 +116,7 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public RunScenarioResultModel runWithParams(Agent agent, UUID agentRunId) {
|
public RunScenarioResultModel run(Agent agent, UUID agentRunId) {
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
try {
|
try {
|
||||||
if (agent == null || agentRunId == null) {
|
if (agent == null || agentRunId == null) {
|
||||||
|
@ -139,13 +142,13 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
return this.executorService
|
return this.executorService
|
||||||
.submit(new Callable<RunScenarioResultModel>() {
|
.submit(new Callable<RunScenarioResultModel>() {
|
||||||
public RunScenarioResultModel call() throws Exception {
|
public RunScenarioResultModel call() throws Exception {
|
||||||
return runWithParams(agent, agentRunId);
|
return run(agent, agentRunId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// there is bug in here
|
// there is bug in here
|
||||||
public TestBriefStatusModel scriptBriefAll(Agent agent, UUID runId) {
|
public TestBriefStatusModel brief(Agent agent, UUID runId) {
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
try {
|
try {
|
||||||
if (agent == null || runId == null) {
|
if (agent == null || runId == null) {
|
||||||
|
@ -169,13 +172,13 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Future<TestBriefStatusModel> scriptBriefAsync(final Agent agent,
|
public Future<TestBriefStatusModel> briefAsync(final Agent agent,
|
||||||
final UUID runId) {
|
final UUID runId) {
|
||||||
return this.executorService
|
return this.executorService
|
||||||
.submit(new Callable<TestBriefStatusModel>() {
|
.submit(new Callable<TestBriefStatusModel>() {
|
||||||
|
|
||||||
public TestBriefStatusModel call() throws Exception {
|
public TestBriefStatusModel call() throws Exception {
|
||||||
return scriptBriefAll(agent, runId);
|
return brief(agent, runId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -214,7 +217,7 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
return agent.getHostName() + ":" + agent.getPort();
|
return agent.getHostName() + ":" + agent.getPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStatusModel getStatus(Agent agent) {
|
public ServerStatusModel status(Agent agent) {
|
||||||
try {
|
try {
|
||||||
HttpResponse httpResponse = this.getHttpRequester().sendGet(
|
HttpResponse httpResponse = this.getHttpRequester().sendGet(
|
||||||
agent.getHostName() + ":" + agent.getPort() + "/", null,
|
agent.getHostName() + ":" + agent.getPort() + "/", null,
|
||||||
|
@ -230,11 +233,11 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Future<ServerStatusModel> getStatusAsync(final Agent agent) {
|
public Future<ServerStatusModel> statusAsync(final Agent agent) {
|
||||||
return this.executorService.submit(new Callable<ServerStatusModel>() {
|
return this.executorService.submit(new Callable<ServerStatusModel>() {
|
||||||
|
|
||||||
public ServerStatusModel call() throws Exception {
|
public ServerStatusModel call() throws Exception {
|
||||||
return getStatus(agent);
|
return status(agent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class HighAvailablePoolImpl extends CurrentLoadSubject implements
|
||||||
private void heartBeatsAndUpdateHAPool() {
|
private void heartBeatsAndUpdateHAPool() {
|
||||||
Map<Agent, Future<ServerStatusModel>> map = new HashMap<Agent, Future<ServerStatusModel>>();
|
Map<Agent, Future<ServerStatusModel>> map = new HashMap<Agent, Future<ServerStatusModel>>();
|
||||||
for (Agent agent : this.getPool().values()) {
|
for (Agent agent : this.getPool().values()) {
|
||||||
map.put(agent, this.getAgentMessenger().getStatusAsync(agent));
|
map.put(agent, this.getAgentMessenger().statusAsync(agent));
|
||||||
}
|
}
|
||||||
this.updateAgentPoolByHeart(map);
|
this.updateAgentPoolByHeart(map);
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ public class HighAvailablePoolImpl extends CurrentLoadSubject implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStatusModel queryAgentStatus(Agent agent) {
|
public ServerStatusModel queryAgentStatus(Agent agent) {
|
||||||
return this.getAgentMessenger().getStatus(agent);
|
return this.getAgentMessenger().status(agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,3 +4,4 @@ maxFailTime=10
|
||||||
minExcuteIntervalInSeconds=600
|
minExcuteIntervalInSeconds=600
|
||||||
minSampleCycleInSeconds=10
|
minSampleCycleInSeconds=10
|
||||||
scriptParamRootFolder=ScriptParameterization
|
scriptParamRootFolder=ScriptParameterization
|
||||||
|
briefCycleInMillis=3000
|
|
@ -54,7 +54,7 @@ public class Test_HighAvailableWithActualMessenger extends
|
||||||
this.getHaPool().checkAllHeartBeat();
|
this.getHaPool().checkAllHeartBeat();
|
||||||
for (RunningAgentInterface runingAgent : agentRunBlottersBeforeKill
|
for (RunningAgentInterface runingAgent : agentRunBlottersBeforeKill
|
||||||
.values()) {
|
.values()) {
|
||||||
while (this.getAgentMessenger().getStatus(runingAgent.getAgent()) != null) {
|
while (this.getAgentMessenger().status(runingAgent.getAgent()) != null) {
|
||||||
System.out.println("This need agent "
|
System.out.println("This need agent "
|
||||||
+ runingAgent.getAgent().getHostName()
|
+ runingAgent.getAgent().getHostName()
|
||||||
+ " to be killed");
|
+ " to be killed");
|
||||||
|
|
|
@ -84,13 +84,13 @@ public class Test_AgentMessenger extends TestBase_MakeUpTestPlan {
|
||||||
.submitScenrioWithParams(agent, model.getRunId(), paramFiles,
|
.submitScenrioWithParams(agent, model.getRunId(), paramFiles,
|
||||||
inputModel, scheduleModel, new Date());
|
inputModel, scheduleModel, new Date());
|
||||||
assertEquals(model.getRunId(), modelAfter.getRunId());
|
assertEquals(model.getRunId(), modelAfter.getRunId());
|
||||||
model = this.getAgentMessenger().runWithParams(agent, model.getRunId());
|
model = this.getAgentMessenger().run(agent, model.getRunId());
|
||||||
assertNotNull(model);
|
assertNotNull(model);
|
||||||
assertNotNull(model.getRunId());
|
assertNotNull(model.getRunId());
|
||||||
System.out.println(model.getRunId());
|
System.out.println(model.getRunId());
|
||||||
// Thread.sleep(2000);
|
// Thread.sleep(2000);
|
||||||
TestBriefStatusModel briefModel = this.getAgentMessenger()
|
TestBriefStatusModel briefModel = this.getAgentMessenger()
|
||||||
.scriptBriefAll(agent, model.getRunId());
|
.brief(agent, model.getRunId());
|
||||||
assertNotNull(briefModel);
|
assertNotNull(briefModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class Test_MonitorResultService extends TestBase_MakeUpTestPlan {
|
||||||
public void testLoadMemoryResults() throws InterruptedException,
|
public void testLoadMemoryResults() throws InterruptedException,
|
||||||
Bench4QException {
|
Bench4QException {
|
||||||
assertNotNull(this.getAgentMessenger()
|
assertNotNull(this.getAgentMessenger()
|
||||||
.getStatus(
|
.status(
|
||||||
Agent.createAgentWithoutId(Test_AGENT_HOSTNAME,
|
Agent.createAgentWithoutId(Test_AGENT_HOSTNAME,
|
||||||
TEST_PORT, 500)));
|
TEST_PORT, 500)));
|
||||||
User user = this.getUserRepository().getUser("admin");
|
User user = this.getUserRepository().getUser("admin");
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class Test_TestPlanEngine extends TestBase_MakeUpTestPlan {
|
||||||
@Test
|
@Test
|
||||||
public void testRunTestPlanRightly() throws InterruptedException {
|
public void testRunTestPlanRightly() throws InterruptedException {
|
||||||
assertNotNull(this.getAgentMessenger()
|
assertNotNull(this.getAgentMessenger()
|
||||||
.getStatus(
|
.status(
|
||||||
Agent.createAgentWithoutId(Test_AGENT_HOSTNAME,
|
Agent.createAgentWithoutId(Test_AGENT_HOSTNAME,
|
||||||
TEST_PORT, 500)));
|
TEST_PORT, 500)));
|
||||||
User user = this.getUserRepository().getUser("admin");
|
User user = this.getUserRepository().getUser("admin");
|
||||||
|
|
|
@ -42,12 +42,12 @@ public class Mock_AgentMessenger implements AgentMessenger {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RunScenarioResultModel runWithParams(Agent agent, UUID agentRunId) {
|
public RunScenarioResultModel run(Agent agent, UUID agentRunId) {
|
||||||
return new RunScenarioResultModel(this.testId);
|
return new RunScenarioResultModel(this.testId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TestBriefStatusModel scriptBriefAll(Agent agent, UUID runId) {
|
public TestBriefStatusModel brief(Agent agent, UUID runId) {
|
||||||
if (isDead(agent)) {
|
if (isDead(agent)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class Mock_AgentMessenger implements AgentMessenger {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ServerStatusModel getStatus(Agent agent) {
|
public ServerStatusModel status(Agent agent) {
|
||||||
ServerStatusModel result = new ServerStatusModel();
|
ServerStatusModel result = new ServerStatusModel();
|
||||||
if (agent.getCurrentEnumStatus() == AgentStatus.InIdle) {
|
if (agent.getCurrentEnumStatus() == AgentStatus.InIdle) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -90,7 +90,7 @@ public class Mock_AgentMessenger implements AgentMessenger {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Future<ServerStatusModel> getStatusAsync(Agent agent) {
|
public Future<ServerStatusModel> statusAsync(Agent agent) {
|
||||||
return new AsyncResult<ServerStatusModel>(getStatus(agent));
|
return new AsyncResult<ServerStatusModel>(status(agent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue