File tree Expand file tree Collapse file tree 3 files changed +9
-0
lines changed
main/java/org/cloudbus/cloudsim
test/java/org/cloudbus/cloudsim Expand file tree Collapse file tree 3 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -1205,6 +1205,10 @@ public long getCloudletFinishedSoFar(final int resId) {
12051205 * @post $result >= 0
12061206 */
12071207 public long getRemainingCloudletLength () {
1208+ // Check if Cloudlet is finished
1209+ if (getCloudletLength () == getCloudletFinishedSoFar ())
1210+ return 0 ;
1211+
12081212 long length = getCloudletTotalLength ()*Consts .MILLION - getCloudletFinishedSoFar ();
12091213
12101214 // Remaining Cloudlet length can't be negative number.
Original file line number Diff line number Diff line change @@ -137,6 +137,9 @@ public void testCloudletFinish() {
137137 vmScheduler .cloudletFinish (cloudlet );
138138
139139 assertEquals (Cloudlet .CloudletStatus .SUCCESS , vmScheduler .getCloudletStatus (0 ));
140+ assertEquals (0 , cloudlet .getRemainingCloudletLength ());
141+ assertEquals (true , cloudlet .isFinished ());
142+ assertEquals (CLOUDLET_LENGTH , cloudlet .getCloudletFinishedSoFar ());
140143 assertTrue (vmScheduler .isFinishedCloudlets ());
141144 assertSame (cloudlet , vmScheduler .getNextFinishedCloudlet ());
142145 }
Original file line number Diff line number Diff line change @@ -57,6 +57,8 @@ public void testCloudlet() {
5757 assertSame (utilizationModelCpu , cloudlet .getUtilizationModelCpu ());
5858 assertSame (utilizationModelRam , cloudlet .getUtilizationModelRam ());
5959 assertSame (utilizationModelBw , cloudlet .getUtilizationModelBw ());
60+ assertEquals (CLOUDLET_LENGTH * PES_NUMBER , cloudlet .getRemainingCloudletLength ());
61+ assertEquals (0 , cloudlet .getCloudletFinishedSoFar ());
6062 }
6163
6264 @ Test
You can’t perform that action at this time.
0 commit comments