diff --git a/src/main/java/org/bench4q/master/domain/entity/TestPlan.java b/src/main/java/org/bench4q/master/domain/entity/TestPlan.java index b8cffc72..4355f493 100644 --- a/src/main/java/org/bench4q/master/domain/entity/TestPlan.java +++ b/src/main/java/org/bench4q/master/domain/entity/TestPlan.java @@ -27,7 +27,7 @@ public class TestPlan implements IAggregate { private String name; private int sampleCycleInSeconds; private Date createDateTime; - private Date latestRunningTime; + private Date lastRunningTime; private User user; private String testPlanRunId; private String currentStatus; @@ -84,13 +84,13 @@ public class TestPlan implements IAggregate { this.createDateTime = createDateTime; } - @Column(name = "latestRunningTime", nullable = false) - public Date getLatestRunningTime() { - return latestRunningTime; + @Column(name = "lastRunningTime", nullable = false) + public Date getLastRunningTime() { + return lastRunningTime; } - public void setLatestRunningTime(Date latestRunningTime) { - this.latestRunningTime = latestRunningTime; + public void setLastRunningTime(Date lastRunningTime) { + this.lastRunningTime = lastRunningTime; } @ManyToOne diff --git a/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java b/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java index cd5bb6e3..e5c87a60 100644 --- a/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java +++ b/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java @@ -62,7 +62,7 @@ public class TestPlanFactory { result.setFailTimes(0); result.setName(testPlanModel.getName()); result.setSampleCycleInSeconds(getLargerOneBetweenUserOptionAndMinInSystem(testPlanModel)); - result.setLatestRunningTime(new Date(0)); + result.setLastRunningTime(new Date(0)); result.setTestPlanRunId(runId.toString()); result.setUser(user); Set testPlanScripts = new HashSet(); diff --git a/src/main/java/org/bench4q/master/domain/service/TestPlanEngine.java b/src/main/java/org/bench4q/master/domain/service/TestPlanEngine.java index 2d8fbebe..e0273c03 100644 --- a/src/main/java/org/bench4q/master/domain/service/TestPlanEngine.java +++ b/src/main/java/org/bench4q/master/domain/service/TestPlanEngine.java @@ -100,7 +100,7 @@ public class TestPlanEngine implements TaskCompleteCallback, private void commitInRunning(TestPlan testPlan) { testPlan.setCurrentStatus(TestPlanStatus.InRunning.name()); - testPlan.setLatestRunningTime(new Date()); + testPlan.setLastRunningTime(new Date()); getTestPlanRepository().attachRunningTestPlan(testPlan); getTestPlanRepository().updateEntity(testPlan); } diff --git a/src/main/java/org/bench4q/master/testplan/highavailable/HighAvailablePool.java b/src/main/java/org/bench4q/master/testplan/highavailable/HighAvailablePool.java index c833d8c7..55882a20 100644 --- a/src/main/java/org/bench4q/master/testplan/highavailable/HighAvailablePool.java +++ b/src/main/java/org/bench4q/master/testplan/highavailable/HighAvailablePool.java @@ -125,7 +125,7 @@ public class HighAvailablePool extends CurrentLoadSubject { this.setCurrentAvailableLoad((long) 0); this.setMaxAvailableLoad((long) 0); for (Agent agent : this.agentService.loadAgentPoolFromDB()) { - checkHeartBeat(agent); + checkHeartBeatAndUpdateMaxLoadAndAvailableLoad(agent); } logger.info("Current Available load in pool is " + this.getCurrentAvailableLoad()); @@ -133,7 +133,7 @@ public class HighAvailablePool extends CurrentLoadSubject { + this.getMaxAvailableLoad()); } - public void checkHeartBeat(Agent agent) { + public void checkHeartBeatAndUpdateMaxLoadAndAvailableLoad(Agent agent) { this.getPool().put(agent.getHostName(), agent); ServerStatusModel model = queryAgentStatus(agent); if (model == null) { diff --git a/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/BriefAgentFault.java b/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/BriefAgentFault.java index e116dbc3..a577424b 100644 --- a/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/BriefAgentFault.java +++ b/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/BriefAgentFault.java @@ -48,7 +48,7 @@ public class BriefAgentFault implements FaultTolerance { } synchronized (this.getHaPool().getPool()) { - this.getHaPool().checkHeartBeat(this.getAgent()); + this.getHaPool().checkHeartBeatAndUpdateMaxLoadAndAvailableLoad(this.getAgent()); } } diff --git a/src/main/resources/org/bench4q/master/config/ServerPort.properties b/src/main/resources/org/bench4q/master/config/ServerPort.properties index 547a0a4f..baa4f984 100644 --- a/src/main/resources/org/bench4q/master/config/ServerPort.properties +++ b/src/main/resources/org/bench4q/master/config/ServerPort.properties @@ -1 +1,3 @@ -portToServe=7979 \ No newline at end of file +portToServe=7979 +maxFailTime=10 +minExcuteIntervalInSeconds=600 \ No newline at end of file diff --git a/src/test/java/org/bench4q/master/test/service/Test_TestPlanEngine.java b/src/test/java/org/bench4q/master/test/service/Test_TestPlanEngine.java index dbe4bf67..667842e1 100644 --- a/src/test/java/org/bench4q/master/test/service/Test_TestPlanEngine.java +++ b/src/test/java/org/bench4q/master/test/service/Test_TestPlanEngine.java @@ -59,7 +59,7 @@ public class Test_TestPlanEngine extends TestBase_MakeUpTestPlan { getTestPlanRunIdUuid()); assertEquals(TestPlanStatus.InRunning, TestPlanStatus.valueOf(testPlan.getCurrentStatus())); - assertTrue(testPlan.getLatestRunningTime().after(dateBeforeRun)); + assertTrue(testPlan.getLastRunningTime().after(dateBeforeRun)); assertEquals(TestPlanStatus.InRunning, TestPlanStatus.valueOf(getTestPlanRepository() .getRunningTestPlanBy(getTestPlanRunIdUuid()) @@ -73,14 +73,14 @@ public class Test_TestPlanEngine extends TestBase_MakeUpTestPlan { System.out.println("This need each agent not in running"); User user = this.getUserRepository().getUser("admin"); int scriptId = getUserFirstScript(user); + this.getHaPool().getPool().clear(); this.setTestPlanRunIdUuid(this.getTestPlanEngine().runWith( createATestPlanWithOneScript(scriptId), user)); Thread.sleep(10000); - assertNotEquals( - TestPlanStatus.InRunning, - TestPlanStatus.valueOf(this.getTestPlanRepository() - .getTestPlanBy(getTestPlanRunIdUuid()) - .getCurrentStatus())); + TestPlan testPlan = this.getTestPlanRepository().getTestPlanBy( + getTestPlanRunIdUuid()); + assertNotEquals(TestPlanStatus.InRunning, + TestPlanStatus.valueOf(testPlan.getCurrentStatus())); assertNull(this.getTestPlanRepository().getRunningTestPlanBy( getTestPlanRunIdUuid())); deleteTestPlan();