add pool size setting now.
This commit is contained in:
parent
f5f0455f3c
commit
f4f22a47d4
|
@ -94,7 +94,8 @@ public class TestController {
|
||||||
RunScenarioResultModel runScenarioResultModel = new RunScenarioResultModel();
|
RunScenarioResultModel runScenarioResultModel = new RunScenarioResultModel();
|
||||||
runScenarioResultModel.setRunId(UUID.randomUUID());
|
runScenarioResultModel.setRunId(UUID.randomUUID());
|
||||||
this.getScenarioEngine().runScenario(runScenarioResultModel.getRunId(),
|
this.getScenarioEngine().runScenario(runScenarioResultModel.getRunId(),
|
||||||
scenario, runScenarioModel.getTotalCount());
|
scenario, runScenarioModel.getPoolSize(),
|
||||||
|
runScenarioModel.getTotalCount());
|
||||||
return runScenarioResultModel;
|
return runScenarioResultModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,20 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
@XmlRootElement(name = "runScenario")
|
@XmlRootElement(name = "runScenario")
|
||||||
public class RunScenarioModel {
|
public class RunScenarioModel {
|
||||||
|
private int poolSize;
|
||||||
private int totalCount;
|
private int totalCount;
|
||||||
private List<UsePluginModel> usePlugins;
|
private List<UsePluginModel> usePlugins;
|
||||||
private List<UserBehaviorModel> userBehaviors;
|
private List<UserBehaviorModel> userBehaviors;
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
public int getPoolSize() {
|
||||||
|
return poolSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPoolSize(int poolSize) {
|
||||||
|
this.poolSize = poolSize;
|
||||||
|
}
|
||||||
|
|
||||||
@XmlElement
|
@XmlElement
|
||||||
public int getTotalCount() {
|
public int getTotalCount() {
|
||||||
return totalCount;
|
return totalCount;
|
||||||
|
|
|
@ -7,12 +7,21 @@ import java.util.concurrent.ExecutorService;
|
||||||
import org.bench4q.agent.plugin.BehaviorResult;
|
import org.bench4q.agent.plugin.BehaviorResult;
|
||||||
|
|
||||||
public class ScenarioContext {
|
public class ScenarioContext {
|
||||||
|
private int poolSize;
|
||||||
private int totalCount;
|
private int totalCount;
|
||||||
private Date startDate;
|
private Date startDate;
|
||||||
private ExecutorService executorService;
|
private ExecutorService executorService;
|
||||||
private Scenario scenario;
|
private Scenario scenario;
|
||||||
private List<BehaviorResult> results;
|
private List<BehaviorResult> results;
|
||||||
|
|
||||||
|
public int getPoolSize() {
|
||||||
|
return poolSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPoolSize(int poolSize) {
|
||||||
|
this.poolSize = poolSize;
|
||||||
|
}
|
||||||
|
|
||||||
public int getTotalCount() {
|
public int getTotalCount() {
|
||||||
return totalCount;
|
return totalCount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,15 +46,17 @@ public class ScenarioEngine {
|
||||||
return this.getRunningTests().get(uuid);
|
return this.getRunningTests().get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runScenario(UUID runId, final Scenario scenario, int totalCount) {
|
public void runScenario(UUID runId, final Scenario scenario, int poolSize,
|
||||||
|
int totalCount) {
|
||||||
try {
|
try {
|
||||||
ScenarioContext scenarioContext = new ScenarioContext();
|
ScenarioContext scenarioContext = new ScenarioContext();
|
||||||
scenarioContext.setScenario(scenario);
|
scenarioContext.setScenario(scenario);
|
||||||
scenarioContext.setTotalCount(totalCount
|
scenarioContext.setTotalCount(totalCount
|
||||||
* scenario.getUserBehaviors().length);
|
* scenario.getUserBehaviors().length);
|
||||||
|
scenarioContext.setPoolSize(poolSize);
|
||||||
scenarioContext.setStartDate(new Date(System.currentTimeMillis()));
|
scenarioContext.setStartDate(new Date(System.currentTimeMillis()));
|
||||||
ExecutorService executorService = Executors
|
ExecutorService executorService = Executors
|
||||||
.newFixedThreadPool(totalCount);
|
.newFixedThreadPool(poolSize);
|
||||||
scenarioContext.setExecutorService(executorService);
|
scenarioContext.setExecutorService(executorService);
|
||||||
int i;
|
int i;
|
||||||
final List<BehaviorResult> ret = Collections
|
final List<BehaviorResult> ret = Collections
|
||||||
|
|
|
@ -23,7 +23,8 @@ public class RunScenarioTest {
|
||||||
public void testRunScenario() {
|
public void testRunScenario() {
|
||||||
try {
|
try {
|
||||||
RunScenarioModel runScenarioModel = new RunScenarioModel();
|
RunScenarioModel runScenarioModel = new RunScenarioModel();
|
||||||
runScenarioModel.setTotalCount(300);
|
runScenarioModel.setTotalCount(30000);
|
||||||
|
runScenarioModel.setPoolSize(300);
|
||||||
runScenarioModel.setUsePlugins(new ArrayList<UsePluginModel>());
|
runScenarioModel.setUsePlugins(new ArrayList<UsePluginModel>());
|
||||||
runScenarioModel
|
runScenarioModel
|
||||||
.setUserBehaviors(new ArrayList<UserBehaviorModel>());
|
.setUserBehaviors(new ArrayList<UserBehaviorModel>());
|
||||||
|
@ -85,7 +86,8 @@ public class RunScenarioTest {
|
||||||
httpURLConnection.setDoInput(true);
|
httpURLConnection.setDoInput(true);
|
||||||
httpURLConnection.setUseCaches(false);
|
httpURLConnection.setUseCaches(false);
|
||||||
httpURLConnection.setRequestMethod("POST");
|
httpURLConnection.setRequestMethod("POST");
|
||||||
httpURLConnection.setRequestProperty("Content-Type", "application/xml");
|
httpURLConnection.setRequestProperty("Content-Type",
|
||||||
|
"application/xml");
|
||||||
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
|
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
|
||||||
httpURLConnection.getOutputStream());
|
httpURLConnection.getOutputStream());
|
||||||
outputStreamWriter.write(content);
|
outputStreamWriter.write(content);
|
||||||
|
|
Loading…
Reference in New Issue