Skip to content

Commit 38bf8b0

Browse files
authored
Close #432 :: VM lifetime (PR #433)
Introduces Lifetimed, Startable and StartableAbstract class/interfaces - Introduces a Vm lifeTime attribute (Cloudlet already had it) - Makes Broker request VM destruction after reaching lifeTime - Start and finishTime attributes were moved to the new Startable interface and StartableAbstract class. Now such attributes are uniform between Cloudlet, Vm and Host. - Makes CustomerEntity extends Lifetimed and Startable - Redesign to provide a default implementation for Lifetimed.isLifeTimeReached - Renames Cloudlet.getActualCpuTime to getTotalExecutionTime to conform to the Vm method. That method is now defined inside CustomerEntity interface. - Renames Cloudlet.execStartTime to startTime to conform to Vm.startTime to avoid confusion and provide uniformity to method names - Renames Cloudlet.getWaitingTime to getStartWaitTime - Renames Vm and Cloudlet (CustomerEntity) getWaitTime to getCreationWaitTime - Renames Cloudlet and Vm getArrivedTime to getBrokerArrivalTime - Renames Cloudlet.getArrivalTime to getDcArrivalTime - Renames Vm.stopTime to Vm.finishTime to conform to Cloudlet.finishTime - Renames Host.shutdownTime to finishTime - Fix test failures - Version bump to 8.2.0 Signed-off-by: Manoel Campos <[email protected]>
1 parent 77afad4 commit 38bf8b0

39 files changed

+712
-879
lines changed

