private void _WaitForReboot(bool master, ref Session session, MetricDelegate metricDelegate, DelegateWithSession methodInvoker) { _cancelled = false; double metric = metricDelegate(session); log.DebugFormat("{0}._WaitForReboot(master='{1}', metric='{2}')", GetType().Name, master, metric); PercentComplete = 10; RegisterConnectionLostEvent(); try { methodInvoker(session); PercentComplete = 20; log.DebugFormat("{0}._WaitForReboot executed delegate...", GetType().Name); session = WaitForHostToStart(master, session, metricDelegate, metric); } finally { DeregisterConnectionLostEvent(); } }
/// <summary> /// Provides a wrapper to a list a functions that can be used to /// measure the performance of a filter. /// </summary> /// <param name="listMetrics"> /// List of metric functions to use to calculate the filter's performance. /// </param> internal Metric(MetricDelegate[] listMetrics) { // Preparse list of metrics ... _listMetrics = new List<MetricMethod>(); if (null != listMetrics) { foreach (MetricDelegate metric in listMetrics) { MetricMethod mm = new MetricMethod(metric); _listMetrics.Add(mm); } } }
private Session WaitForHostToStart(bool master, Session session, MetricDelegate metricDelegate, double metric) { Connection.ExpectDisruption = true; try { if (master) { Connection.SupressErrors = true; // // Wait for a dissconnection // WaitForDisconnection(); // // Now, we need to wait for a reconnection // session = WaitReconnectToMaster(session); } PercentComplete = 60; // // Now wait for boot time to be greater than it was before // WaitForBootTimeToBeGreaterThanBefore(master, session, metricDelegate, metric); log.DebugFormat("{0}._WaitForReboot done!", GetType().Name); } finally { Connection.SupressErrors = false; } return(session); }
private void WaitForBootTimeToBeGreaterThanBefore(bool master, Session session, MetricDelegate metricDelegate, double metric) { DateTime waitForMetric = DateTime.Now; int lastMetricDebug = 0; log.DebugFormat("{0}._WaitForReboot waiting for metric to update... (metric='{1}')", GetType().Name, metric); double currentMetric; do { currentMetric = metricDelegate(session); if (_cancelled) throw new CancelledException(); Thread.Sleep(1000); // Debug message once a minute int currMin = (int)((DateTime.Now - waitForMetric).TotalSeconds) / 60; if (currMin <= lastMetricDebug) continue; lastMetricDebug = currMin; log.DebugFormat("{0}._WaitForReboot still waiting for metric after {1}... (old metric='{2}', current metric='{3}')", GetType().Name, DateTime.Now - waitForMetric, metric, currentMetric); } while (metric == currentMetric); Thread.Sleep(1000); log.DebugFormat("{0}._WaitForReboot metric now up to date... (old metric='{1}', current metric='{2}')", GetType().Name, metric, currentMetric); if (master) { // // Force a reconnect to prime the cache for the next actions // log.DebugFormat("{0}._WaitForReboot connecting up...", GetType().Name); Program.Invoke(Program.MainWindow, () => XenConnectionUI.BeginConnect(Connection, false, null, false)); } }
private Session WaitForHostToStart(bool master, Session session, MetricDelegate metricDelegate, double metric) { Connection.ExpectDisruption = true; try { if (master) { Connection.SupressErrors = true; // // Wait for a dissconnection // WaitForDisconnection(); // // Now, we need to wait for a reconnection // session = WaitReconnectToMaster(session); } PercentComplete = 60; // // Now wait for boot time to be greater than it was before // WaitForBootTimeToBeGreaterThanBefore(master, session, metricDelegate, metric); log.DebugFormat("{0}._WaitForReboot done!", GetType().Name); } finally { Connection.SupressErrors = false; } return session; }
private void WaitForBootTimeToBeGreaterThanBefore(bool master, Session session, MetricDelegate metricDelegate, double metric) { DateTime waitForMetric = DateTime.Now; int lastMetricDebug = 0; log.DebugFormat("{0}._WaitForReboot waiting for metric to update... (metric='{1}')", GetType().Name, metric); double currentMetric; do { currentMetric = metricDelegate(session); if (_cancelled) { throw new CancelledException(); } Thread.Sleep(1000); // Debug message once a minute int currMin = (int)((DateTime.Now - waitForMetric).TotalSeconds) / 60; if (currMin <= lastMetricDebug) { continue; } lastMetricDebug = currMin; log.DebugFormat("{0}._WaitForReboot still waiting for metric after {1}... (old metric='{2}', current metric='{3}')", GetType().Name, DateTime.Now - waitForMetric, metric, currentMetric); }while (metric == currentMetric); Thread.Sleep(1000); log.DebugFormat("{0}._WaitForReboot metric now up to date... (old metric='{1}', current metric='{2}')", GetType().Name, metric, currentMetric); if (master) { // // Force a reconnect to prime the cache for the next actions // log.DebugFormat("{0}._WaitForReboot connecting up...", GetType().Name); Program.Invoke(Program.MainWindow, delegate() { XenConnectionUI.BeginConnect(Connection, false, null, false); }); } }
public TargetSetting(MetricDelegate m, float target) { this.evaluateForMetric = m; this.targetValue = target; }