CloudSim4.0 Learning(1)

本文档详细介绍了CloudSim4.0的初始设置,包括CloudSim的初始化、DataCenter的创建、DatacenterBroker的声明、虚拟机的创建、云任务清单的设定、模拟执行流程及终止条件。重点讲解了各步骤的关键函数和参数,如CloudSim.init(), DatacenterBroker构造函数,以及模拟运行过程中的状态检查和控制。" 114444154,10536939,Python实现飞船游戏:纵向移动与箭头速度调整,"['Python编程', '游戏开发', 'pygame库', '用户交互']
摘要由CSDN通过智能技术生成

CloudSim4.0 Learning(1)


Example1

1 CloudSim初始化

int num_user = 1;
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false;
CloudSim.init(num_user, calendar, trace_flag);

这一部分代码主要是初始化模拟程序
num_user是控制用户数量的一个参数
calendar是控制时间的参数
trace_flag 控制日志的输出[有待进一步查证]我改成true之后毫无变化

1.1 CloudSim.init(num_user, calendar, trace_flag)

调用CloudSim类中的initCommonVariable(cal, traceFlag, numUser);设置calendar、numUser、traceFlag
cis = new CloudInformationService("CloudInformationService");则是声明一个新的CIS对象,用来存储仿真信息。 原文的相关表述如下:A Cloud Information Service (CIS) is an entity that provides cloud resource registration CIS提供的应该是注册表的服务,会记录所有的Entity的ID,但不负责具体的信息的管理。

public static void init(int numUser, Calendar cal, boolean traceFlag) {
   
		try {
   
			initCommonVariable(cal, traceFlag, numUser);
			// create a CIS object
			cis = new CloudInformationService("CloudInformationService");//初始化CloudInformationService
			// set all the above entity IDs
			cisId = cis.getId();
			Log.printLine("cisId:"+cisId);
		} catch (IllegalArgumentException s) {
   
			Log.printLine("CloudSim.init(): The simulation has been terminated due to an unexpected error");
			Log.printLine(s.getMessage());
		} catch (Exception e) {
   
			Log.printLine("CloudSim.init(): The simulation has been terminated due to an unexpected error");
			Log.printLine(e.getMessage());
		}
	}

1.2 initCommonVariable(cal, traceFlag, numUser);

该函数主要是为了设置calendar、traceFlag和numUser
还调用了CloudSimShutdown shutdown = new CloudSimShutdown("CloudSimShutdown", numUser);根据源代码的注释来看就是个结束的标识。原文如下:This object signals the end of simulation to CloudInformationService (CIS) entity.

private static void initCommonVariable(Calendar _calendar, boolean _traceFlag, int numUser)
			throws Exception {
   
		initialize();
		// NOTE: the order for the below 3 lines are important
		traceFlag = _traceFlag;
		// Set the current Wall clock time as the starting time of
		// simulation
		if (_calendar == null) {
   
			calendar = Calendar.getInstance();
		} else {
   
			calendar = _calendar;
		}
		// creates a CloudSimShutdown object
		CloudSimShutdown shutdown = new CloudSimShutdown("CloudSimShutdown", numUser);
		shutdownId = shutdown.getId();
		Log.print(shutdownId+"\n");
	}

2 DataCenter初始化

Datacenter datacenter0 = createDatacenter("Datacenter_0");

创建了一个名为’Datacenter_0’的datacenter0变量
Datacenter类
包含如下域:
characteristicsDatacenterCharacteristics类,主要负责存储datacenter的特征。
regionalCisName主要是负责存储原始的CIS信息。
vmAllocationPolicy主要负责控制虚拟机的分配策略。
lastProcessTime负责记录云任务列表最后一次被运行的时间
vmList负责记录虚拟机的列表
schedulingInterval调度间隔,每隔多长时间调度一次event

/** The characteristics. */
private DatacenterCharacteristics characteristics;
/** The regional Cloud Information Service (CIS) name.*@see org.cloudbus.cloudsim.core.CloudInformationService*/
private String regionalCisName;
/** The vm provisioner. */
private VmAllocationPolicy vmAllocationPolicy;
/** The last time some cloudlet was processed in the datacenter. */
private double lastProcessTime;
/** The storage list. */
private List<Storage> storageList;
/** The vm list. */
private List<? extends Vm> vmList;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值