原文出处:http://blog.csdn.net/chhaj5236/article/details/6422425
虚拟机分配指的是,选择满足特定条件(内存、软件环境配置等)的主机创建虚拟机的过程,这个过程由Datacenter对象负责。VmAllocationPolicy这个抽象类代表的就是这个过程。用户可以通过继承该类实现自己的分配策略,CloudSim中,作者实现了一种简单的分配策略——VmAllocationPolicySimple。方法allocateHostForVm(Vm vm)是该类的核心,它实现了从主机列表中选择一台主机,并在其上创建虚拟机vm。主要实现过程的描述如下: (1) 记录下所有主机可用的处理器核心数。 (2) 从中选出可用处理器核心数最多的第一台主机,并尝试在其上创建虚拟机。 (3) 如果(2)失败了且还有主机没有尝试过,就排除当前选择的这台主机,重做(2)。 (4) 根据虚拟机是否创建成功,返回true或false。 源代码(版本2.1.1)分析如下:
[java] view plain copy
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/182265.html原文链接:https://javaforall.cn