refactor
This commit is contained in:
coderfengyun 2014-04-22 09:31:29 +08:00
parent 92b1f36356
commit dc45262df6
11 changed files with 22 additions and 30 deletions

View File

@ -8,8 +8,8 @@ import javax.persistence.Id;
import javax.persistence.Table;
import org.bench4q.master.domain.service.AgentService;
import org.bench4q.master.domain.transaction.exception.AgentRunException;
import org.bench4q.master.domain.transaction.impl.AgentDistribute;
import org.bench4q.master.domain.valueobject.transaction.exception.AgentRunException;
import org.bench4q.master.domain.valueobject.transaction.impl.AgentDistribute;
import org.bench4q.share.models.agent.RunScenarioModel;
@Entity
@ -98,7 +98,6 @@ public class Agent {
agentDistribute.rollBack();
return false;
}
}
}

View File

@ -1,14 +1,15 @@
package org.bench4q.master.domain.valueobject;
import java.util.List;
import org.apache.log4j.Logger;
import org.bench4q.master.domain.RunningAgentInterface;
import org.bench4q.master.domain.RunningScriptInterface;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.entity.TestPlanScript;
import org.bench4q.master.domain.repository.TestPlanRepository;
import org.bench4q.master.domain.transaction.Transaction;
import org.bench4q.master.domain.transaction.TransactionFactory;
import org.bench4q.master.domain.valueobject.transaction.Transaction;
import org.bench4q.master.domain.valueobject.transaction.TransactionFactory;
import org.bench4q.master.infrastructure.highavailable.HighAvailablePool;
import org.bench4q.share.enums.master.TestPlanStatus;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,4 +1,4 @@
package org.bench4q.master.domain.transaction;
package org.bench4q.master.domain.valueobject.transaction;
public interface Transaction {
public Object execute() throws Exception;

View File

@ -1,8 +1,8 @@
package org.bench4q.master.domain.transaction;
package org.bench4q.master.domain.valueobject.transaction;
import org.bench4q.master.domain.RunningScriptInterface;
import org.bench4q.master.domain.transaction.impl.ScriptDistribute;
import org.bench4q.master.domain.transaction.impl.TestPlanDistribute;
import org.bench4q.master.domain.valueobject.transaction.impl.ScriptDistribute;
import org.bench4q.master.domain.valueobject.transaction.impl.TestPlanDistribute;
public class TransactionFactory {
public static Transaction buildScriptTransaction(

View File

@ -1,4 +1,4 @@
package org.bench4q.master.domain.transaction.exception;
package org.bench4q.master.domain.valueobject.transaction.exception;
public class AgentRunException extends Exception {

View File

@ -1,4 +1,4 @@
package org.bench4q.master.domain.transaction.exception;
package org.bench4q.master.domain.valueobject.transaction.exception;
public class ScriptLoadDistributeException extends Exception {
private static final long serialVersionUID = -5230579598325900610L;

View File

@ -1,12 +1,12 @@
package org.bench4q.master.domain.transaction.impl;
package org.bench4q.master.domain.valueobject.transaction.impl;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.Agent;
import org.bench4q.master.domain.service.AgentService;
import org.bench4q.master.domain.transaction.Transaction;
import org.bench4q.master.domain.transaction.exception.AgentRunException;
import org.bench4q.master.domain.valueobject.transaction.Transaction;
import org.bench4q.master.domain.valueobject.transaction.exception.AgentRunException;
import org.bench4q.master.exception.ExceptionLog;
import org.bench4q.master.helper.ApplicationContextHelper;
import org.bench4q.master.infrastructure.communication.AgentMessenger;

View File

@ -1,4 +1,4 @@
package org.bench4q.master.domain.transaction.impl;
package org.bench4q.master.domain.valueobject.transaction.impl;
import org.bench4q.master.domain.RunningScriptInterface;

View File

@ -1,4 +1,4 @@
package org.bench4q.master.domain.transaction.impl;
package org.bench4q.master.domain.valueobject.transaction.impl;
import java.util.ArrayList;
import java.util.List;
@ -12,9 +12,8 @@ import org.bench4q.master.domain.RunningScriptInterface;
import org.bench4q.master.domain.RunningAgentInterface.AbstractRunningAgent;
import org.bench4q.master.domain.entity.Agent;
import org.bench4q.master.domain.service.AgentService;
import org.bench4q.master.domain.transaction.Transaction;
import org.bench4q.master.domain.transaction.exception.AgentRunException;
import org.bench4q.master.domain.transaction.exception.ScriptLoadDistributeException;
import org.bench4q.master.domain.valueobject.transaction.Transaction;
import org.bench4q.master.domain.valueobject.transaction.exception.ScriptLoadDistributeException;
import org.bench4q.master.exception.ExceptionLog;
import org.bench4q.master.helper.ApplicationContextHelper;
import org.bench4q.master.infrastructure.communication.AgentMessenger;
@ -158,14 +157,7 @@ public abstract class ScriptLoadBase implements Transaction {
}
loadForRunCurrent = getMin(totalRequireLoad, agent.getRemainLoad());
runScenarioModel.setPoolSize(loadForRunCurrent);
AgentDistribute agentTransaction = new AgentDistribute(
agent.getHostName(), agent.getPort(), runScenarioModel);
try {
runScenarioResultModel = (RunScenarioResultModel) agentTransaction
.execute();
} catch (AgentRunException e) {
logger.info(ExceptionLog.getStackTrace(e));
agentTransaction.rollBack();
if (!agent.runWithouParams(runScenarioModel)) {
continue;
}
agent.setCurrentStatus(AgentService.AGENT_STATUS_InRun);

View File

@ -1,6 +1,6 @@
package org.bench4q.master.domain.transaction.impl;
package org.bench4q.master.domain.valueobject.transaction.impl;
import org.bench4q.master.domain.transaction.Transaction;
import org.bench4q.master.domain.valueobject.transaction.Transaction;
public class TestPlanDistribute implements Transaction {

View File

@ -8,7 +8,7 @@ import java.util.UUID;
import org.bench4q.master.domain.RunningAgentInterface;
import org.bench4q.master.domain.entity.Agent;
import org.bench4q.master.domain.entity.TestPlanScript;
import org.bench4q.master.domain.transaction.impl.ScriptDistribute;
import org.bench4q.master.domain.valueobject.transaction.impl.ScriptDistribute;
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
import org.junit.After;
import org.junit.Before;