Commit 2faca426 authored by Nikolay's avatar Nikolay

Refactored the CloudletSchedulers, moved duplicate code to the superclass.

parent 03509e81
......@@ -8,8 +8,10 @@
package org.cloudbus.cloudsim;
import java.util.ArrayList;
import java.util.List;
/**
* CloudletScheduler is an abstract class that represents the policy of scheduling performed by a
* virtual machine. So, classes extending this must execute Cloudlets. Also, the interface for
......@@ -27,6 +29,21 @@ public abstract class CloudletScheduler {
/** The current mips share. */
private List<Double> currentMipsShare;
/** The cloudlet waiting list. */
protected List<? extends ResCloudlet> cloudletWaitingList;
/** The cloudlet exec list. */
protected List<? extends ResCloudlet> cloudletExecList;
/** The cloudlet paused list. */
protected List<? extends ResCloudlet> cloudletPausedList;
/** The cloudlet finished list. */
protected List<? extends ResCloudlet> cloudletFinishedList;
/** The cloudlet failed list. */
protected List<? extends ResCloudlet> cloudletFailedList;
/**
* Creates a new CloudletScheduler object. This method must be invoked before starting the
* actual simulation.
......@@ -36,6 +53,11 @@ public abstract class CloudletScheduler {
*/
public CloudletScheduler() {
setPreviousTime(0.0);
cloudletWaitingList = new ArrayList<ResCloudlet>();
cloudletExecList = new ArrayList<ResCloudlet>();
cloudletPausedList = new ArrayList<ResCloudlet>();
cloudletFinishedList = new ArrayList<ResCloudlet>();
cloudletFailedList = new ArrayList<ResCloudlet>();
}
/**
......@@ -248,4 +270,109 @@ public abstract class CloudletScheduler {
return currentMipsShare;
}
/**
* Gets the cloudlet waiting list.
*
* @param <T> the generic type
* @return the cloudlet waiting list
*/
@SuppressWarnings("unchecked")
public <T extends ResCloudlet> List<T> getCloudletWaitingList() {
return (List<T>) cloudletWaitingList;
}
/**
* Cloudlet waiting list.
*
* @param <T> the generic type
* @param cloudletWaitingList the cloudlet waiting list
*/
protected <T extends ResCloudlet> void setCloudletWaitingList(List<T> cloudletWaitingList) {
this.cloudletWaitingList = cloudletWaitingList;
}
/**
* Gets the cloudlet exec list.
*
* @param <T> the generic type
* @return the cloudlet exec list
*/
@SuppressWarnings("unchecked")
public <T extends ResCloudlet> List<T> getCloudletExecList() {
return (List<T>) cloudletExecList;
}
/**
* Sets the cloudlet exec list.
*
* @param <T> the generic type
* @param cloudletExecList the new cloudlet exec list
*/
protected <T extends ResCloudlet> void setCloudletExecList(List<T> cloudletExecList) {
this.cloudletExecList = cloudletExecList;
}
/**
* Gets the cloudlet paused list.
*
* @param <T> the generic type
* @return the cloudlet paused list
*/
@SuppressWarnings("unchecked")
public <T extends ResCloudlet> List<T> getCloudletPausedList() {
return (List<T>) cloudletPausedList;
}
/**
* Sets the cloudlet paused list.
*
* @param <T> the generic type
* @param cloudletPausedList the new cloudlet paused list
*/
protected <T extends ResCloudlet> void setCloudletPausedList(List<T> cloudletPausedList) {
this.cloudletPausedList = cloudletPausedList;
}
/**
* Gets the cloudlet finished list.
*
* @param <T> the generic type
* @return the cloudlet finished list
*/
@SuppressWarnings("unchecked")
public <T extends ResCloudlet> List<T> getCloudletFinishedList() {
return (List<T>) cloudletFinishedList;
}
/**
* Sets the cloudlet finished list.
*
* @param <T> the generic type
* @param cloudletFinishedList the new cloudlet finished list
*/
protected <T extends ResCloudlet> void setCloudletFinishedList(List<T> cloudletFinishedList) {
this.cloudletFinishedList = cloudletFinishedList;
}
/**
* Gets the cloudlet failed list.
*
* @param <T> the generic type
* @return the cloudlet failed list.
*/
@SuppressWarnings("unchecked")
public <T extends ResCloudlet> List<T> getCloudletFailedList() {
return (List<T>) cloudletFailedList;
}
/**
* Sets the cloudlet failed list.
*
* @param <T> the generic type
* @param cloudletFailedList the new cloudlet failed list.
*/
protected <T extends ResCloudlet> void setCloudletFailedList(List<T> cloudletFailedList) {
this.cloudletFailedList = cloudletFailedList;
}
}
......@@ -26,18 +26,6 @@ import org.cloudbus.cloudsim.core.CloudSim;
*/
public class CloudletSchedulerSpaceShared extends CloudletScheduler {
/** The cloudlet waiting list. */
private List<? extends ResCloudlet> cloudletWaitingList;
/** The cloudlet exec list. */
private List<? extends ResCloudlet> cloudletExecList;
/** The cloudlet paused list. */
private List<? extends ResCloudlet> cloudletPausedList;
/** The cloudlet finished list. */
private List<? extends ResCloudlet> cloudletFinishedList;
/** The current CPUs. */
protected int currentCpus;
......@@ -53,10 +41,6 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
*/
public CloudletSchedulerSpaceShared() {
super();
cloudletWaitingList = new ArrayList<ResCloudlet>();
cloudletExecList = new ArrayList<ResCloudlet>();
cloudletPausedList = new ArrayList<ResCloudlet>();
cloudletFinishedList = new ArrayList<ResCloudlet>();
usedPes = 0;
currentCpus = 0;
}
......@@ -509,90 +493,6 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
return cl;
}
/**
* Gets the cloudlet waiting list.
*
* @param <T> the generic type
* @return the cloudlet waiting list
*/
@SuppressWarnings("unchecked")
protected <T extends ResCloudlet> List<T> getCloudletWaitingList() {
return (List<T>) cloudletWaitingList;
}
/**
* Cloudlet waiting list.
*
* @param <T> the generic type
* @param cloudletWaitingList the cloudlet waiting list
*/
protected <T extends ResCloudlet> void cloudletWaitingList(List<T> cloudletWaitingList) {
this.cloudletWaitingList = cloudletWaitingList;
}
/**
* Gets the cloudlet exec list.
*
* @param <T> the generic type
* @return the cloudlet exec list
*/
@SuppressWarnings("unchecked")
protected <T extends ResCloudlet> List<T> getCloudletExecList() {
return (List<T>) cloudletExecList;
}
/**
* Sets the cloudlet exec list.
*
* @param <T> the generic type
* @param cloudletExecList the new cloudlet exec list
*/
protected <T extends ResCloudlet> void setCloudletExecList(List<T> cloudletExecList) {
this.cloudletExecList = cloudletExecList;
}
/**
* Gets the cloudlet paused list.
*
* @param <T> the generic type
* @return the cloudlet paused list
*/
@SuppressWarnings("unchecked")
protected <T extends ResCloudlet> List<T> getCloudletPausedList() {
return (List<T>) cloudletPausedList;
}
/**
* Sets the cloudlet paused list.
*
* @param <T> the generic type
* @param cloudletPausedList the new cloudlet paused list
*/
protected <T extends ResCloudlet> void setCloudletPausedList(List<T> cloudletPausedList) {
this.cloudletPausedList = cloudletPausedList;
}
/**
* Gets the cloudlet finished list.
*
* @param <T> the generic type
* @return the cloudlet finished list
*/
@SuppressWarnings("unchecked")
protected <T extends ResCloudlet> List<T> getCloudletFinishedList() {
return (List<T>) cloudletFinishedList;
}
/**
* Sets the cloudlet finished list.
*
* @param <T> the generic type
* @param cloudletFinishedList the new cloudlet finished list
*/
protected <T extends ResCloudlet> void setCloudletFinishedList(List<T> cloudletFinishedList) {
this.cloudletFinishedList = cloudletFinishedList;
}
/*
* (non-Javadoc)
* @see org.cloudbus.cloudsim.CloudletScheduler#getCurrentRequestedMips()
......
......@@ -22,15 +22,6 @@ import org.cloudbus.cloudsim.core.CloudSim;
*/
public class CloudletSchedulerTimeShared extends CloudletScheduler {
/** The cloudlet exec list. */
private List<? extends ResCloudlet> cloudletExecList;
/** The cloudlet paused list. */
private List<? extends ResCloudlet> cloudletPausedList;
/** The cloudlet finished list. */
private List<? extends ResCloudlet> cloudletFinishedList;
/** The current cp us. */
protected int currentCPUs;
......@@ -43,9 +34,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
*/
public CloudletSchedulerTimeShared() {
super();
cloudletExecList = new ArrayList<ResCloudlet>();
cloudletPausedList = new ArrayList<ResCloudlet>();
cloudletFinishedList = new ArrayList<ResCloudlet>();
currentCPUs = 0;
}
......@@ -416,68 +404,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
return rgl.getCloudlet();
}
/**
* Gets the cloudlet exec list.
*
* @param <T> the generic type
* @return the cloudlet exec list
*/
@SuppressWarnings("unchecked")
protected <T extends ResCloudlet> List<T> getCloudletExecList() {
return (List<T>) cloudletExecList;
}
/**
* Sets the cloudlet exec list.
*
* @param <T> the generic type
* @param cloudletExecList the new cloudlet exec list
*/
protected <T extends ResCloudlet> void setCloudletExecList(List<T> cloudletExecList) {
this.cloudletExecList = cloudletExecList;
}
/**
* Gets the cloudlet paused list.
*
* @param <T> the generic type
* @return the cloudlet paused list
*/
@SuppressWarnings("unchecked")
protected <T extends ResCloudlet> List<T> getCloudletPausedList() {
return (List<T>) cloudletPausedList;
}
/**
* Sets the cloudlet paused list.
*
* @param <T> the generic type
* @param cloudletPausedList the new cloudlet paused list
*/
protected <T extends ResCloudlet> void setCloudletPausedList(List<T> cloudletPausedList) {
this.cloudletPausedList = cloudletPausedList;
}
/**
* Gets the cloudlet finished list.
*
* @param <T> the generic type
* @return the cloudlet finished list
*/
@SuppressWarnings("unchecked")
protected <T extends ResCloudlet> List<T> getCloudletFinishedList() {
return (List<T>) cloudletFinishedList;
}
/**
* Sets the cloudlet finished list.
*
* @param <T> the generic type
* @param cloudletFinishedList the new cloudlet finished list
*/
protected <T extends ResCloudlet> void setCloudletFinishedList(List<T> cloudletFinishedList) {
this.cloudletFinishedList = cloudletFinishedList;
}
/*
* (non-Javadoc)
......
......@@ -33,18 +33,6 @@ import org.cloudbus.cloudsim.core.CloudSimTags;
*/
public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/** The cloudlet waiting list. */
private List<? extends ResCloudlet> cloudletWaitingList;
/** The cloudlet exec list. */
private List<? extends ResCloudlet> cloudletExecList;
/** The cloudlet paused list. */
private List<? extends ResCloudlet> cloudletPausedList;
/** The cloudlet finished list. */
private List<? extends ResCloudlet> cloudletFinishedList;
/** The current CPUs. */
protected int currentCpus;
......@@ -645,90 +633,6 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
return cl;
}
/**
* Gets the cloudlet waiting list.
*
* @param <T> the generic type
* @return the cloudlet waiting list
*/
@SuppressWarnings("unchecked")
protected <T extends ResCloudlet> List<T> getCloudletWaitingList() {
return (List<T>) cloudletWaitingList;
}
/**
* Cloudlet waiting list.
*
* @param <T> the generic type
* @param cloudletWaitingList the cloudlet waiting list
*/
protected <T extends ResCloudlet> void cloudletWaitingList(List<T> cloudletWaitingList) {
this.cloudletWaitingList = cloudletWaitingList;
}
/**
* Gets the cloudlet exec list.
*
* @param <T> the generic type
* @return the cloudlet exec list
*/
@SuppressWarnings("unchecked")
protected <T extends ResCloudlet> List<T> getCloudletExecList() {
return (List<T>) cloudletExecList;
}
/**
* Sets the cloudlet exec list.
*
* @param <T> the generic type
* @param cloudletExecList the new cloudlet exec list
*/
protected <T extends ResCloudlet> void setCloudletExecList(List<T> cloudletExecList) {
this.cloudletExecList = cloudletExecList;
}
/**
* Gets the cloudlet paused list.
*
* @param <T> the generic type
* @return the cloudlet paused list
*/
@SuppressWarnings("unchecked")
protected <T extends ResCloudlet> List<T> getCloudletPausedList() {
return (List<T>) cloudletPausedList;
}
/**
* Sets the cloudlet paused list.
*
* @param <T> the generic type
* @param cloudletPausedList the new cloudlet paused list
*/
protected <T extends ResCloudlet> void setCloudletPausedList(List<T> cloudletPausedList) {
this.cloudletPausedList = cloudletPausedList;
}
/**
* Gets the cloudlet finished list.
*
* @param <T> the generic type
* @return the cloudlet finished list
*/
@SuppressWarnings("unchecked")
protected <T extends ResCloudlet> List<T> getCloudletFinishedList() {
return (List<T>) cloudletFinishedList;
}
/**
* Sets the cloudlet finished list.
*
* @param <T> the generic type
* @param cloudletFinishedList the new cloudlet finished list
*/
protected <T extends ResCloudlet> void setCloudletFinishedList(List<T> cloudletFinishedList) {
this.cloudletFinishedList = cloudletFinishedList;
}
/*
* (non-Javadoc)
* @see org.cloudbus.cloudsim.CloudletScheduler#getCurrentRequestedMips()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment