Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Cleanup #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public abstract class CloudletScheduler {
*/
public CloudletScheduler() {
setPreviousTime(0.0);
cloudletWaitingList = new LinkedList<ResCloudlet>();
cloudletExecList = new LinkedList<ResCloudlet>();
cloudletPausedList = new LinkedList<ResCloudlet>();
cloudletFinishedList = new LinkedList<ResCloudlet>();
cloudletFailedList = new LinkedList<ResCloudlet>();
cloudletWaitingList = new LinkedList<>();
cloudletExecList = new LinkedList<>();
cloudletPausedList = new LinkedList<>();
cloudletFinishedList = new LinkedList<>();
cloudletFailedList = new LinkedList<>();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ public double updateVmProcessing(double currentTime, List<Double> mipsShare) {

// check finished cloudlets
double nextEvent = Double.MAX_VALUE;
List<ResCloudlet> toRemove = new ArrayList<ResCloudlet>();
List<ResCloudlet> toRemove = new ArrayList<>();
for (ResCloudlet rcl : getCloudletExecList()) {
long remainingLength = rcl.getRemainingCloudletLength();
if (remainingLength == 0) {// finished: remove from the list
toRemove.add(rcl);
cloudletFinish(rcl);
continue;
}
}
getCloudletExecList().removeAll(toRemove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
*/
public final class Consts {

/** Suppreses intantiation. */
/** Suppresses instantiation. */
private Consts() {
throw new RuntimeException("This class should not be instantiated");
}

/** One million. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,24 @@ public void processEvent(SimEvent ev) {
switch (ev.getTag()) {
// Resource characteristics inquiry
case CloudSimTags.RESOURCE_CHARACTERISTICS:
srcId = ((Integer) ev.getData()).intValue();
srcId = (Integer) ev.getData();
sendNow(srcId, ev.getTag(), getCharacteristics());
break;

// Resource dynamic info inquiry
case CloudSimTags.RESOURCE_DYNAMICS:
srcId = ((Integer) ev.getData()).intValue();
srcId = (Integer) ev.getData();
sendNow(srcId, ev.getTag(), 0);
break;

case CloudSimTags.RESOURCE_NUM_PE:
srcId = ((Integer) ev.getData()).intValue();
srcId = (Integer) ev.getData();
int numPE = getCharacteristics().getNumberOfPes();
sendNow(srcId, ev.getTag(), numPE);
break;

case CloudSimTags.RESOURCE_NUM_FREE_PE:
srcId = ((Integer) ev.getData()).intValue();
srcId = (Integer) ev.getData();
int freePesNumber = getCharacteristics().getNumberOfFreePes();
sendNow(srcId, ev.getTag(), freePesNumber);
break;
Expand Down Expand Up @@ -282,7 +282,7 @@ protected void processDataDelete(SimEvent ev, boolean ack) {
}

String filename = (String) data[0];
int req_source = ((Integer) data[1]).intValue();
int req_source = (Integer) data[1];
int tag = -1;

// check if this file can be deleted (do not delete is right now)
Expand All @@ -297,7 +297,7 @@ protected void processDataDelete(SimEvent ev, boolean ack) {
// send back to sender
Object pack[] = new Object[2];
pack[0] = filename;
pack[1] = Integer.valueOf(msg);
pack[1] = msg;

sendNow(req_source, tag, pack);
}
Expand All @@ -322,7 +322,7 @@ protected void processDataAdd(SimEvent ev, boolean ack) {

File file = (File) pack[0]; // get the file
file.setMasterCopy(true); // set the file into a master copy
int sentFrom = ((Integer) pack[1]).intValue(); // get sender ID
int sentFrom = (Integer) pack[1]; // get sender ID

/******
* // DEBUG Log.printLine(super.get_name() + ".addMasterFile(): " + file.getName() +
Expand All @@ -335,8 +335,8 @@ protected void processDataAdd(SimEvent ev, boolean ack) {
int msg = addFile(file); // add the file

if (ack) {
data[1] = Integer.valueOf(-1); // no sender id
data[2] = Integer.valueOf(msg); // the result of adding a master file
data[1] = -1; // no sender id
data[2] = msg; // the result of adding a master file
sendNow(sentFrom, DataCloudTags.FILE_ADD_MASTER_RESULT, data);
}
}
Expand Down Expand Up @@ -902,16 +902,15 @@ protected void updateCloudletProcessing() {
List<? extends Host> list = getVmAllocationPolicy().getHostList();
double smallerTime = Double.MAX_VALUE;
// for each host...
for (int i = 0; i < list.size(); i++) {
Host host = list.get(i);
for (Host host : list) {
// inform VMs to update processing
double time = host.updateVmsProcessing(CloudSim.clock());
// what time do we expect that the next cloudlet will finish?
if (time < smallerTime) {
smallerTime = time;
}
}
// gurantees a minimal interval before scheduling the event
// guarantees a minimal interval before scheduling the event
if (smallerTime < CloudSim.clock() + CloudSim.getMinTimeBetweenEvents() + 0.01) {
smallerTime = CloudSim.clock() + CloudSim.getMinTimeBetweenEvents() + 0.01;
}
Expand All @@ -931,8 +930,7 @@ protected void updateCloudletProcessing() {
*/
protected void checkCloudletCompletion() {
List<? extends Host> list = getVmAllocationPolicy().getHostList();
for (int i = 0; i < list.size(); i++) {
Host host = list.get(i);
for (Host host : list) {
for (Vm vm : host.getVmList()) {
while (vm.getCloudletScheduler().isFinishedCloudlets()) {
Cloudlet cl = vm.getCloudletScheduler().getNextFinishedCloudlet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ public double updateVmsProcessing(double currentTime) {
double smallerTime = Double.MAX_VALUE;

for (Vm vm : getVmList()) {
double time = vm.updateVmProcessing(
currentTime, getVmScheduler().getAllocatedMipsForVm(vm));
double time = vm.updateVmProcessing(currentTime, getVmScheduler().getAllocatedMipsForVm(vm));
if (time > 0.0 && time < smallerTime) {
smallerTime = time;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public class CloudInformationService extends SimEntity {
*/
public CloudInformationService(String name) throws Exception {
super(name);
resList = new LinkedList<Integer>();
arList = new LinkedList<Integer>();
gisList = new LinkedList<Integer>();
resList = new LinkedList<>();
arList = new LinkedList<>();
gisList = new LinkedList<>();
}

/**
Expand All @@ -89,7 +89,7 @@ public void processEvent(SimEvent ev) {
case CloudSimTags.REQUEST_REGIONAL_GIS:

// Get ID of an entity that send this event
id = ((Integer) ev.getData()).intValue();
id = (Integer) ev.getData();

// Send the regional GIS list back to sender
super.send(id, 0L, ev.getTag(), gisList);
Expand All @@ -110,7 +110,7 @@ public void processEvent(SimEvent ev) {
case CloudSimTags.RESOURCE_LIST:

// Get ID of an entity that send this event
id = ((Integer) ev.getData()).intValue();
id = (Integer) ev.getData();

// Send the resource list back to the sender
super.send(id, 0L, ev.getTag(), resList);
Expand All @@ -120,7 +120,7 @@ public void processEvent(SimEvent ev) {
case CloudSimTags.RESOURCE_AR_LIST:

// Get ID of an entity that send this event
id = ((Integer) ev.getData()).intValue();
id = (Integer) ev.getData();

// Send the resource AR list back to the sender
super.send(id, 0L, ev.getTag(), arList);
Expand Down Expand Up @@ -279,13 +279,9 @@ private boolean checkResource(Collection<Integer> list, int id) {
return flag;
}

Integer obj = null;
Iterator<Integer> it = list.iterator();

// a loop to find the match the resource id in a list
while (it.hasNext()) {
obj = it.next();
if (obj.intValue() == id) {
for (Integer integer : list) {
if (integer == id) {
flag = true;
break;
}
Expand Down
Loading