public static void ResourceReleaseChanged(FogDevice fogDev, SFog.Models.Tuple tuple, List <FogDevice> deviceList) { lock (Lock) { var fogDevice = deviceList.FirstOrDefault(x => x.ID.Equals(fogDev.ID)); if (fogDevice != null) { fogDevice.CurrentAllocatedBw = fogDevice.CurrentAllocatedBw - tuple.BW; fogDevice.CurrentAllocatedRam = fogDevice.CurrentAllocatedRam - tuple.RAM; fogDevice.CurrentAllocatedSize = fogDevice.CurrentAllocatedSize - tuple.Size; double Mips = fogDevice.CurrentAllocatedMips - tuple.MIPS; if (Mips < 0) { fogDevice.CurrentAllocatedMips = 0; } else { fogDevice.CurrentAllocatedMips = Mips; } } else { } } }
public static bool ResourceConsumptionChanged(FogDevice fogDev, SFog.Models.Tuple tuple, List <FogDevice> deviceList) { if (fogDev == null) { return(false); } lock (Lock) { var fogDevice = deviceList.FirstOrDefault(x => x.ID.Equals(fogDev.ID)); if (fogDevice != null) { // if (fogDevice.CurrentAllocatedBw <= fogDevice.UpBW && // fogDevice.CurrentAllocatedMips <= fogDevice.MIPS && // fogDevice.CurrentAllocatedRam <= fogDevice.RAM && // fogDevice.CurrentAllocatedSize <= fogDevice.Size) if ((fogDevice.MIPS - fogDevice.CurrentAllocatedMips) >= tuple.MIPS && (fogDevice.RAM - fogDevice.CurrentAllocatedRam) >= tuple.RAM) { fogDevice.CurrentAllocatedBw = fogDevice.CurrentAllocatedBw + tuple.BW; fogDevice.CurrentAllocatedMips = fogDevice.CurrentAllocatedMips + tuple.MIPS; fogDevice.CurrentAllocatedRam = fogDevice.CurrentAllocatedRam + tuple.RAM; fogDevice.CurrentAllocatedSize = fogDevice.CurrentAllocatedSize + tuple.Size; return(true); } else { return(false); } } else { return(false); } } }
public static bool ResourceConsumptionChangedMRR(FogDevice fogDev, SFog.Models.Tuple tuple) { if (fogDev == null) { return(false); } lock (Lock) { var fogDevice = fogDev; if (fogDevice != null) { // if (fogDevice.CurrentAllocatedBw <= fogDevice.UpBW && // fogDevice.CurrentAllocatedMips <= fogDevice.MIPS && // fogDevice.CurrentAllocatedRam <= fogDevice.RAM && // fogDevice.CurrentAllocatedSize <= fogDevice.Size) if ((fogDevice.MIPS - fogDevice.CurrentAllocatedMips) >= tuple.MIPS && (fogDevice.RAM - fogDevice.CurrentAllocatedRam) >= tuple.RAM) { fogDevice.CurrentAllocatedBw = fogDevice.CurrentAllocatedBw + tuple.BW; fogDevice.CurrentAllocatedMips = fogDevice.CurrentAllocatedMips + tuple.MIPS; fogDevice.CurrentAllocatedRam = fogDevice.CurrentAllocatedRam + tuple.RAM; fogDevice.CurrentAllocatedSize = fogDevice.CurrentAllocatedSize + tuple.Size; return(true); } else { return(false); } } else { return(false); } } }