【问题标题】:How can we create VM and Cloudlets dynamically in cloudsim afterCloudSim.startSimulation() is being called?在调用 CloudSim.startSimulation() 之后,我们如何在 cloudsim 中动态创建 VM 和 Cloudlets?
【发布时间】:2018-09-11 12:25:05
【问题描述】:

在调用 CloudSim.startSimulation() 之后,我们如何在 cloudsim 中动态创建 VM 和 Cloudlets? 我正在尝试随着模拟的进行动态地将 vms 和 cloudlets 添加到已经存在的代理中。 我试过这个:

CloudSim.startSimulation();
vm_list = create_vm(brokerId, 1, 6); //creating 1 vms,ID=6  
cloudlet_list = create_cloudlet(brokerId, 1, 6); // creating 1 cloudlet,CloudletId=6

broker.submitVmList(vm_list);
broker.submitCloudletList(cloudlet_list);

但是这段代码不起作用,CloudSim 没有考虑到小云。任何人都可以提出一些方法让我能够在模拟开始后添加虚拟机和动态调度小云吗?

【问题讨论】:

    标签: cloud cloudsim


    【解决方案1】:

    在 CloudSim 中,开始模拟后,您无法创建新对象,而无需添加新线程,暂停模拟,然后添加所需的对象。

    CloudSim Plus 中,您可以通过两种不同的方式轻松完成此操作。

    1) 您可以在提交 Cloudlet 或 VM 时定义延迟:

    broker.submitCloudletList(cloudletList, delay);
    broker.submitVmList(vmList, delay);
    

    2) 您可以使用一些 CloudSim Plus 事件侦听器(例如跟踪模拟时钟何时更改的事件侦听器),然后将新的 Cloudlet 或 VM 提交给现有的代理。为此,您首先需要将以下方法添加到您的模拟类中:

    /**
     * Event listener which is called every time the simulation clock advances.
     * @param info information about the event happened.
    */
    private void clockTickListener(final EventInfo info) {
        //at the desired time, submit new cloudlets
        if(info.getTime() == 10) {
            //@todo create your new cloudlets here 
            //submits another list of new created Cloudlets
            broker.submitCloudletList(newCloudletList, delay);
        }
    }
    

    simulation.start()之前调用simulation.addOnClockTickListener(this::clockTickListener)

    有一套完整的例子here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多