From 13e83c16df4fd6fa2564b960185015d9d3ba7360 Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Fri, 26 Sep 2014 17:02:02 +0800 Subject: [PATCH] refactor refactor --- .../java/org/bench4q/agent/api/TestController.java | 5 +++++ .../org/bench4q/agent/scenario/engine/Schedule.java | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/TestController.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/TestController.java index 02841011..70f65e34 100644 --- a/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/TestController.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/TestController.java @@ -1,6 +1,7 @@ package org.bench4q.agent.api; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.UUID; @@ -87,6 +88,7 @@ public class TestController { try { this.getParamFileCollector().collectParamFiles(files, runId); System.out.println(scenarioModel); + logger.info("Real start time is:" + new Date(realStartTime)); RunScenarioModel runScenarioModel = MarshalHelper.unmarshal( RunScenarioModel.class, scenarioModel); System.out.println(scheduleContent); @@ -166,6 +168,9 @@ public class TestController { .getBehaviorBriefResult(scenarioContext .getDataCollector()); logger.info(pluginImplementBehavior.getId()); + if (briefModel == null) { + continue; + } briefModel.setBehaviorUrl(pluginImplementBehavior .getSpecificParamValue("url")); behaviorBriefModels.add(briefModel); diff --git a/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/engine/Schedule.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/engine/Schedule.java index be54f631..48057d1b 100644 --- a/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/engine/Schedule.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/engine/Schedule.java @@ -91,13 +91,15 @@ public class Schedule extends Observable { * @return get the segment by binary search */ public Segment getSegment(long timeInMilliSecond) { - if (this.getSegments() == null - || this.getSegments().size() < 1 - || timeInMilliSecond < this.getSegments().get(0).start - .getTimeInMilliSecond()) { + if (this.getSegments() == null || this.getSegments().size() < 1) { throw new Bench4QRunTimeException( "can't getSegment when segments' size is LT 1"); } + if (timeInMilliSecond < this.getSegments().get(0).start + .getTimeInMilliSecond()) { + throw new Bench4QRunTimeException( + "can't getSegment when timeInMilliSecond LT 0-segment's start"); + } if (timeInMilliSecond >= this.getSegments().get( this.getSegments().size() - 1).end.getTimeInMilliSecond()) { this.reachEnd();