public static bool IsFullyConsumed(CloudDevice cloud) { if (cloud.CurrentAllocatedBw >= cloud.UpBW || cloud.CurrentAllocatedMips >= cloud.MIPS || cloud.CurrentAllocatedRam >= cloud.RAM || cloud.CurrentAllocatedSize >= cloud.Size) { return(true); } return(false); }
public static void ResourceReleased(Models.Tuple tuple, CloudDevice cloud) { if (cloud != null && tuple.IsServerFound == true && tuple.IsReversed == false) { lock (Lock) { cloud.CurrentAllocatedBw = cloud.CurrentAllocatedBw - tuple.BW; cloud.CurrentAllocatedMips = cloud.CurrentAllocatedMips - tuple.MIPS; cloud.CurrentAllocatedRam = cloud.CurrentAllocatedRam - tuple.RAM; cloud.CurrentAllocatedSize = cloud.CurrentAllocatedSize - tuple.Size; } } }
public static CloudDevice CloudComputation(Models.Tuple tuple, CloudDevice cloud) { var rnd = new Random(); double[] arrLatency = { 40, 50, 60 }; var dis = GeoDistance.CalcDistance(tuple.GeoLocation.getLongitude(), tuple.GeoLocation.getLatitude(), cloud.GeoLocation.getLongitude(), cloud.GeoLocation.getLatitude(), GeoCodeCalcMeasurement.Kilometers); lock (Lock) { cloud.DistanceFromTuple = dis; } lock (Lock) { link.Source = tuple.Name; link.Destination = cloud.Name; link.SDDistance = dis; link.Propagationtime = LinkUtility.CalculateLatency(dis, cooperSpeed, tuple.Size, transmitionRate, arrLatency[rnd.Next(arrLatency.Length)]); } CloudRersourceUtility.ResourceConsumption(tuple, cloud); return(cloud); }
public static void ResourceConsumption(Models.Tuple tuple, CloudDevice cloud) { lock (Lock) { if (cloud.CurrentAllocatedBw <= cloud.UpBW && cloud.CurrentAllocatedMips <= cloud.MIPS && cloud.CurrentAllocatedRam <= cloud.RAM && cloud.CurrentAllocatedSize <= cloud.Size) { cloud.CurrentAllocatedBw = cloud.CurrentAllocatedBw + tuple.BW; cloud.CurrentAllocatedMips = cloud.CurrentAllocatedMips + tuple.MIPS; cloud.CurrentAllocatedRam = cloud.CurrentAllocatedRam + tuple.RAM; cloud.CurrentAllocatedSize = cloud.CurrentAllocatedSize + tuple.Size; } else { lock (Lock) { tuple.IsReversed = true; //return IsReversed when server is fully occupied. tuple.IsServerFound = true; } } } }