/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.core.CloudSimTags;
import org.cloudbus.cloudsim.core.SimEntity;
import org.cloudbus.cloudsim.core.SimEvent;
import org.cloudbus.cloudsim.lists.CloudletList;
import org.cloudbus.cloudsim.lists.VmList;
/**
* DatacentreBroker represents a broker
* acting on behalf of a user. It hides VM management,
* as vm creation, sumbission of cloudlets to this VMs
* and destruction of VMs.
*
* @author Rodrigo N. Calheiros
* @author Anton Beloglazov
* @since CloudSim Toolkit 1.0
*/
//datacenter 代理,隐藏VM管理,如VM创建,提交Cloudlet,和VM销毁
public class DatacenterBroker extends SimEntity {
// TODO: remove unnecessary variables
//vm列表
/** The vm list. */
private List<? extends Vm> vmList;
//建立的vm列表
/** The vms created list. */
private List<? extends Vm> vmsCreatedList;
//cloudlet列表
/** The cloudlet list. */
private List<? extends Cloudlet> cloudletList;
//cloudlet提交列表
/** The cloudlet submitted list. */
private List<? extends Cloudlet> cloudletSubmittedList;
//收到的cloudlet列表
/** The cloudlet received list. */
private List<? extends Cloudlet> cloudletReceivedList;
//提交的cloudlet数
/** The cloudlets submitted. */
private int cloudletsSubmitted;
//请求的vm数量
/** The vms requested. */
private int vmsRequested;
//vm响应数
/** The vms acks. */
private int vmsAcks;
//销毁的VM数
/** The vms destroyed. */
private int vmsDestroyed;
//数据中心ID列表
/** The datacenter ids list. */
private List<Integer> datacenterIdsList;
//请求的数据中心id列表
/** The datacenter requested ids list. */
private List<Integer> datacenterRequestedIdsList;
//vm到数据中心映射
/** The vms to datacenters map. */
private Map<Integer, Integer> vmsToDatacentersMap;
//数据中心特征列表
/** The datacenter characteristics list. */
private Map<Integer, DatacenterCharacteristics> datacenterCharacteristicsList;
/**
* Created a new DatacenterBroker object.
*
* @param name name to be associated with this entity (as
* required by Sim_entity class from simjava package)
*
* @throws Exception the exception
*
* @pre name != null
* @post $none
*/
//创建数据中心代理
public DatacenterBroker(String name) throws Exception {
super(name);
setVmList(new ArrayList<Vm>());
setVmsCreatedList(new ArrayList<Vm>());
setCloudletList(new ArrayList<Cloudlet>());
setCloudletSubmittedList(new ArrayList<Cloudlet>());
setCloudletReceivedList(new ArrayList<Cloudlet>());
cloudletsSubmitted=0;
setVmsRequested(0);
setVmsAcks(0);
setVmsDestroyed(0);
setDatacenterIdsList(new LinkedList<Integer>());
setDatacenterRequestedIdsList(new ArrayList<Integer>());
setVmsToDatacentersMap(new HashMap<Integer, Integer>());
setDatacenterCharacteristicsList(new HashMap<Integer, DatacenterCharacteristics>());
}
/**
* 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
*/
//提交VM
public void submitVmList(List<? extends Vm> list) {
getVmList().addAll(list);
}
/**
* This method is used to send to the broker the list of
* cloudlets.
*
* @param list the list
*
* @pre list !=null
* @post $none
*/
//提交cloudlet
public void submitCloudletList(List<? extends Cloudlet> list){
getC
cloudsim源代码学习:DatacenterBroker.java
最新推荐文章于 2022-08-13 22:02:06 发布
本文档详细介绍了CloudSim框架中的DatacenterBroker类,该类作为用户代理,负责虚拟机(VM)的管理和云任务(Cloudlet)的提交与接收。类中包括了VM列表、已创建VM列表、Cloudlet列表等多个数据结构,以及用于创建、销毁VM,提交Cloudlet,处理事件等关键方法。DatacenterBroker通过与数据中心交互,实现了资源请求、VM创建确认和Cloudlet返回处理等功能。
摘要由CSDN通过智能技术生成