@SuppressWarnings("ForLoopReplaceableByForEach") @Override public double updateProcessing(final double currentTime) { setPreviousUtilizationMips(getUtilizationOfCpuMips()); double nextSimulationTime = Double.MAX_VALUE; /* Uses a traditional for to avoid ConcurrentModificationException, * e.g., in cases when Vm is destroyed during simulation execution.*/ for (int i = 0; i < vmList.size(); i++) { final Vm vm = vmList.get(i); final double nextTime = vm.updateProcessing(currentTime, vmScheduler.getAllocatedMips(vm)); nextSimulationTime = Math.min(nextTime, nextSimulationTime); } notifyOnUpdateProcessingListeners(nextSimulationTime); addStateHistory(currentTime); return nextSimulationTime; }
/** * Gets the packets from the local packets buffer and sends them * to VMs inside this host. */ private void sendPacketsToLocalVms() { for (final HostPacket hostPkt : pktsToSendForLocalVms) { hostPkt.setSendTime(hostPkt.getReceiveTime()); final Vm destinationVm = receiveVmPacket(hostPkt); // insert the packet in receivedlist getVmPacketScheduler(destinationVm).addPacketToListOfPacketsSentFromVm(hostPkt.getVmPacket()); } if (!pktsToSendForLocalVms.isEmpty()) { for (final Vm vm : getVmList()) { vm.updateProcessing( getSimulation().clock(), getVmScheduler().getAllocatedMips(vm)); } } pktsToSendForLocalVms.clear(); }
/** * Process the event for a Broker which wants to create a VM in this * Datacenter. This Datacenter will then send the status back to * the Broker. * * @param evt information about the event just happened * @param ackRequested indicates if the event's sender expects to receive an * acknowledge message when the event finishes to be processed * @return true if a host was allocated to the VM; false otherwise */ protected boolean processVmCreate(final SimEvent evt, final boolean ackRequested) { final Vm vm = (Vm) evt.getData(); final boolean hostAllocatedForVm = vmAllocationPolicy.allocateHostForVm(vm); if (ackRequested) { send(vm.getBroker(), getSimulation().getMinTimeBetweenEvents(), CloudSimTags.VM_CREATE_ACK, vm); } if (hostAllocatedForVm) { if (!vm.isCreated()) { vm.setCreated(true); } final List<Double> mipsList = vm.getHost().getVmScheduler().getAllocatedMips(vm); vm.updateProcessing(getSimulation().clock(), mipsList); } return hostAllocatedForVm; }