Beispiel #1
0
        protected HealthInfoPersisted GetDagHealthInfo(string serverToQueryFqdn)
        {
            HealthInfoPersisted hip = null;
            Exception           ex  = MonitoringServiceClient.HandleException(delegate
            {
                TimeSpan timeSpan = TimeSpan.FromSeconds((double)this.TimeoutInSeconds);
                using (MonitoringServiceClient monitoringServiceClient = MonitoringServiceClient.Open(serverToQueryFqdn, timeSpan, timeSpan, timeSpan, MonitoringServiceClient.ReceiveTimeout))
                {
                    Task <HealthInfoPersisted> dagHealthInfoAsync = monitoringServiceClient.GetDagHealthInfoAsync();
                    if (!dagHealthInfoAsync.Wait(timeSpan))
                    {
                        throw new TimeoutException(Strings.GetDagHealthInfoRequestTimedOut(this.TimeoutInSeconds));
                    }
                    hip = dagHealthInfoAsync.Result;
                }
            });

            if (ex != null)
            {
                base.WriteError(new GetDagHealthInfoRequestException(serverToQueryFqdn, ex.Message, ex), ErrorCategory.InvalidResult, serverToQueryFqdn);
                return(null);
            }
            hip.ToString();
            return(hip);
        }
        protected override void InternalRun()
        {
            if (!ReplicationCheckGlobals.MonitoringServiceCheckHasRun)
            {
                ReplicationCheckGlobals.MonitoringServiceCheckHasRun = true;
            }
            else
            {
                ExTraceGlobals.HealthChecksTracer.TraceDebug((long)this.GetHashCode(), "MonitoringServiceCheck skipping because it has already been run once.");
                base.Skip();
            }
            if ((ReplicationCheckGlobals.ServerConfiguration & ServerConfig.Stopped) == ServerConfig.Stopped)
            {
                ExTraceGlobals.HealthChecksTracer.TraceDebug <string>((long)this.GetHashCode(), "Stopped server! Skipping {0}.", base.Title);
                base.Skip();
            }
            TimeSpan  timeout = TimeSpan.FromSeconds(5.0);
            Exception ex      = MonitoringServiceClient.HandleException(delegate
            {
                using (MonitoringServiceClient monitoringServiceClient = MonitoringServiceClient.Open(this.ServerName, timeout, timeout, timeout, timeout))
                {
                    Task <ServiceVersion> versionAsync = monitoringServiceClient.GetVersionAsync();
                    if (!versionAsync.Wait(timeout))
                    {
                        ExTraceGlobals.HealthChecksTracer.TraceError <string, TimeSpan>((long)this.GetHashCode(), "MonitoringServiceCheck: GetVersionAsync() call to server '{0}' timed out after '{1}'", this.ServerName, timeout);
                        this.Fail(Strings.MonitoringServiceRequestTimedout(this.ServerName, timeout));
                    }
                    else
                    {
                        ExTraceGlobals.HealthChecksTracer.TraceDebug <string, long>((long)this.GetHashCode(), "MonitoringServiceCheck: GetVersionAsync() call to server '{0}' returned: {1}", this.ServerName, versionAsync.Result.Version);
                    }
                }
            });

            if (ex != null)
            {
                ExTraceGlobals.HealthChecksTracer.TraceError <string, Exception>((long)this.GetHashCode(), "MonitoringServiceCheck: GetVersionAsync() call to server '{0}' failed with exception: {1}", base.ServerName, ex);
                base.Fail(Strings.MonitoringServiceRequestFailed(base.ServerName, ex.Message));
            }
        }