From 3c25415a9a2f681f07530925a626088d624d9186 Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Tue, 9 Sep 2014 17:44:44 +0800 Subject: [PATCH] refactor refactor --- .../org/bench4q/master/domain/RunningScriptInterface.java | 2 +- .../main/java/org/bench4q/master/domain/entity/TestPlan.java | 2 +- .../org/bench4q/master/domain/entity/TestPlanScript.java | 2 +- .../org/bench4q/master/integrated/Test_TestResultSave.java | 2 +- .../share/models/agent/scriptrecord/ScheduleModel.java | 5 ++--- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/RunningScriptInterface.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/RunningScriptInterface.java index 7b5fa1a9..9f338c1b 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/RunningScriptInterface.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/RunningScriptInterface.java @@ -24,7 +24,7 @@ public interface RunningScriptInterface { public boolean stop(); - public List doAfterRun(Date sampleTime); + public List sample(Date sampleTime); public Date getStartTime(); diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlan.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlan.java index 7838c4a8..70fbf3f0 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlan.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlan.java @@ -285,7 +285,7 @@ public class TestPlan implements IAggregate { List resultList = new LinkedList(); for (TestPlanScript testPlanScript : getTestPlanScripts()) { List testPlanScriptResults = testPlanScript - .doAfterRun(sampleTime); + .sample(sampleTime); if (testPlanScriptResults != null) resultList.addAll(testPlanScriptResults); } diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlanScript.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlanScript.java index 7770f532..49ff0efb 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlanScript.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlanScript.java @@ -220,7 +220,7 @@ public class TestPlanScript implements RunningScriptInterface { .unmodifiableCollection(this.getRunningAgentsDB()))); } - public List doAfterRun(Date sampleTime) { + public List sample(Date sampleTime) { try { ScriptResultModel scriptResultModel = this.getSampler() .getResultModelFromAgent(); diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_TestResultSave.java b/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_TestResultSave.java index 20abd627..088c5c45 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_TestResultSave.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_TestResultSave.java @@ -106,7 +106,7 @@ public class Test_TestResultSave extends TestBase_MakeUpTestPlan { testPlan.getCurrentStatus()); testPlanScript = getOneTestPlanScript(testPlan); List resultList = new ArrayList(); - resultList.addAll(testPlanScript.doAfterRun(new Date())); + resultList.addAll(testPlanScript.sample(new Date())); this.getTestResultSave().update(testPlan, resultList); testPlanFromRepo = this.getTestPlanRepository().getTestPlanInDomainBy( this.getTestPlanRunIdUuid()); diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/scriptrecord/ScheduleModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/scriptrecord/ScheduleModel.java index 761285c9..f34091a9 100644 --- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/scriptrecord/ScheduleModel.java +++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/scriptrecord/ScheduleModel.java @@ -39,12 +39,11 @@ public class ScheduleModel { if (this.points.size() == 0) { return 0; } - long startTime = this.points.get(0).getTimeInSecond(), endTime = startTime; + long endTime = this.points.get(0).getTimeInSecond(); for (PointModel point : this.getPoints()) { - startTime = Math.min(point.getTimeInSecond(), startTime); endTime = Math.max(point.getTimeInSecond(), endTime); } - return endTime - startTime; + return endTime; } public int getMaxLoad() {