Exemple #1
0
 private void SetLastServiceStatus(HAServiceStatus status)
 {
     lock (this)
     {
         this.lastServiceState = status;
         foreach (HealthMonitor.ServiceStateCallback cb in serviceStateCallbacks)
         {
             cb.ReportServiceStatus(lastServiceState);
         }
     }
 }
            /// <exception cref="System.IO.IOException"/>
            public virtual HAServiceStatus GetServiceStatus()
            {
                this.CheckUnreachable();
                HAServiceStatus ret = new HAServiceStatus(this._enclosing.state);

                if (this._enclosing.state == HAServiceProtocol.HAServiceState.Standby || this._enclosing
                    .state == HAServiceProtocol.HAServiceState.Active)
                {
                    ret.SetReadyToBecomeActive();
                }
                return(ret);
            }
Exemple #3
0
 /// <exception cref="System.Exception"/>
 private void DoHealthChecks()
 {
     while (shouldRun)
     {
         HAServiceStatus status  = null;
         bool            healthy = false;
         try
         {
             status = proxy.GetServiceStatus();
             proxy.MonitorHealth();
             healthy = true;
         }
         catch (Exception t)
         {
             if (IsHealthCheckFailedException(t))
             {
                 Log.Warn("Service health check failed for " + targetToMonitor + ": " + t.Message);
                 EnterState(HealthMonitor.State.ServiceUnhealthy);
             }
             else
             {
                 Log.Warn("Transport-level exception trying to monitor health of " + targetToMonitor
                          + ": " + t.InnerException + " " + t.GetLocalizedMessage());
                 RPC.StopProxy(proxy);
                 proxy = null;
                 EnterState(HealthMonitor.State.ServiceNotResponding);
                 Thread.Sleep(sleepAfterDisconnectMillis);
                 return;
             }
         }
         if (status != null)
         {
             SetLastServiceStatus(status);
         }
         if (healthy)
         {
             EnterState(HealthMonitor.State.ServiceHealthy);
         }
         Thread.Sleep(checkIntervalMillis);
     }
 }
Exemple #4
0
 public virtual void ReportServiceStatus(HAServiceStatus status)
 {
     this._enclosing.VerifyChangedServiceState(status.GetState());
 }