parent
b288d92336
commit
fd82b54d4e
|
@ -61,7 +61,7 @@ public class TestController {
|
||||||
@RequestMapping(value = "/bookTest/{poolSize}", method = {
|
@RequestMapping(value = "/bookTest/{poolSize}", method = {
|
||||||
RequestMethod.GET, RequestMethod.POST })
|
RequestMethod.GET, RequestMethod.POST })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RunScenarioResultModel bookTest(@PathVariable int poolSize) {
|
public RunScenarioResultModel bookTest(@PathVariable int poolSize, @RequestParam long startTime) {
|
||||||
try {
|
try {
|
||||||
UUID runId = UUID.randomUUID();
|
UUID runId = UUID.randomUUID();
|
||||||
this.getScenarioEngine().addRunningTestWithoutScenario(runId,
|
this.getScenarioEngine().addRunningTestWithoutScenario(runId,
|
||||||
|
|
|
@ -130,8 +130,9 @@ public class ScenarioContext implements Observer {
|
||||||
this.getExecutor().getActiveCount());
|
this.getExecutor().getActiveCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initTasks() {
|
public void initTasks(int currentLoad) {
|
||||||
for (int i = 0; i < this.getExecutor().getCorePoolSize(); i++) {
|
this.updatePopulation(currentLoad);
|
||||||
|
for (int i = 0; i < currentLoad; i++) {
|
||||||
addTask();
|
addTask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
|
||||||
@Component
|
@Component
|
||||||
public class ScenarioEngine implements Observer {
|
public class ScenarioEngine implements Observer {
|
||||||
private Map<UUID, ScenarioContext> runningTests;
|
private Map<UUID, ScenarioContext> runningTests;
|
||||||
private Logger logger = Logger.getLogger(ScenarioEngine.class);
|
private final Logger logger = Logger.getLogger(ScenarioEngine.class);
|
||||||
private PluginManager pluginManager;
|
private PluginManager pluginManager;
|
||||||
|
|
||||||
public ScenarioEngine() {
|
public ScenarioEngine() {
|
||||||
|
@ -72,9 +72,20 @@ public class ScenarioEngine implements Observer{
|
||||||
logger.error("The context required is null");
|
logger.error("The context required is null");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
scenarioContext.initTasks();
|
try {
|
||||||
new Supervisor(scenarioContext).start();;
|
int currentLoad = scenarioContext
|
||||||
|
.getScenario()
|
||||||
|
.getSchedule()
|
||||||
|
.loadFor(
|
||||||
|
System.currentTimeMillis()
|
||||||
|
- scenarioContext.getStartDate().getTime());
|
||||||
|
scenarioContext.initTasks(currentLoad);
|
||||||
|
new Supervisor(scenarioContext).start();
|
||||||
return true;
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.logger.info(e, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,5 +97,4 @@ public class ScenarioEngine implements Observer{
|
||||||
this.getRunningTests().remove(testId);
|
this.getRunningTests().remove(testId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,19 @@ public class Schedule extends Observable {
|
||||||
throw new Bench4QRunTimeException("Should not come to this place");
|
throw new Bench4QRunTimeException("Should not come to this place");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param relativeTime, relativeTime from beginDate
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int loadFor(long relativeTime){
|
||||||
|
Segment segment = getSegment(relativeTime);
|
||||||
|
if (segment == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
return segment.loadFor(relativeTime);
|
||||||
|
}
|
||||||
|
|
||||||
public static class Segment {
|
public static class Segment {
|
||||||
private final Point start;
|
private final Point start;
|
||||||
private final Point end;
|
private final Point end;
|
||||||
|
|
Loading…
Reference in New Issue