コード例 #1
0
 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);
 }
コード例 #2
0
 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;
         }
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 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;
             }
         }
     }
 }