Java cloudsim的弹性

Java cloudsim的弹性,java,cloud,scheduled-tasks,cloudsim,elasticity,Java,Cloud,Scheduled Tasks,Cloudsim,Elasticity,我正在研究一种云计算的任务调度方法,问题是我想在运行时创建虚拟机,以便有弹性并降低任务拒绝率,但我不知道如何做到这一点,我应该把创建虚拟机的代码放在哪里:-?使用你可以做到这一点,而无需更改框架代码。CloudSim Plus提供了不同的事件侦听器,可用于动态创建Cloudlet或VM。它甚至允许您提交此类对象,而无需创建新的代理。要完成此操作的代码段如下所示: //Constructor of the example class private KeepSimulationRunningExa

我正在研究一种云计算的任务调度方法,问题是我想在运行时创建虚拟机,以便有弹性并降低任务拒绝率,但我不知道如何做到这一点,我应该把创建虚拟机的代码放在哪里:-?

使用你可以做到这一点,而无需更改框架代码。CloudSim Plus提供了不同的事件侦听器,可用于动态创建Cloudlet或VM。它甚至允许您提交此类对象,而无需创建新的代理。要完成此操作的代码段如下所示:

//Constructor of the example class
private KeepSimulationRunningExample() {
  //Initializes CloudSim Plus 
  simulation = new CloudSim();

  //The simulation startup code goes here...
  //It creates objects such as Datacenters, Hosts, etc.

  //Adds a Listener that will be notified when the simulation clock changes
  simulation.addOnClockTickListener(this::createDynamicCloudletAndVm);
  simulation.start();
}

/** Creates a new VM when the simulation reaches a defined time */
private void createDynamicCloudletAndVm(EventInfo evt) {
    if((int)evt.getTime() == TIME_TO_CREATE_NEW_VM){
        Vm vm = new VmSimple(1000, 2);
        //Configure your VM here (such as setting a CloudletScheduler)
        vmList.add(vm);
        broker0.submitVm(vm);
    }
}
完整的示例可用。显示了使用不同侦听器创建VM和Cloudlet的其他示例