parent
9af631ad1c
commit
3cb3768da1
|
@ -3,6 +3,7 @@ package org.bench4q.master.domain;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.bench4q.master.domain.entity.Agent;
|
||||
import org.bench4q.share.models.agent.TestBriefStatusModel;
|
||||
|
||||
public interface RunningAgentInterface {
|
||||
public Agent getAgent();
|
||||
|
@ -19,6 +20,8 @@ public interface RunningAgentInterface {
|
|||
|
||||
public void substituteOnBoard();
|
||||
|
||||
public TestBriefStatusModel briefAll();
|
||||
|
||||
public boolean stop();
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.bench4q.share.helper.MarshalHelper;
|
|||
import org.bench4q.share.models.agent.RunScenarioModel;
|
||||
import org.bench4q.share.models.agent.RunScenarioResultModel;
|
||||
import org.bench4q.share.models.agent.StopTestModel;
|
||||
import org.bench4q.share.models.agent.TestBriefStatusModel;
|
||||
|
||||
@Entity
|
||||
@Table(name = "runningAgent")
|
||||
|
@ -164,10 +165,6 @@ public class RunningAgentDB implements RunningAgentInterface {
|
|||
return runScenarioResultModel != null;
|
||||
}
|
||||
|
||||
public void briefAll() {
|
||||
// this.getAgentMessenger().
|
||||
}
|
||||
|
||||
public boolean stop() {
|
||||
StopTestModel result = this.getAgentMessenger().stop(getAgent(),
|
||||
getAgentRunId());
|
||||
|
@ -180,4 +177,10 @@ public class RunningAgentDB implements RunningAgentInterface {
|
|||
this.run();
|
||||
this.setHasSubstitute(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestBriefStatusModel briefAll() {
|
||||
return this.getAgentMessenger().scriptBriefAll(this.getAgent(),
|
||||
this.getAgentRunId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,10 +33,8 @@ import org.bench4q.master.domain.valueobject.schedulscript.WarmUpOverTask;
|
|||
import org.bench4q.master.domain.valueobject.transaction.Transaction;
|
||||
import org.bench4q.master.domain.valueobject.transaction.TransactionFactory;
|
||||
import org.bench4q.master.exception.ExceptionLog;
|
||||
import org.bench4q.master.infrastructure.communication.impl.AgentMessengerImpl;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.agent.RunScenarioModel;
|
||||
import org.bench4q.share.models.agent.StopTestModel;
|
||||
import org.bench4q.share.models.master.statistics.ScriptResultModel;
|
||||
|
||||
@Entity
|
||||
|
@ -52,7 +50,6 @@ public class TestPlanScript implements RunningScriptInterface {
|
|||
private boolean finish;
|
||||
|
||||
private TestPlanFactory testPlanFactory;
|
||||
private AgentMessengerImpl agentMessenger;
|
||||
private TransactionFactory transactionFactory;
|
||||
private RunningScriptSampler sampler;
|
||||
private AgentService agentService;
|
||||
|
@ -183,15 +180,6 @@ public class TestPlanScript implements RunningScriptInterface {
|
|||
this.sampler = sampler;
|
||||
}
|
||||
|
||||
@Transient
|
||||
private AgentMessengerImpl getAgentMessenger() {
|
||||
return agentMessenger;
|
||||
}
|
||||
|
||||
public void setAgentMessenger(AgentMessengerImpl agentMessenger) {
|
||||
this.agentMessenger = agentMessenger;
|
||||
}
|
||||
|
||||
@Transient
|
||||
private AgentService getAgentService() {
|
||||
return agentService;
|
||||
|
@ -248,8 +236,8 @@ public class TestPlanScript implements RunningScriptInterface {
|
|||
for (RunningAgentInterface runningAgent : agentsAfterDistribute) {
|
||||
this.getRunningAgentsDB().add((RunningAgentDB) runningAgent);
|
||||
}
|
||||
this.setSampler(new RunningScriptSampler(this.getAgentMessenger(),
|
||||
Collections.unmodifiableCollection(this.getRunningAgentsDB())));
|
||||
this.setSampler(new RunningScriptSampler(Collections
|
||||
.unmodifiableCollection(this.getRunningAgentsDB())));
|
||||
}
|
||||
|
||||
public List<TestPlanScriptResult> doAfterRun() {
|
||||
|
@ -294,9 +282,7 @@ public class TestPlanScript implements RunningScriptInterface {
|
|||
if (runningAgent == null) {
|
||||
continue;
|
||||
}
|
||||
StopTestModel resultModel = this.getAgentMessenger().stop(
|
||||
runningAgent.getAgent(), runningAgent.getAgentRunId());
|
||||
if (resultModel == null || !resultModel.isSuccess()) {
|
||||
if (!runningAgent.stop()) {
|
||||
logger.error("can't stop the agent with hostName"
|
||||
+ runningAgent.getAgent().getHostName()
|
||||
+ "and currentRunId is " + runningAgent.getAgentRunId());
|
||||
|
|
|
@ -24,4 +24,8 @@ public class RunningAgentFactory {
|
|||
runningAgent.setAgentMessenger(this.agentMessenger);
|
||||
return runningAgent;
|
||||
}
|
||||
|
||||
public void convertToDomain(RunningAgentDB fromReop) {
|
||||
fromReop.setAgentMessenger(this.agentMessenger);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.bench4q.master.domain.service.TestResultSave;
|
|||
import org.bench4q.master.domain.valueobject.transaction.TransactionFactory;
|
||||
import org.bench4q.master.exception.ExceptionLog;
|
||||
import org.bench4q.master.exception.ExceptionUtils.IllegalParameterException;
|
||||
import org.bench4q.master.infrastructure.communication.impl.AgentMessengerImpl;
|
||||
import org.bench4q.share.enums.master.TestPlanStatus;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.MonitorModel;
|
||||
|
@ -43,36 +42,27 @@ import org.springframework.stereotype.Component;
|
|||
public class TestPlanFactory {
|
||||
private Logger logger = Logger.getLogger(TestPlanFactory.class);
|
||||
private ScriptService scriptService;
|
||||
private AgentMessengerImpl agentMessenger;
|
||||
private AgentService agentService;
|
||||
private TestResultSave testResultSave;
|
||||
private TestPlanRepository testPlanRepository;
|
||||
private TransactionFactory transactionFactory;
|
||||
private RunningAgentFactory runningAgentFactory;
|
||||
|
||||
public AgentMessengerImpl getAgentMessenger() {
|
||||
return agentMessenger;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setAgentMessenger(AgentMessengerImpl agentMessenger) {
|
||||
this.agentMessenger = agentMessenger;
|
||||
}
|
||||
|
||||
public AgentService getAgentService() {
|
||||
private AgentService getAgentService() {
|
||||
return agentService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setAgentService(AgentService agentService) {
|
||||
private void setAgentService(AgentService agentService) {
|
||||
this.agentService = agentService;
|
||||
}
|
||||
|
||||
public TestResultSave getTestResultSave() {
|
||||
private TestResultSave getTestResultSave() {
|
||||
return testResultSave;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setTestResultSave(TestResultSave testResultSave) {
|
||||
private void setTestResultSave(TestResultSave testResultSave) {
|
||||
this.testResultSave = testResultSave;
|
||||
}
|
||||
|
||||
|
@ -103,6 +93,15 @@ public class TestPlanFactory {
|
|||
this.transactionFactory = transactionFactory;
|
||||
}
|
||||
|
||||
private RunningAgentFactory getRunningAgentFactory() {
|
||||
return runningAgentFactory;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setRunningAgentFactory(RunningAgentFactory runningAgentFactory) {
|
||||
this.runningAgentFactory = runningAgentFactory;
|
||||
}
|
||||
|
||||
public TestPlan createATestPlanWithoutIdentity(TestPlanModel testPlanModel,
|
||||
User user, UUID runId) throws IllegalParameterException {
|
||||
Logger.getLogger(TestPlanFactory.class).info(
|
||||
|
@ -247,7 +246,7 @@ public class TestPlanFactory {
|
|||
if (testPlanInRepo == null) {
|
||||
return null;
|
||||
}
|
||||
testPlanInRepo.setTestResultSave(testResultSave);
|
||||
testPlanInRepo.setTestResultSave(this.getTestResultSave());
|
||||
testPlanInRepo.setRepository(this.getTestPlanRepository());
|
||||
for (TestPlanScript testPlanScript : testPlanInRepo
|
||||
.getTestPlanScripts()) {
|
||||
|
@ -265,11 +264,10 @@ public class TestPlanFactory {
|
|||
|
||||
private void converToDomain(TestPlanScript testPlanScript) {
|
||||
testPlanScript.setTestPlanFactory(this);
|
||||
testPlanScript.setAgentMessenger(this.getAgentMessenger());
|
||||
testPlanScript.setAgentService(this.getAgentService());
|
||||
testPlanScript.setTransactionFactory(this.getTransactionFactory());
|
||||
for (RunningAgentDB runningAgent : testPlanScript.getRunningAgentsDB()) {
|
||||
runningAgent.setAgentMessenger(this.getAgentMessenger());
|
||||
this.getRunningAgentFactory().convertToDomain(runningAgent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@ import java.util.List;
|
|||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.bench4q.master.domain.RunningAgentInterface;
|
||||
import org.bench4q.master.helper.ApplicationContextHelper;
|
||||
import org.bench4q.master.infrastructure.communication.impl.AgentMessengerImpl;
|
||||
import org.bench4q.share.models.agent.TestBriefStatusModel;
|
||||
import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel;
|
||||
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
|
||||
|
@ -23,7 +21,6 @@ import org.bench4q.share.models.master.statistics.ScriptResultModel;
|
|||
public class RunningScriptSampler {
|
||||
private List<DataStatistics> dataStatisticsList;
|
||||
private List<RunningAgentInterface> runningAgents;
|
||||
private AgentMessengerImpl agentMessenger;
|
||||
|
||||
private List<DataStatistics> getDataStatisticsList() {
|
||||
return dataStatisticsList;
|
||||
|
@ -41,25 +38,15 @@ public class RunningScriptSampler {
|
|||
this.runningAgents = runningAgents;
|
||||
}
|
||||
|
||||
private AgentMessengerImpl getAgentMessenger() {
|
||||
return agentMessenger;
|
||||
}
|
||||
|
||||
private void setAgentMessenger(AgentMessengerImpl agentMessenger) {
|
||||
this.agentMessenger = agentMessenger;
|
||||
}
|
||||
|
||||
private RunningScriptSampler() {
|
||||
this.setDataStatisticsList(new ArrayList<DataStatistics>());
|
||||
this.getDataStatisticsList().add(new ScriptBriefStatistics());
|
||||
this.getDataStatisticsList().add(new BehaviorsBriefStatistics());
|
||||
this.getDataStatisticsList().add(new PagesBriefStatistics());
|
||||
this.setAgentMessenger(ApplicationContextHelper.getContext().getBean(
|
||||
AgentMessengerImpl.class));
|
||||
this.setRunningAgents(new LinkedList<RunningAgentInterface>());
|
||||
}
|
||||
|
||||
public RunningScriptSampler(AgentMessengerImpl agentMessenger,
|
||||
public RunningScriptSampler(
|
||||
Collection<? extends RunningAgentInterface> runningAgents) {
|
||||
this();
|
||||
this.getRunningAgents().addAll(runningAgents);
|
||||
|
@ -70,10 +57,7 @@ public class RunningScriptSampler {
|
|||
if (runningAgent.isBreakDown()) {
|
||||
continue;
|
||||
}
|
||||
TestBriefStatusModel testBriefStatusModel = this
|
||||
.getAgentMessenger().scriptBriefAll(
|
||||
runningAgent.getAgent(),
|
||||
runningAgent.getAgentRunId());
|
||||
TestBriefStatusModel testBriefStatusModel = runningAgent.briefAll();
|
||||
addScriptResultModelStatistics(testBriefStatusModel);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ public class Test_RunningScriptSampler extends TestBase_MakeUpTestPlan {
|
|||
TestPlan testPlanInRunning = fetchTestPlan();
|
||||
TestPlanScript testPlanScript = testPlanInRunning
|
||||
.extracSpecifiedScript(getScriptId());
|
||||
this.setRunningScriptSampler(new RunningScriptSampler(this
|
||||
.getAgentMessenger(), testPlanScript.getRunningAgentsDB()));
|
||||
this.setRunningScriptSampler(new RunningScriptSampler(testPlanScript
|
||||
.getRunningAgentsDB()));
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
Loading…
Reference in New Issue