add code
This commit is contained in:
coderfengyun 2014-07-21 14:05:07 +08:00
parent f0296eb398
commit c2db1fa1b7
5 changed files with 15 additions and 12 deletions

View File

@ -1,5 +1,6 @@
package org.bench4q.master.domain;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.UUID;
@ -23,6 +24,6 @@ public interface RunningScriptInterface {
public void doForComplete();
public List<TestPlanScriptResult> doAfterRun();
public List<TestPlanScriptResult> doAfterRun(Date sampleTime);
}

View File

@ -116,15 +116,14 @@ public class Monitor {
}
public List<MonitorResult> doAfterRun() {
public List<MonitorResult> doAfterRun(Date sampeTime) {
try {
MonitorMain monitorMain = getTestMonitorSampler().getMonitorResult(
hostName, port);
System.out.println(MarshalHelper.tryMarshal(monitorMain));
List<MonitorResult> monitorResults = this.getTestPlanFactory()
.createMonitorResultListWithOutId(monitorMain, testPlan,
this, monitorMain.getSamplingTime());
this, sampeTime);
return monitorResults;
} catch (Exception e) {

View File

@ -259,7 +259,8 @@ public class TestPlan implements IAggregate {
scheScheduledExecutorService.shutdown();
return;
}
getTestResultSave().update(TestPlan.this, collectResult());
getTestResultSave().update(TestPlan.this,
collectResult(new Date()));
}
}, 0, this.getSampleCycleInSeconds(), TimeUnit.SECONDS);
} catch (Exception e) {
@ -269,17 +270,18 @@ public class TestPlan implements IAggregate {
}
private List<Object> collectResult() {
private List<Object> collectResult(Date sampleTime) {
List<Object> resultList = new LinkedList<Object>();
for (TestPlanScript testPlanScript : getTestPlanScripts()) {
List<TestPlanScriptResult> testPlanScriptResults = testPlanScript
.doAfterRun();
.doAfterRun(sampleTime);
if (testPlanScriptResults != null)
resultList.addAll(testPlanScriptResults);
}
if (getMonitors() != null) {
for (Monitor monitor : getMonitors()) {
List<MonitorResult> monitorResults = monitor.doAfterRun();
List<MonitorResult> monitorResults = monitor
.doAfterRun(sampleTime);
if (monitorResults != null) {
resultList.addAll(monitorResults);
}

View File

@ -228,14 +228,14 @@ public class TestPlanScript implements RunningScriptInterface {
.unmodifiableCollection(this.getRunningAgentsDB())));
}
public List<TestPlanScriptResult> doAfterRun() {
public List<TestPlanScriptResult> doAfterRun(Date sampleTime) {
try {
ScriptResultModel scriptResultModel = this.getSampler()
.getResultModelFromAgent();
List<TestPlanScriptResult> testPlanScriptResultList = this
.getTestPlanFactory().createScriptResultsWithoutId(
scriptResultModel, this, new Date());
scriptResultModel, this, sampleTime);
return testPlanScriptResultList;
} catch (Exception e) {
logger.info(ExceptionLog.getStackTrace(e));

View File

@ -3,6 +3,7 @@ package org.bench4q.master.integrated;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.bench4q.master.domain.entity.Monitor;
@ -80,7 +81,7 @@ public class Test_TestResultSave extends TestBase_MakeUpTestPlan {
testPlanFromRepo);
List<Object> resultList = new ArrayList<Object>();
resultList.addAll(getOneMonitor(testPlan, Monitor_Host_Name)
.doAfterRun());
.doAfterRun(new Date()));
this.getTestResultSave().update(testPlan, resultList);
testPlanFromRepo = this.getTestPlanRepository().getTestPlanInDomainBy(
this.getTestPlanRunIdUuid());
@ -105,7 +106,7 @@ public class Test_TestResultSave extends TestBase_MakeUpTestPlan {
testPlan.getCurrentStatus());
testPlanScript = getOneTestPlanScript(testPlan);
List<Object> resultList = new ArrayList<Object>();
resultList.addAll(testPlanScript.doAfterRun());
resultList.addAll(testPlanScript.doAfterRun(new Date()));
this.getTestResultSave().update(testPlan, resultList);
testPlanFromRepo = this.getTestPlanRepository().getTestPlanInDomainBy(
this.getTestPlanRunIdUuid());