DatacenterBroker 类
DatacenterBroker是用来做VM管理,和任务卸载管理
DatacenterBroker 的属性
用来存储broker管理的VM列表
/** The list of VMs submitted to be managed by the broker. */
protected List<? extends GuestEntity> vmList;
用来存储由broker创建的VM
/** The list of VMs created by the broker. */
protected List<? extends GuestEntity> vmsCreatedList;
用来存储任务集合
/** The list of cloudlet submitted to the broker.
* @see #submitCloudletList(java.util.List)
*/
protected List<? extends Cloudlet> cloudletList;
/** The list of submitted cloudlets. */
protected List<? extends Cloudlet> cloudletSubmittedList;
/** The list of received cloudlet. */
protected List<? extends Cloudlet> cloudletReceivedList;
提交的任务列表的数量
/** The number of submitted cloudlets. */
protected int cloudletsSubmitted;
要求创建VM的请求数量
/** The number of requests to create VM. */
protected int vmsRequested;
应答创建VM的请求的数量
/** The number of acknowledges (ACKs) sent in response to
* VM creation requests. */
protected int vmsAcks;
销毁的VM数量
/** The number of destroyed VMs. */
protected int vmsDestroyed;
datacenter中当先可用的id列表
/** The id's list of available datacenters. */
protected List<Integer> datacenterIdsList;
要求放置VM的datacenter列表
/** The list of datacenters where was requested to place VMs. */
protected List<Integer> datacenterRequestedIdsList;
vm和datacenter的对应map
/** The vms to datacenters map, where each key is a VM id
* and each value is the datacenter id whwere the VM is placed. */
protected Map<Integer, Integer> vmsToDatacentersMap;
datacenter和特征对应的map
/** The datacenter characteristics map where each key
* is a datacenter id and each value is its characteristics.. */
protected Map<Integer, DatacenterCharacteristics> datacenterCharacteristicsList;
下一个发送任务列表的用户
/** Next guest to which send the cloudlet */
private int guestIndex = 0;
DatacenterBroker 中的方法(可直接调用的)
创建一个broker对象
/**
* Created a new DatacenterBroker object.
*
* @param name name to be associated with this entity (as required by {@link SimEntity} class)
* @throws Exception the exception
* @pre name != null
* @post $none
*/
public DatacenterBroker(String name)
用来初始化VM
/**
* This method is used to send to the broker the list with virtual machines that must be
* created.
*
* @param list the list
* @pre list !=null
* @post $none
*/
public void submitGuestList(List<? extends GuestEntity> list)
发送任务列表到broker
/**
* This method is used to send to the broker the list of cloudlets.bindCloudletToVm
*
* @param list the list
* @pre list !=null
* @post $none
*
* //TODO The name of the method is confused with the {@link #submitCloudlets()},
* that in fact submit cloudlets to VMs. The term "submit" is being used
* ambiguously. The method {@link #submitCloudlets()} would be named "sendCloudletsToVMs"
* The method {@link #submitGuestList(List)} may have
* be checked too.
*/
public void submitCloudletList(List<? extends Cloudlet> list)
将任务在指定VM中运行
/**
* Specifies that a given cloudlet must run in a specific virtual machine.
*
* @param cloudletId ID of the cloudlet being bount to a vm
* @param vmId the vm id
* @pre cloudletId > 0
* @pre id > 0
* @post $none
*/
public void bindCloudletToVm(int cloudletId, int vmId)
在datacenter中创建VM
/**
* Create the submitted virtual machines in a datacenter.
*
* @param datacenterId Id of the chosen Datacenter
* @pre $none
* @post $none
* @see #submitGuestList(List)
*/
protected void createVmsInDatacenter(int datacenterId)
将任务列表提交到VM中
/**
* Submit cloudlets to the created VMs.
*
* @pre $none
* @post $none
* @see #submitCloudletList(java.util.List)
*/
protected void submitCloudlets()
销毁数据中心的所有VM
/**
* Destroy all virtual machines running in datacenters.
*
* @pre $none
* @post $none
*/
protected void clearDatacenters()
结束仿真
/**
* Send an internal event communicating the end of the simulation.
*
* @pre $none
* @post $none
*/
protected void finishExecution()
拿到vm列表
/**
* Gets the vm list.
*
* @param <T> the generic type
* @return the vm list
*/
@SuppressWarnings("unchecked")
public <T extends GuestEntity> List<T> getGuestList()
设置vm列表
/**
* Sets the vm list.
*
* @param <T> the generic type
* @param vmList the new vm list
*/
protected <T extends GuestEntity> void setGuestList(List<T> vmList)
拿到vm列表
/**
* Gets the cloudlet list.
*
* @param <T> the generic type
* @return the cloudlet list
*/
@SuppressWarnings("unchecked")
public <T extends Cloudlet> List<T> getCloudletList()
设置任务列表
/**
* Sets the cloudlet list.
*
* @param <T> the generic type
* @param cloudletList the new cloudlet list
*/
protected <T extends Cloudlet> void setCloudletList(List<T> cloudletList)
拿到已经提交的任务列表
/**
* Gets the cloudlet submitted list.
*
* @param <T> the generic type
* @return the cloudlet submitted list
*/
@SuppressWarnings("unchecked")
public <T extends Cloudlet> List<T> getCloudletSubmittedList()
设置提交的任务列表
/**
* Sets the cloudlet submitted list.
*
* @param <T> the generic type
* @param cloudletSubmittedList the new cloudlet submitted list
*/
protected <T extends Cloudlet> void setCloudletSubmittedList(List<T> cloudletSubmittedList)
接收到的任务列表
/**
* Gets the cloudlet received list.
*
* @param <T> the generic type
* @return the cloudlet received list
*/
@SuppressWarnings("unchecked")
public <T extends Cloudlet> List<T> getCloudletReceivedList()
设置接收到的任务列表
/**
* Sets the cloudlet received list.
*
* @param <T> the generic type
* @param cloudletReceivedList the new cloudlet received list
*/
protected <T extends Cloudlet> void setCloudletReceivedList(List<T> cloudletReceivedList)
拿到虚拟机列表
/**
* Gets the vm list.
*
* @param <T> the generic type
* @return the vm list
*/
@SuppressWarnings("unchecked")
public <T extends GuestEntity> List<T> getGuestsCreatedList()
设置虚拟机列表
/**
* Sets the vm list.
*
* @param <T> the generic type
* @param vmsCreatedList the vms created list
*/
protected <T extends GuestEntity> void setGuestsCreatedList(List<T> vmsCreatedList)
拿到VM和datacenter的map
/**
* Gets the vms to datacenters map.
*
* @return the vms to datacenters map
*/
protected Map<Integer, Integer> getVmsToDatacentersMap()