/** * Processes a Cloudlet cancel request. * * @param cloudletId ID of the cloudlet to be canceled * @param userId ID of the cloudlet's owner * @param vmId the id of the VM where the cloudlet has to be canceled * * @pre $none * @post $none */ protected void processCloudletCancel(int cloudletId, int userId, int vmId) { Cloudlet cl = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId) .getCloudletScheduler().cloudletCancel(cloudletId); sendNow(userId, CloudSimTags.CLOUDLET_CANCEL, cl); }
/** * Verifies if some cloudlet inside this Datacenter already finished. * If yes, send it to the User/Broker * * @pre $none * @post $none */ protected void checkCloudletCompletion() { List<? extends Host> list = getVmAllocationPolicy().getHostList(); for (int i = 0; i < list.size(); i++) { Host host = list.get(i); for (Vm vm : host.getVmList()) { while (vm.getCloudletScheduler().isFinishedCloudlets()) { Cloudlet cl = vm.getCloudletScheduler().getNextFinishedCloudlet(); if (cl != null) { sendNow(cl.getUserId(), CloudSimTags.CLOUDLET_RETURN, cl); } } } } }
/** * Process the event for an User/Broker who wants to destroy a VM previously created in this * Datacenter. This Datacenter may send, upon request, the status back to the * User/Broker. * * @param ev information about the event just happened * @param ack indicates if the event's sender expects to receive * an acknowledge message when the event finishes to be processed * * @pre ev != null * @post $none */ protected void processVmDestroy(SimEvent ev, boolean ack) { Vm vm = (Vm) ev.getData(); getVmAllocationPolicy().deallocateHostForVm(vm); if (ack) { int[] data = new int[3]; data[0] = getId(); data[1] = vm.getId(); data[2] = CloudSimTags.TRUE; sendNow(vm.getUserId(), CloudSimTags.VM_DESTROY_ACK, data); } getVmList().remove(vm); }
Host host = (Host) migrate.get("host"); getVmAllocationPolicy().deallocateHostForVm(vm); host.removeMigratingInVm(vm); boolean result = getVmAllocationPolicy().allocateHostForVm(vm, host); if (!result) { Log.printLine("[Datacenter.processVmMigrate] VM allocation to the destination host failed");
/** * Processes a Cloudlet pause request. * * @param cloudletId ID of the cloudlet to be paused * @param userId ID of the cloudlet's owner * @param ack indicates if the event's sender expects to receive * an acknowledge message when the event finishes to be processed * @param vmId the id of the VM where the cloudlet has to be paused * * @pre $none * @post $none */ protected void processCloudletPause(int cloudletId, int userId, int vmId, boolean ack) { boolean status = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId) .getCloudletScheduler().cloudletPause(cloudletId); if (ack) { int[] data = new int[3]; data[0] = getId(); data[1] = cloudletId; if (status) { data[2] = CloudSimTags.TRUE; } else { data[2] = CloudSimTags.FALSE; } sendNow(userId, CloudSimTags.CLOUDLET_PAUSE_ACK, data); } }
Vm vm = (Vm) ev.getData(); boolean result = getVmAllocationPolicy().allocateHostForVm(vm); vm.updateVmProcessing(CloudSim.clock(), getVmAllocationPolicy().getHost(vm).getVmScheduler() .getAllocatedMipsForVm(vm));
vmId = data[2]; status = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId).getCloudletScheduler() .getCloudletStatus(cloudletId); userId = cl.getUserId(); status = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId) .getCloudletScheduler().getCloudletStatus(cloudletId); } catch (Exception e) {
List<? extends Host> list = getVmAllocationPolicy().getHostList(); double smallerTime = Double.MAX_VALUE;
double eventTime = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId) .getCloudletScheduler().cloudletResume(cloudletId);
Cloudlet cl = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId) .getCloudletScheduler().cloudletCancel(cloudletId); Vm vm = getVmAllocationPolicy().getHost(vmDestId, userId).getVm(vmDestId,userId); if (vm == null) { failed = true;
Host host = getVmAllocationPolicy().getHost(vmId, userId); Vm vm = host.getVm(vmId, userId); CloudletScheduler scheduler = vm.getCloudletScheduler();