private static void ReleaseReservation(ReservationBase reservation) { lock (ReservationManager.Locker) { ReservationManager.reservations.Remove(reservation.ReservationId); } }
protected virtual void VerifyStaticCapacity(ReservationBase reservation) { if (this.Utilization >= this.StaticCapacity) { this.ThrowStaticCapacityExceededException(); } }
protected override void AddReservation(ReservationBase reservation) { foreach (WlmResourceHealthMonitor wlmResourceHealthMonitor in this.healthMonitors) { wlmResourceHealthMonitor.AddReservation(reservation); } base.AddReservation(reservation); }
protected override void VerifyDynamicCapacity(ReservationBase reservation) { this.InitializeMonitors(); foreach (WlmResourceHealthMonitor wlmResourceHealthMonitor in this.healthMonitors) { wlmResourceHealthMonitor.VerifyDynamicCapacity(reservation); } }
private void ReleaseReservation(ReservationBase reservation) { lock (this.Locker) { if (this.Reservations.Remove(reservation.ReservationId) && this.UtilizationPerfCounter != null) { this.UtilizationPerfCounter.RawValue = (long)this.Utilization; } } }
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); } } }
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); }
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) }); } }
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; } } } }
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); } }
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); }
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); }); } }
protected virtual void AddReservation(ReservationBase reservation) { this.Reservations.Add(reservation.ReservationId, reservation); reservation.AddReleaseAction(new Action <ReservationBase>(this.ReleaseReservation)); }
public ResourceHealthTracker(ReservationBase reservation) { this.Reservation = reservation; this.openedContexts = new Stack <ResourceHealthTracker.BudgetCostHandle>(); this.openedContexts.Push(ResourceHealthTracker.OuterContext); }
private static bool ShouldRemoveReservation(Guid reservationID, ReservationBase reservation) { return(!reservation.IsActive); }
private void VerifyCapacity(ReservationBase reservation) { this.VerifyStaticCapacity(reservation); this.VerifyDynamicCapacity(reservation); }
protected virtual void VerifyDynamicCapacity(ReservationBase reservation) { }