// Token: 0x06002248 RID: 8776 RVA: 0x0009FC80 File Offset: 0x0009DE80
        internal static void QueryLogRange(Guid dbGuid, NetworkChannel ch, out long minGen, out long maxGen, out DateTime maxGenUtc)
        {
            minGen    = 0L;
            maxGen    = 0L;
            maxGenUtc = DateTime.UtcNow;
            bool       flag             = false;
            int        timeoutToRestore = 0;
            TcpChannel tcpChannel       = null;

            try
            {
                tcpChannel = ch.TcpChannel;
                if (tcpChannel.ReadTimeoutInMs < RegistryParameters.QueryLogRangeTimeoutInMsec)
                {
                    timeoutToRestore           = tcpChannel.ReadTimeoutInMs;
                    tcpChannel.ReadTimeoutInMs = RegistryParameters.QueryLogRangeTimeoutInMsec;
                }
                QueryLogRangeRequest queryLogRangeRequest = new QueryLogRangeRequest(ch, dbGuid);
                queryLogRangeRequest.Send();
                NetworkChannelMessage message            = ch.GetMessage();
                QueryLogRangeReply    queryLogRangeReply = message as QueryLogRangeReply;
                if (queryLogRangeReply == null)
                {
                    ch.ThrowUnexpectedMessage(message);
                }
                minGen    = queryLogRangeReply.FirstAvailableGeneration;
                maxGen    = queryLogRangeReply.EndOfLogGeneration;
                maxGenUtc = queryLogRangeReply.EndOfLogUtc;
                ExTraceGlobals.LogCopyClientTracer.TraceDebug <long, long>((long)ch.GetHashCode(), "LogCopyClient:TryQueryLogRange: 0x{0:x} .. {1:x}", minGen, maxGen);
                flag = true;
            }
            finally
            {
                if (timeoutToRestore > 0)
                {
                    if (!flag)
                    {
                        NetworkChannel.RunNetworkFunction(delegate
                        {
                            tcpChannel.ReadTimeoutInMs = timeoutToRestore;
                        });
                    }
                    else
                    {
                        tcpChannel.ReadTimeoutInMs = timeoutToRestore;
                    }
                }
            }
        }
        // Token: 0x0600224B RID: 8779 RVA: 0x000A000C File Offset: 0x0009E20C
        internal static void CopyLog(Guid dbGuid, NetworkChannel ch, long logGen, string destinationFileName)
        {
            ExTraceGlobals.LogCopyClientTracer.TraceDebug <string>((long)ch.GetHashCode(), "static CopyLog {0} starting", destinationFileName);
            CopyLogRequest copyLogRequest = new CopyLogRequest(ch, dbGuid, logGen);

            copyLogRequest.Send();
            ReplayStopwatch replayStopwatch = new ReplayStopwatch();

            replayStopwatch.Start();
            NetworkChannelMessage message      = ch.GetMessage();
            CopyLogReply          copyLogReply = message as CopyLogReply;

            if (copyLogReply == null)
            {
                ch.ThrowUnexpectedMessage(message);
            }
            long elapsedMilliseconds = replayStopwatch.ElapsedMilliseconds;

            ExTraceGlobals.LogCopyClientTracer.TraceDebug <long>((long)ch.GetHashCode(), "Log Copy Response took: {0}ms", elapsedMilliseconds);
            CheckSummer summer = null;

            if (ch.ChecksumDataTransfer)
            {
                summer = new CheckSummer();
            }
            copyLogReply.ReceiveFile(destinationFileName, null, summer);
            elapsedMilliseconds = replayStopwatch.ElapsedMilliseconds;
            ExTraceGlobals.LogCopyClientTracer.TraceDebug <long>((long)ch.GetHashCode(), "Transmit/Decomp took: {0}ms", elapsedMilliseconds);
            ExchangeNetworkPerfmonCounters perfCounters = ch.PerfCounters;

            if (perfCounters != null)
            {
                perfCounters.RecordLogCopyThruputReceived(copyLogReply.FileSize);
            }
            replayStopwatch.Stop();
            ExTraceGlobals.LogCopyClientTracer.TraceDebug((long)ch.GetHashCode(), "{0}: LogCopy success: {1} for {2} after {3}ms", new object[]
            {
                ExDateTime.Now,
                replayStopwatch.ToString(),
                destinationFileName,
                replayStopwatch.ElapsedMilliseconds
            });
        }
        internal static bool TestHealth(string targetServer, int targetPort, int timeOutInMs, out string errMsg)
        {
            errMsg = null;
            NetworkChannel networkChannel = null;
            Exception      ex             = null;

            ExTraceGlobals.TcpChannelTracer.TraceFunction <string>(0L, "TcpHealthCheck: testing {0}", targetServer);
            try
            {
                ushort num = (ushort)targetPort;
                if (num == 0)
                {
                    num = 64327;
                }
                ITcpConnector tcpConnector = Dependencies.TcpConnector;
                NetworkPath   netPath      = tcpConnector.BuildDnsNetworkPath(targetServer, (int)num);
                networkChannel = NetworkChannel.Connect(netPath, TcpChannel.GetDefaultTimeoutInMs(), false);
                TestHealthRequest testHealthRequest = new TestHealthRequest(networkChannel);
                testHealthRequest.Send();
                NetworkChannelMessage message = networkChannel.GetMessage();
                if (!(message is TestHealthReply))
                {
                    networkChannel.ThrowUnexpectedMessage(message);
                }
                ExTraceGlobals.TcpChannelTracer.TraceFunction <string>(0L, "TcpHealthCheck: {0} is healthy", targetServer);
                return(true);
            }
            catch (NetworkRemoteException ex2)
            {
                ex = ex2.InnerException;
            }
            catch (NetworkTransportException ex3)
            {
                ex = ex3;
            }
            catch (Win32Exception ex4)
            {
                ex = ex4;
            }
            catch (COMException ex5)
            {
                ex = ex5;
            }
            catch (ClusCommonFailException ex6)
            {
                ex = ex6;
            }
            catch (ClusCommonTransientException ex7)
            {
                ex = ex7;
            }
            finally
            {
                if (networkChannel != null)
                {
                    networkChannel.Close();
                }
            }
            if (ex != null)
            {
                ExTraceGlobals.TcpChannelTracer.TraceError <Exception>(0L, "TcpHealthCheck: failed: {0}", ex);
                errMsg = ex.Message;
            }
            return(false);
        }