cloudsim源代码学习:DatacenterBroker.java

本文档详细介绍了CloudSim框架中的DatacenterBroker类,该类作为用户代理,负责虚拟机(VM)的管理和云任务(Cloudlet)的提交与接收。类中包括了VM列表、已创建VM列表、Cloudlet列表等多个数据结构,以及用于创建、销毁VM,提交Cloudlet,处理事件等关键方法。DatacenterBroker通过与数据中心交互,实现了资源请求、VM创建确认和Cloudlet返回处理等功能。
摘要由CSDN通过智能技术生成
/*
 * 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值