test can be cancelled or cleaned up.

This commit is contained in:
Zhen Tang 2013-06-28 22:40:20 +08:00
parent cc8bc43f27
commit baa00c1054
5 changed files with 62 additions and 6 deletions

View File

@ -1,5 +0,0 @@
package org.bench4q.agent.api;
public class AgentController {
}

View File

@ -12,7 +12,6 @@ public class HomeController {
@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST })
@ResponseBody
public String index() {
return "It works!";
}
}

View File

@ -4,9 +4,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bench4q.agent.api.model.CleanTestResultModel;
import org.bench4q.agent.api.model.ParameterModel;
import org.bench4q.agent.api.model.RunScenarioModel;
import org.bench4q.agent.api.model.RunScenarioResultModel;
import org.bench4q.agent.api.model.StopTestModel;
import org.bench4q.agent.api.model.TestBriefStatusModel;
import org.bench4q.agent.api.model.TestDetailModel;
import org.bench4q.agent.api.model.TestDetailStatusModel;
@ -178,4 +180,26 @@ public class TestController {
testBriefStatusModel.setTotalCount(scenarioContext.getTotalCount());
return testBriefStatusModel;
}
@RequestMapping(value = "/stop/{runId}", method = RequestMethod.GET)
@ResponseBody
public StopTestModel stop(@PathVariable UUID runId) {
this.getScenarioEngine().getRunningTests().get(runId)
.getExecutorService().shutdownNow();
StopTestModel stopTestModel = new StopTestModel();
stopTestModel.setSuccess(true);
return stopTestModel;
}
@RequestMapping(value = "/clean/{runId}", method = RequestMethod.GET)
@ResponseBody
public CleanTestResultModel clean(@PathVariable UUID runId) {
this.getScenarioEngine().getRunningTests().get(runId)
.getExecutorService().shutdownNow();
this.getScenarioEngine().getRunningTests().remove(runId);
System.gc();
CleanTestResultModel cleanTestResultModel = new CleanTestResultModel();
cleanTestResultModel.setSuccess(true);
return cleanTestResultModel;
}
}

View File

@ -0,0 +1,19 @@
package org.bench4q.agent.api.model;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "cleanTestResult")
public class CleanTestResultModel {
private boolean success;
@XmlElement
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
}

View File

@ -0,0 +1,19 @@
package org.bench4q.agent.api.model;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "stopTest")
public class StopTestModel {
private boolean success;
@XmlElement
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
}