/* * (non-Javadoc) * @see org.cloudbus.cloudsim.VmAllocationPolicy#allocateHostForVm(org.cloudbus.cloudsim.Vm, * org.cloudbus.cloudsim.Host) */ @Override public boolean allocateHostForVm(Vm vm, Host host) { if (host == null) { Log.formatLine("%.2f: No suitable host found for VM #" + vm.getId() + "\n", CloudSim.clock()); return false; } if (host.vmCreate(vm)) { // if vm has been succesfully created in the host getVmTable().put(vm.getUid(), host); /* * update host cache pain information * in CacheMatrix.HOST_PAIN_LIST */ CacheMatrix.update_host_pain_add_vm(vm, host); /* * end update host cache pain information */ Log.formatLine( "%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(), CloudSim.clock()); return true; } Log.formatLine( "%.2f: Creation of VM #" + vm.getId() + " on the host #" + host.getId() + " failed\n", CloudSim.clock()); return false; }
boolean tryToAllocateVmToHost(Host host, Vm vm) { if (host.isSuitableForVm(vm)) { boolean result = host.vmCreate(vm); if (result) { printLogMsg("Vm created successfuly"); getVmTable().put(vm.getUid(), host); return true; } else { printLogMsg("Vm creation failed"); } } return false; }