refactor
This commit is contained in:
coderfengyun 2014-09-09 11:19:25 +08:00
parent 6982240326
commit 8af22ed469
4 changed files with 121 additions and 6 deletions

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.1.4" icons="true" always-add-relationships="false" generalizations="true" realizations="true"
associations="true" dependencies="false" nesting-relationships="true">
<class id="1" language="java" name="java.util.Calendar" project="bench4q-agent"
file="C:/Program Files/Java/jdk1.7.0_67/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
<position height="53" width="304" x="307" y="-914"/>
<display autosize="false" stereotype="true" package="true" initial-value="false" signature="true" accessors="true"
visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="2" language="java" name="java.util.JapaneseImperialCalendar" project="bench4q-agent"
file="C:/Program Files/Java/jdk1.7.0_67/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
<position height="53" width="221" x="767" y="-707"/>
<display autosize="false" stereotype="true" package="true" initial-value="false" signature="true" accessors="true"
visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="3" language="java" name="java.util.GregorianCalendar" project="clif-core"
file="C:/Program Files/Java/jdk1.7.0_67/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
<position height="53" width="239" x="196" y="-715"/>
<display autosize="false" stereotype="true" package="true" initial-value="false" signature="true" accessors="true"
visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="4" language="java" name="sun.util.BuddhistCalendar" project="bench4q-master"
file="C:/Program Files/Java/jdk1.7.0_67/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
<position height="53" width="176" x="-30" y="-540"/>
<display autosize="false" stereotype="true" package="true" initial-value="false" signature="true" accessors="true"
visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="5" language="java" name="org.apache.log4j.RollingCalendar" project="clif-core"
file="/clif-core/lib/log4j-1.2.8.jar" binary="true" corner="BOTTOM_RIGHT">
<position height="53" width="190" x="191" y="-545"/>
<display autosize="false" stereotype="true" package="true" initial-value="false" signature="true" accessors="true"
visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="6" language="java" name="org.apache.log4j.RollingCalendar" project="bench4q-web"
file="C:/Users/chentienan/.m2/repository/com/github/tomakehurst/wiremock/1.46/wiremock-1.46-standalone.jar"
binary="true" corner="BOTTOM_RIGHT">
<position height="53" width="190" x="402" y="-525"/>
<display autosize="false" stereotype="true" package="true" initial-value="false" signature="true" accessors="true"
visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="7" language="java" name="org.apache.log4j.RollingCalendar" project="bench4q-agent"
file="C:/Users/chentienan/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar" binary="true" corner="BOTTOM_RIGHT">
<position height="53" width="190" x="610" y="-615"/>
<display autosize="false" stereotype="true" package="true" initial-value="false" signature="true" accessors="true"
visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<generalization id="8">
<end type="SOURCE" refId="5"/>
<end type="TARGET" refId="3"/>
</generalization>
<generalization id="9">
<end type="SOURCE" refId="7"/>
<end type="TARGET" refId="3"/>
</generalization>
<generalization id="10">
<end type="SOURCE" refId="6"/>
<end type="TARGET" refId="3"/>
</generalization>
<generalization id="11">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="3"/>
</generalization>
<generalization id="12">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="1"/>
</generalization>
<generalization id="13">
<end type="SOURCE" refId="2"/>
<end type="TARGET" refId="1"/>
</generalization>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>

View File

@ -149,12 +149,17 @@ public class Test_RunningAgent extends TestBase_MakeUpTestPlan {
@Test
public void test_RatioIntoEffectWithRatioHalf() {
ScheduleModel scheduleModel = new ScheduleModel();
double ratio = 0.5;
int maxLoad = 100;
testRatioCore(ratio, maxLoad);
}
private void testRatioCore(double ratio, int maxLoad) {
ScheduleModel scheduleModel = new ScheduleModel();
scheduleModel.getPoints().addAll(
Arrays.asList(new ScheduleModel.PointModel(0, 0),
new ScheduleModel.PointModel(30, 100)));
ScheduleModel target = scheduleModel.ratioIntoEffect(0.5);
new ScheduleModel.PointModel(30, maxLoad)));
ScheduleModel target = scheduleModel.ratioIntoEffect(ratio);
for (int i = 0; i < scheduleModel.getPoints().size(); i++) {
assertEquals(target.getPoints().get(i).getTimeInSecond(),
scheduleModel.getPoints().get(i).getTimeInSecond());
@ -163,4 +168,12 @@ public class Test_RunningAgent extends TestBase_MakeUpTestPlan {
target.getPoints().get(i).getLoad());
}
}
@Test
public void test_RatioIntoEffectWithVeryLittleLoad() {
double ratio = 0.1;
int maxLoad = 5;
testRatioCore(ratio, maxLoad);
}
}

View File

@ -7,10 +7,12 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class ScheduleModel {
private List<PointModel> points;
@XmlElementWrapper
@XmlElement
public List<PointModel> getPoints() {
return points;
}
@ -53,12 +55,12 @@ public class ScheduleModel {
return result;
}
@XmlRootElement
public static class PointModel {
// Time Unit is second
private long timeInSecond;
private int load;
public PointModel() {
}
@ -67,6 +69,7 @@ public class ScheduleModel {
this.setLoad(load);
}
@XmlElement
public long getTimeInSecond() {
return timeInSecond;
}
@ -75,6 +78,7 @@ public class ScheduleModel {
this.timeInSecond = timeInSecond;
}
@XmlElement
public int getLoad() {
return load;
}

View File

@ -1 +1 @@
masterAddress=localhost:8901
masterAddress=133.133.2.100:8901