Beispiel #1
0
        private void TimeoutCallback(object state, bool timedOut)
        {
            this.UnregisterWaitHandle();
            TimeSpan timeSpan = TimeProvider.UtcNow - this.lastPingAttemptUtc;

            if (timeSpan < MdbSystemMailboxPinger.PingTimeout)
            {
                ExTraceGlobals.DatabasePingerTracer.TraceError <TimeSpan, TimeSpan, Guid>((long)this.GetHashCode(), "Timeout was called before PingTimeout reached.  Ignoring.  Elapsed: {0}, PingTimeout: {1}, Database: {2}", timeSpan, MdbSystemMailboxPinger.PingTimeout, this.databaseGuid);
                return;
            }
            if (timedOut)
            {
                PingerPerfCounterWrapper.PingTimedOut();
                if (MdbSystemMailboxPinger.OnPingTimeout != null)
                {
                    MdbSystemMailboxPinger.OnPingTimeout(this.databaseGuid, MdbSystemMailboxPinger.PingTimeout);
                }
                ExTraceGlobals.DatabasePingerTracer.TraceError <Guid>((long)this.GetHashCode(), "Ping for Mdb '{0}' timed out.  This might suggest that the remote server is down.", this.databaseGuid);
                StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_ErrorDatabasePingTimedOut, string.Empty, new object[]
                {
                    this.databaseGuid,
                    timeSpan,
                    (this.lastSuccessfulPingUtc == DateTime.MinValue) ? "[never]" : this.lastSuccessfulPingUtc.ToString()
                });
            }
        }
Beispiel #2
0
        public bool Ping()
        {
            base.CheckDisposed();
            bool flag  = false;
            bool flag2 = false;

            this.lastPingAttemptUtc = TimeProvider.UtcNow;
            try
            {
                if (!this.Pinging)
                {
                    lock (this.instanceLock)
                    {
                        if (!this.Pinging)
                        {
                            this.Pinging = true;
                            flag2        = true;
                        }
                    }
                }
                if (flag2)
                {
                    ExTraceGlobals.DatabasePingerTracer.TraceDebug <Guid>((long)this.GetHashCode(), "Attempting XSO ping against database {0}", this.databaseGuid);
                    lock (this.instanceLock)
                    {
                        PerformanceContext performanceContext = default(PerformanceContext);
                        bool flag5 = false;
                        bool flag6 = ExTraceGlobals.DatabasePingerTracer.IsTraceEnabled(TraceType.DebugTrace);
                        if (flag6)
                        {
                            flag5 = NativeMethods.GetTLSPerformanceContext(out performanceContext);
                        }
                        DateTime utcNow = TimeProvider.UtcNow;
                        flag = this.OpenSession();
                        if (flag)
                        {
                            PingerPerfCounterWrapper.PingSuccessful();
                        }
                        else
                        {
                            PingerPerfCounterWrapper.PingFailed();
                        }
                        TimeSpan           timeSpan = TimeProvider.UtcNow - utcNow;
                        PerformanceContext performanceContext2;
                        if (flag6 && flag5 && NativeMethods.GetTLSPerformanceContext(out performanceContext2))
                        {
                            uint  num  = performanceContext2.rpcCount - performanceContext.rpcCount;
                            ulong num2 = performanceContext2.rpcLatency - performanceContext.rpcLatency;
                            ExTraceGlobals.DatabasePingerTracer.TraceDebug((long)this.GetHashCode(), "Ping Stats - Mdb: {0}, Rpc Count: {1}, Rpc Latency: {2}. Elapsed: {3}", new object[]
                            {
                                this.databaseGuid,
                                num,
                                num2,
                                timeSpan
                            });
                        }
                        goto IL_17F;
                    }
                }
                ExTraceGlobals.DatabasePingerTracer.TraceError <Guid>((long)this.GetHashCode(), "Could not make ping call against mdb {0} because there is already an outstanding ping.", this.databaseGuid);
                IL_17F :;
            }
            catch (StoragePermanentException arg)
            {
                ExTraceGlobals.DatabasePingerTracer.TraceError <Guid, StoragePermanentException>((long)this.GetHashCode(), "Encountered permanent exception acquiring and pinging mdb {0}.  Exception: {1}", this.databaseGuid, arg);
                this.principal = null;
                this.DisposeAccessInfo();
                this.pingerState = MdbSystemMailboxPinger.PingerState.NeedReinitialization;
                PingerPerfCounterWrapper.PingFailed();
            }
            catch (StorageTransientException arg2)
            {
                PingerPerfCounterWrapper.PingFailed();
                ExTraceGlobals.DatabasePingerTracer.TraceError <Guid, StorageTransientException>((long)this.GetHashCode(), "Encountered transient exception acquiring and pinging mdb {0}.  Exception: {1}", this.databaseGuid, arg2);
            }
            catch (Exception)
            {
                PingerPerfCounterWrapper.PingFailed();
                throw;
            }
            finally
            {
                if (flag2)
                {
                    lock (this.instanceLock)
                    {
                        this.Pinging = false;
                    }
                }
            }
            return(flag);
        }