add zero zero point to schedule if it doesn't exists
add zero zero point to schedule if it doesn't exists
This commit is contained in:
parent
ed8161f13d
commit
4f51501237
|
@ -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,
|
||||
|
|
|
@ -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<PointModel> pointModels, List<Segment> result) {
|
||||
int maxLoad = 0;
|
||||
List<Point> points = new LinkedList<Schedule.Point>();
|
||||
LinkedList<Point> points = new LinkedList<Schedule.Point>();
|
||||
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)));
|
||||
}
|
||||
|
|
|
@ -83,8 +83,9 @@ public class AgentMessengerImpl implements AgentMessenger {
|
|||
.tryMarshal(runScenarioModel);
|
||||
final Map<String, String> stringParts = new LinkedHashMap<String, String>();
|
||||
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(),
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -61,9 +61,10 @@ public class BehaviorModel {
|
|||
public void setParameters(List<ParameterModel> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
//
|
||||
// public BehaviorModel() {
|
||||
// }
|
||||
|
||||
//
|
||||
// public BehaviorModel() {
|
||||
// }
|
||||
|
||||
public static BehaviorModel TimerBehaviorBuilder(int id, String name,
|
||||
String use, List<ParameterModel> parameters) {
|
||||
|
@ -98,37 +99,5 @@ public class BehaviorModel {
|
|||
result.setType("CONTROLBEHAVIOR");
|
||||
return result;
|
||||
}
|
||||
|
||||
// public static BehaviorModel TimerBehaviorBuilder(String name,
|
||||
// String use, List<ParameterModel> parameters) {
|
||||
// BehaviorModel behaviorBaseModel = buildBehaviorModelWithoutType(
|
||||
// name, use, parameters);
|
||||
// behaviorBaseModel.setType("TIMERBEHAVIOR");
|
||||
// return behaviorBaseModel;
|
||||
// }
|
||||
//
|
||||
// private static BehaviorModel buildBehaviorModelWithoutType(
|
||||
// String name, String use, List<ParameterModel> 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<ParameterModel> parameters) {
|
||||
// BehaviorModel behaviorBaseModel = buildBehaviorModelWithoutType(
|
||||
// name, use, parameters);
|
||||
// behaviorBaseModel.setType("USERBEHAVIOR");
|
||||
// return behaviorBaseModel;
|
||||
// }
|
||||
//
|
||||
// public static BehaviorModel ControlBehaviorBuilder(String name,
|
||||
// String use, List<ParameterModel> parameters) {
|
||||
// BehaviorModel result = buildBehaviorModelWithoutType( name, use,
|
||||
// parameters);
|
||||
// result.setType("CONTROLBEHAVIOR");
|
||||
// return result;
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue