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 628f1181..3ed8eeb4 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 @@ -91,6 +91,7 @@ public class TestController { RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper .unmarshal(RunScenarioModel.class, scenarioModel); System.out.println(scheduleContent); + this.logger.info(scheduleContent); ScheduleModel scheduleModel = (ScheduleModel) MarshalHelper .unmarshal(ScheduleModel.class, scheduleContent); this.getScenarioEngine().submitScenario(runId, 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 6980fc57..be54f631 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 @@ -96,7 +96,7 @@ public class Schedule extends Observable { || timeInMilliSecond < this.getSegments().get(0).start .getTimeInMilliSecond()) { throw new Bench4QRunTimeException( - "can't getSegment when segments' size is LT 2"); + "can't getSegment when segments' size is LT 1"); } if (timeInMilliSecond >= this.getSegments().get( this.getSegments().size() - 1).end.getTimeInMilliSecond()) { @@ -120,16 +120,16 @@ public class Schedule extends Observable { /** * - * @param relativeTime + * @param relativeTimeInMS * , relativeTime from beginDate * @return */ - public int loadFor(long relativeTime) { - Segment segment = getSegment(relativeTime); + public int loadFor(long relativeTimeInMS) { + Segment segment = getSegment(relativeTimeInMS); if (segment == null) { throw new IllegalArgumentException(); } - return segment.loadFor(relativeTime); + return segment.loadFor(relativeTimeInMS); } public static class Segment { @@ -184,12 +184,12 @@ public class Schedule extends Observable { return load; } - public Point(long time, int load) { + public Point(long timeInSecond, int load) { if (load < 0) { throw new IllegalArgumentException( "Load can't be negtive number!"); } - this.timeInSecond = time; + this.timeInSecond = timeInSecond; this.load = load; } @@ -209,7 +209,7 @@ public class Schedule extends Observable { private static int extractSegmentsAndGetMaxLoad( List pointModels, List result) { int maxLoad = 0; - List points = new LinkedList(); + LinkedList points = new LinkedList(); for (PointModel model : pointModels) { maxLoad = Math.max(maxLoad, model.getLoad()); points.add(new Point(model.getTimeInSecond(), model.getLoad())); @@ -221,6 +221,10 @@ public class Schedule extends Observable { .getTimeInMilliSecond()); } }); + // guard the startPoint is 0,0 + if (points.size() > 0 || points.get(0).getTimeInSecond() > 0) { + points.addFirst(new Point(0, 0)); + } for (int i = 0; i < points.size() - 1; i++) { result.add(new Segment(points.get(i), points.get(i + 1))); } diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/impl/AgentMessengerImpl.java b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/impl/AgentMessengerImpl.java index 977105d5..3d2cadf2 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/impl/AgentMessengerImpl.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/impl/AgentMessengerImpl.java @@ -83,8 +83,9 @@ public class AgentMessengerImpl implements AgentMessenger { .tryMarshal(runScenarioModel); final Map stringParts = new LinkedHashMap(); stringParts.put("scenarioModel", modelContent); - stringParts.put("scheduleContent", - MarshalHelper.tryMarshal(scheduleModel)); + String scheduleContent = MarshalHelper.tryMarshal(scheduleModel); + this.logger.info(scheduleContent); + stringParts.put("scheduleContent", scheduleContent); httpResponse = this.httpRequester.postFiles(null, buildBaseUrl(agent) + "/test/submitScenarioWithParams/" + agentRunId + "/" + realStartDate.getTime(), diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/communication/HttpRequester.java b/Bench4Q-Share/src/main/java/org/bench4q/share/communication/HttpRequester.java index e93c3d14..e66cf568 100644 --- a/Bench4Q-Share/src/main/java/org/bench4q/share/communication/HttpRequester.java +++ b/Bench4Q-Share/src/main/java/org/bench4q/share/communication/HttpRequester.java @@ -109,8 +109,8 @@ public class HttpRequester { httpResponse.setCode(statusCode); httpResponse.setContent(postMethod.getResponseBodyAsString()); httpResponse.setContentType(postMethod - .getResponseHeader("Content-Type").equals(null) ? postMethod - .getResponseHeader("Content-Type").getValue() : null); + .getResponseHeader("Content-Type") == null ? null : postMethod + .getResponseHeader("Content-Type").getValue()); httpResponse.setContentEncoding(postMethod.getResponseCharSet()); return httpResponse; } diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/scriptrecord/BehaviorModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/scriptrecord/BehaviorModel.java index d8fa78b7..419199bc 100644 --- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/scriptrecord/BehaviorModel.java +++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/scriptrecord/BehaviorModel.java @@ -61,9 +61,10 @@ public class BehaviorModel { public void setParameters(List parameters) { this.parameters = parameters; } -// -// public BehaviorModel() { -// } + + // + // public BehaviorModel() { + // } public static BehaviorModel TimerBehaviorBuilder(int id, String name, String use, List parameters) { @@ -98,37 +99,5 @@ public class BehaviorModel { result.setType("CONTROLBEHAVIOR"); return result; } - -// public static BehaviorModel TimerBehaviorBuilder(String name, -// String use, List parameters) { -// BehaviorModel behaviorBaseModel = buildBehaviorModelWithoutType( -// name, use, parameters); -// behaviorBaseModel.setType("TIMERBEHAVIOR"); -// return behaviorBaseModel; -// } -// -// private static BehaviorModel buildBehaviorModelWithoutType( -// String name, String use, List parameters) { -// BehaviorModel behaviorBaseModel = new BehaviorModel(); -// behaviorBaseModel.setName(name); -// behaviorBaseModel.setUse(use); -// behaviorBaseModel.setParameters(parameters); -// return behaviorBaseModel; -// } -// -// public static BehaviorModel UserBehaviorBuilder(String name, -// String use, List parameters) { -// BehaviorModel behaviorBaseModel = buildBehaviorModelWithoutType( -// name, use, parameters); -// behaviorBaseModel.setType("USERBEHAVIOR"); -// return behaviorBaseModel; -// } -// -// public static BehaviorModel ControlBehaviorBuilder(String name, -// String use, List parameters) { -// BehaviorModel result = buildBehaviorModelWithoutType( name, use, -// parameters); -// result.setType("CONTROLBEHAVIOR"); -// return result; -// } + }