docs/presentation/js/reveal.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4542,9 +4542,6 @@
45424542
* @param {object} event
45434543
*/
45444544
function onOverviewSlideClicked( event ) {
4545-
4546-
// TODO There's a bug here where the event listeners are not
4547-
// removed after deactivating the overview.
45484545
if( eventsAreBound && isOverview() ) {
45494546
event.preventDefault();
45504547

docs/presentation/plugin/markdown/markdown.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@
401401
convertSlides();
402402
},
403403

404-
// TODO: Do these belong in the API?
405404
processSlides: processSlides,
406405
convertSlides: convertSlides,
407406
slidify: slidify

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.cloudsimplus</groupId>
66
<artifactId>cloudsimplus</artifactId>
7-
<version>8.1.0</version>
7+
<version>8.2.0</version>
88

99
<name>CloudSim Plus API</name>
1010
<description>CloudSim Plus: A modern, highly extensible and easier-to-use Java 17+ Framework for Modeling and Simulation of Cloud Computing Infrastructures and Services</description>
@@ -100,7 +100,7 @@
100100
<tags>
101101
<tag>
102102
<name>TODO</name>
103-
<!-- TODO tag for all places -->
103+
<!-- "to do" tag for all places -->
104104
<placement>a</placement>
105105
<head>To do something:</head>
106106
</tag>
@@ -138,7 +138,7 @@
138138
<tags>
139139
<tag>
140140
<name>TODO</name>
141-
<!-- TODO tag for all places -->
141+
<!-- "to do" tag for all places -->
142142
<placement>a</placement>
143143
<head>To do something:</head>
144144
</tag>
@@ -220,7 +220,7 @@
220220
<tags>
221221
<tag>
222222
<name>TODO</name>
223-
<!-- TODO tag for all places -->
223+
<!-- "to do" tag for all places -->
224224
<placement>a</placement>
225225
<head>To do something:</head>
226226
</tag>
@@ -297,7 +297,7 @@
297297
<tags>
298298
<tag>
299299
<name>TODO</name>
300-
<!-- TODO tag for all places -->
300+
<!-- "to do" tag for all places -->
301301
<placement>a</placement>
302302
<head>To do something:</head>
303303
</tag>
@@ -530,7 +530,7 @@
530530
<tags>
531531
<tag>
532532
<name>TODO</name>
533-
<!-- TODO tag for all places -->
533+
<!-- "to do" tag for all places -->
534534
<placement>a</placement>
535535
<head>To do something:</head>
536536
</tag>

src/main/java/org/cloudsimplus/brokers/DatacenterBrokerAbstract.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public DatacenterBroker submitVmList(final List<? extends Vm> list) {
249249
private void configureEntities(final List<? extends CustomerEntity> customerEntities) {
250250
for (final var entity : customerEntities) {
251251
entity.setBroker(this);
252-
entity.setArrivedTime(getSimulation().clock());
252+
entity.setBrokerArrivalTime(getSimulation().clock());
253253
if(entity instanceof VmGroup vmGroup) {
254254
configureEntities(vmGroup.getVmList());
255255
}
@@ -869,8 +869,9 @@ private void requestVmDestructionAfterAllCloudletsFinished() {
869869
@Override
870870
public DatacenterBroker requestIdleVmDestruction(final Vm vm) {
871871
if (vm.isCreated()) {
872-
if(isVmIdleEnough(vm) || isFinished()) {
873-
LOGGER.info("{}: {}: Requesting {} destruction.", getSimulation().clockStr(), getName(), vm);
872+
if(isFinished() || vm.isLifeTimeReached() || isVmIdleEnough(vm)) {
873+
final var lifeTimeMsg = vm.isLifeTimeReached() ? " after reaching defined lifetime" : "";
874+
LOGGER.info("{}: {}: Requesting {} destruction{}.", getSimulation().clockStr(), getName(), vm, lifeTimeMsg);
874875
sendNow(getDatacenter(vm), CloudSimTag.VM_DESTROY, vm);
875876
}
876877

src/main/java/org/cloudsimplus/builders/CloudletBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class CloudletBuilder implements Builder {
4848
private long outputSize = 300;
4949
private long fileSize = 300;
5050
private int pes = 1;
51-
private double lifeTime = -1;
51+
private double lifeTime = Double.MAX_VALUE;
5252
/**
5353
* The VM to be bind to created cloudlets.
5454
*/

src/main/java/org/cloudsimplus/builders/tables/CloudletsTableBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ protected void createTableColumns() {
113113
addColumn(getTable().newColumn("CloudletLen", MI, lengthFormat), Cloudlet::getLength);
114114
addColumn(getTable().newColumn("FinishedLen", MI, lengthFormat), Cloudlet::getFinishedLengthSoFar);
115115
addColumn(getTable().newColumn("CloudletPEs", CPU_CORES, peFormat), Cloudlet::getPesNumber);
116-
addColumn(getTable().newColumn("StartTime", SECONDS, timeFormat), Cloudlet::getExecStartTime);
116+
addColumn(getTable().newColumn("StartTime", SECONDS, timeFormat), Cloudlet::getStartTime);
117117
addColumn(getTable().newColumn("FinishTime", SECONDS, timeFormat), Cloudlet::getFinishTime);
118-
addColumn(getTable().newColumn("ExecTime", SECONDS, timeFormat), Cloudlet::getActualCpuTime);
118+
addColumn(getTable().newColumn("ExecTime", SECONDS, timeFormat), Cloudlet::getTotalExecutionTime);
119119
}
120120

121121
/**

src/main/java/org/cloudsimplus/cloudlets/Cloudlet.java

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
package org.cloudsimplus.cloudlets;
88

99
import org.cloudsimplus.brokers.DatacenterBroker;
10-
import org.cloudsimplus.core.CloudSimTag;
11-
import org.cloudsimplus.core.CustomerEntity;
12-
import org.cloudsimplus.core.UniquelyIdentifiable;
13-
import org.cloudsimplus.datacenters.Datacenter;
10+
import org.cloudsimplus.core.*;
1411
import org.cloudsimplus.listeners.CloudletVmEventInfo;
1512
import org.cloudsimplus.listeners.EventListener;
1613
import org.cloudsimplus.resources.ResourceManageable;
@@ -105,11 +102,6 @@ enum Status {
105102
FAILED_RESOURCE_UNAVAILABLE
106103
}
107104

108-
/**
109-
* Indicates that the Cloudlet was not assigned to a Datacenter yet.
110-
*/
111-
int NOT_ASSIGNED = -1;
112-
113105
/**
114106
* An attribute that implements the Null Object Design Pattern for {@link Cloudlet}
115107
* objects.
@@ -166,15 +158,7 @@ enum Status {
166158
* Gets the time the Cloudlet arrived at a Datacenter to be executed.
167159
* @return the arrival time in seconds.
168160
*/
169-
double getArrivalTime();
170-
171-
/**
172-
* Gets the total execution time of the Cloudlet so far (in seconds),
173-
* if the Cloudlet has finished already or not.
174-
*
175-
* @return
176-
*/
177-
double getActualCpuTime();
161+
double getDcArrivalTime();
178162

179163
/**
180164
* Gets the input file size of this Cloudlet before execution (in bytes).
@@ -237,7 +221,7 @@ enum Status {
237221
*
238222
* @return the latest execution start time (in seconds)
239223
*/
240-
double getExecStartTime();
224+
double getStartTime();
241225

242226
/**
243227
* Gets the time when this Cloudlet has completed executing in the latest Datacenter.
@@ -428,23 +412,12 @@ enum Status {
428412
boolean isBoundToVm();
429413

430414
/**
431-
* Gets the time (in seconds) the cloudlet had to wait before start executing on a
432-
* resource.
415+
* Gets the time (in seconds) the cloudlet had to wait before start executing on a Datacenter.
433416
*
434417
* @return the waiting time (in seconds) when the cloudlet waited to execute;
435-
* or 0 if there wasn't any waiting time
436-
* or the cloudlet hasn't started to execute.
418+
* or -1 if the cloudlet hasn't started executing yet.
437419
*/
438-
double getWaitingTime();
439-
440-
/**
441-
* Checks whether this Cloudlet has finished executing or not.
442-
*
443-
* @return true if this Cloudlet has finished execution;
444-
* false otherwise
445-
*/
446-
boolean isFinished();
447-
420+
double getStartWaitTime();
448421

449422
/**
450423
* Checks whether this Cloudlet is still executing.
@@ -652,16 +625,17 @@ enum Status {
652625
boolean addFinishedLengthSoFar(long partialFinishedMI);
653626

654627
/**
655-
* Sets the {@link #getExecStartTime() latest execution start time} of this Cloudlet.
628+
* Sets the {@link #getStartTime() latest execution start time} of this Cloudlet.
656629
*
657630
* <p>
658631
* <b>NOTE:</b> The execution start time only holds the
659632
* latest one. Meaning all previous execution start times are ignored.
660633
* </p>
661634
*
662635
* @param clockTime the latest execution start time
636+
* @return
663637
*/
664-
void setExecStartTime(double clockTime);
638+
Startable setStartTime(double clockTime);
665639

666640
/**
667641
* Adds a Listener object that will be notified when
@@ -745,26 +719,24 @@ enum Status {
745719
Cloudlet reset();
746720

747721
/**
748-
* Sets the lifeTime of this cloudlet,
749-
* which indicates its maximum {@link #getActualCpuTime() execution time},
750-
* regardless of its length (in MI).
751-
*
752-
* <p>The cloudlet will finish execution as soon as possible, after the given lifeTime has passed,
753-
* since its {@link #getExecStartTime() exec start time}.
754-
* </p>
755-
*
756-
* <b>IMPORTANT</b>: Currently lifeTime must be larger than {@link Datacenter#getSchedulingInterval()}.
757-
* @param lifeTime lifeTime of this Cloudlet (in seconds)
722+
* Cloudlet {@inheritDoc}, regardless of its length (in MI).
723+
* @return {@inheritDoc}
724+
* @see #setLifeTime(double)
758725
*/
759-
Cloudlet setLifeTime(double lifeTime);
726+
@Override
727+
double getLifeTime();
760728

761729
/**
762-
* Gets the lifeTime of this cloudlet,
763-
* which indicates its maximum {@link #getActualCpuTime()} execution time},
764-
* regardless of its length (in MI).
730+
* Sets the Cloudlet {@inheritDoc}.
731+
* <p>The cloudlet will finish execution as soon as possible, after the given lifeTime has passed,
732+
* since its {@link #getStartTime() exec start time}.
733+
* </p>
765734
*
766-
* @return lifeTime of this cloudlet (in seconds).
767-
* @see #setLifeTime(double)
735+
* Check {@link Vm#setLifeTime(double)} for additional details.
736+
*
737+
* @param lifeTime {@inheritDoc}
738+
* @return {@inheritDoc}
768739
*/
769-
double getLifeTime();
740+
@Override
741+
Lifetimed setLifeTime(double lifeTime);
770742
}

0 commit comments

Comments
 (0)