示例#1
0
 private static void ReleaseReservation(ReservationBase reservation)
 {
     lock (ReservationManager.Locker)
     {
         ReservationManager.reservations.Remove(reservation.ReservationId);
     }
 }
示例#2
0
 protected virtual void VerifyStaticCapacity(ReservationBase reservation)
 {
     if (this.Utilization >= this.StaticCapacity)
     {
         this.ThrowStaticCapacityExceededException();
     }
 }
示例#3
0
 protected override void AddReservation(ReservationBase reservation)
 {
     foreach (WlmResourceHealthMonitor wlmResourceHealthMonitor in this.healthMonitors)
     {
         wlmResourceHealthMonitor.AddReservation(reservation);
     }
     base.AddReservation(reservation);
 }
示例#4
0
 protected override void VerifyDynamicCapacity(ReservationBase reservation)
 {
     this.InitializeMonitors();
     foreach (WlmResourceHealthMonitor wlmResourceHealthMonitor in this.healthMonitors)
     {
         wlmResourceHealthMonitor.VerifyDynamicCapacity(reservation);
     }
 }
示例#5
0
 private void ReleaseReservation(ReservationBase reservation)
 {
     lock (this.Locker)
     {
         if (this.Reservations.Remove(reservation.ReservationId) && this.UtilizationPerfCounter != null)
         {
             this.UtilizationPerfCounter.RawValue = (long)this.Utilization;
         }
     }
 }
示例#6
0
 private static void RemoveReservationCallback(Guid reservationID, ReservationBase reservation, RemoveReason reason)
 {
     lock (ReservationManager.Locker)
     {
         if (!reservation.IsDisposed)
         {
             reservation.Dispose();
         }
     }
 }
 protected override void ThrowStaticCapacityExceededException()
 {
     using (Dictionary <Guid, ReservationBase> .ValueCollection.Enumerator enumerator = base.Reservations.Values.GetEnumerator())
     {
         if (enumerator.MoveNext())
         {
             ReservationBase reservationBase = enumerator.Current;
             throw new MoveInProgressReservationException(string.Format("{0}({1})", this.ResourceType, this.ResourceName), reservationBase.ClientName);
         }
     }
 }
示例#8
0
        public static ReservationBase CreateReservation(Guid mailboxGuid, TenantPartitionHint partitionHint, Guid resourceId, ReservationFlags flags, string clientName)
        {
            ReservationBase result;

            lock (ReservationManager.Locker)
            {
                ReservationBase reservationBase = ReservationBase.CreateReservation(mailboxGuid, partitionHint, resourceId, flags, clientName);
                ReservationManager.reservations.TryInsertSliding(reservationBase.ReservationId, reservationBase, ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("ReservationExpirationInterval"));
                reservationBase.AddReleaseAction(new Action <ReservationBase>(ReservationManager.ReleaseReservation));
                result = reservationBase;
            }
            return(result);
        }
示例#9
0
 private void ReleaseReservation(ReservationBase reservation, IResourceAdmissionControl admissionControl)
 {
     try
     {
         admissionControl.Release(this.Owner.WorkloadClassification);
     }
     catch (NonOperationalAdmissionControlException ex)
     {
         MrsTracer.Common.Warning("Releasing a reservation from a non-operational AdmissionControl instance. Ignoring exception {0}", new object[]
         {
             CommonUtils.FullExceptionMessage(ex, true)
         });
     }
 }
示例#10
0
 public void Reserve(ReservationBase reservation)
 {
     lock (this.Locker)
     {
         if (!this.Reservations.ContainsKey(reservation.ReservationId))
         {
             this.VerifyCapacity(reservation);
             this.AddReservation(reservation);
             if (this.UtilizationPerfCounter != null)
             {
                 this.UtilizationPerfCounter.RawValue = (long)this.Utilization;
             }
         }
     }
 }
示例#11
0
        public void VerifyDynamicCapacity(ReservationBase reservation)
        {
            if (this.IsDisabled)
            {
                return;
            }
            ResourceLoad currentLoad = this.GetCurrentLoad();

            if (currentLoad.State == ResourceLoadState.Overloaded || currentLoad.State == ResourceLoadState.Critical)
            {
                throw new WlmResourceUnhealthyException(this.Owner.ResourceName, this.Owner.ResourceType, this.WlmResourceKey.ToString(), (int)this.WlmResourceKey.MetricType, currentLoad.LoadRatio, currentLoad.State.ToString(), (currentLoad.Metric != null) ? currentLoad.Metric.ToString() : "(null)");
            }
            if (!this.DynamicThrottlingDisabled && this.Owner.Utilization >= this.DynamicCapacity)
            {
                throw new WlmCapacityExceededReservationException(this.Owner.ResourceName, this.Owner.ResourceType, this.WlmResourceKey.ToString(), (int)this.WlmResourceKey.MetricType, this.DynamicCapacity);
            }
        }
示例#12
0
        public static XElement GetReservationsDiagnosticInfo(MRSDiagnosticArgument arguments)
        {
            XElement xelement = new XElement("Reservations");

            lock (ReservationManager.Locker)
            {
                using (List <ReservationBase> .Enumerator enumerator = ReservationManager.reservations.Values.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ReservationBase reservation = enumerator.Current;
                        xelement.Add(arguments.RunDiagnosticOperation(() => reservation.GetDiagnosticInfo(arguments)));
                    }
                }
            }
            return(xelement);
        }
示例#13
0
 public void AddReservation(ReservationBase reservation)
 {
     if (!this.IsDisabled && !this.DynamicThrottlingDisabled)
     {
         IResourceAdmissionControl admissionControl = this.admissionControl;
         double num;
         if (!admissionControl.TryAcquire(this.Owner.WorkloadClassification, out num))
         {
             ResourceLoad currentLoad = this.GetCurrentLoad();
             throw new WlmResourceUnhealthyException(this.Owner.ResourceName, this.Owner.ResourceType, this.WlmResourceKey.ToString(), (int)this.WlmResourceKey.MetricType, currentLoad.LoadRatio, currentLoad.State.ToString(), (currentLoad.Metric != null) ? currentLoad.Metric.ToString() : "(null)");
         }
         reservation.AddReleaseAction(delegate(ReservationBase r)
         {
             this.ReleaseReservation(r, admissionControl);
         });
     }
 }
示例#14
0
 protected virtual void AddReservation(ReservationBase reservation)
 {
     this.Reservations.Add(reservation.ReservationId, reservation);
     reservation.AddReleaseAction(new Action <ReservationBase>(this.ReleaseReservation));
 }
示例#15
0
 public ResourceHealthTracker(ReservationBase reservation)
 {
     this.Reservation    = reservation;
     this.openedContexts = new Stack <ResourceHealthTracker.BudgetCostHandle>();
     this.openedContexts.Push(ResourceHealthTracker.OuterContext);
 }
示例#16
0
 private static bool ShouldRemoveReservation(Guid reservationID, ReservationBase reservation)
 {
     return(!reservation.IsActive);
 }
示例#17
0
 private void VerifyCapacity(ReservationBase reservation)
 {
     this.VerifyStaticCapacity(reservation);
     this.VerifyDynamicCapacity(reservation);
 }
示例#18
0
 protected virtual void VerifyDynamicCapacity(ReservationBase reservation)
 {
 }