edit for the information of finishedScenarioCount, to get it for moving

task
This commit is contained in:
coderfengyun 2013-08-16 15:04:16 +08:00
parent 02e2b25ff9
commit c505bc4edf
5 changed files with 20 additions and 20 deletions

View File

@ -1,6 +1,5 @@
package org.bench4q.agent.api; package org.bench4q.agent.api;
import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -57,18 +56,11 @@ public class TestController {
runScenarioModel.getPoolSize(), runScenarioModel.getPoolSize(),
runScenarioModel.getTotalCount()); runScenarioModel.getTotalCount());
RunScenarioResultModel runScenarioResultModel = new RunScenarioResultModel(); RunScenarioResultModel runScenarioResultModel = new RunScenarioResultModel();
runScenarioResultModel.setHostName(this.getLocalIpAdress());
runScenarioResultModel.setRunId(runId); runScenarioResultModel.setRunId(runId);
return runScenarioResultModel; return runScenarioResultModel;
} }
private String getLocalIpAdress() throws UnknownHostException {
InetAddress addr = InetAddress.getLocalHost();
String hostName = addr.getHostAddress().toString();
return hostName;
}
private Scenario extractScenario(RunScenarioModel runScenarioModel) { private Scenario extractScenario(RunScenarioModel runScenarioModel) {
Scenario scenario = new Scenario(); Scenario scenario = new Scenario();
scenario.setUsePlugins(new UsePlugin[runScenarioModel.getUsePlugins() scenario.setUsePlugins(new UsePlugin[runScenarioModel.getUsePlugins()

View File

@ -8,7 +8,6 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "runScenarioResult") @XmlRootElement(name = "runScenarioResult")
public class RunScenarioResultModel { public class RunScenarioResultModel {
private UUID runId; private UUID runId;
private String hostName;
@XmlElement @XmlElement
public UUID getRunId() { public UUID getRunId() {
@ -19,13 +18,4 @@ public class RunScenarioResultModel {
this.runId = runId; this.runId = runId;
} }
@XmlElement
public String getHostName() {
return hostName;
}
public void setHostName(String hostName) {
this.hostName = hostName;
}
} }

View File

@ -13,6 +13,7 @@ public class TestBriefStatusModel {
private int failCount; private int failCount;
private int finishedCount; private int finishedCount;
private int totalCount; private int totalCount;
private int finishedScenarioCount;
private int scenarioBehaviorCount; private int scenarioBehaviorCount;
private double averageResponseTime; private double averageResponseTime;
@ -70,6 +71,15 @@ public class TestBriefStatusModel {
this.totalCount = totalCount; this.totalCount = totalCount;
} }
@XmlElement
public int getFinishedScenarioCount() {
return finishedScenarioCount;
}
public void setFinishedScenarioCount(int finishedScenarioCount) {
this.finishedScenarioCount = finishedScenarioCount;
}
@XmlElement @XmlElement
public double getAverageResponseTime() { public double getAverageResponseTime() {
return averageResponseTime; return averageResponseTime;

View File

@ -4,10 +4,10 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
public class ScenarioContext { public class ScenarioContext {
private int poolSize; private int poolSize;
private int totalCount; private int totalCount;
private int finishedCount;
private Date startDate; private Date startDate;
private ExecutorService executorService; private ExecutorService executorService;
private Scenario scenario; private Scenario scenario;
@ -29,6 +29,14 @@ public class ScenarioContext {
this.totalCount = totalCount; this.totalCount = totalCount;
} }
public int getFinishedCount() {
return finishedCount;
}
public void setFinishedCount(int finishedCount) {
this.finishedCount = finishedCount;
}
public Date getStartDate() { public Date getStartDate() {
return startDate; return startDate;
} }
@ -60,5 +68,4 @@ public class ScenarioContext {
public void setResults(List<BehaviorResult> results) { public void setResults(List<BehaviorResult> results) {
this.results = results; this.results = results;
} }
} }

View File

@ -74,6 +74,7 @@ public class ScenarioEngine {
} }
}; };
for (i = 0; i < totalCount; i++) { for (i = 0; i < totalCount; i++) {
scenarioContext.setFinishedCount(i - 1);
executorService.execute(runnable); executorService.execute(runnable);
} }
executorService.shutdown(); executorService.shutdown();