// 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
            });
        }
示例#2
0
        /// <summary>
        /// 获取网络频道。
        /// </summary>
        /// <param name="name">网络频道名称。</param>
        /// <returns>要获取的网络频道。</returns>
        public INetworkChannel GetNetworkChannel(string name)
        {
            NetworkChannel networkChannel = null;

            if (m_NetworkChannels.TryGetValue(name ?? string.Empty, out networkChannel))
            {
                UnityEngine.Debug.Log(networkChannel.GetHashCode());
                return(networkChannel);
            }

            return(null);
        }
        // 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;
                    }
                }
            }
        }
示例#4
0
        internal static NetworkChannelMessage ReadMessage(NetworkChannel channel, byte[] headerBuf)
        {
            int num = 0;

            NetworkChannelMessage.MessageType messageType = (NetworkChannelMessage.MessageType)Serialization.DeserializeUInt32(headerBuf, ref num);
            if (!NetworkChannelMessage.IsValidType(messageType))
            {
                throw new NetworkUnexpectedMessageException(channel.PartnerNodeName, string.Format("Unknown Type{0}", messageType));
            }
            int num2 = (int)Serialization.DeserializeUInt32(headerBuf, ref num);

            if (num2 < 16 || num2 > 1052672)
            {
                throw new NetworkUnexpectedMessageException(channel.PartnerNodeName, string.Format("Invalid msgLen: {0}", num2));
            }
            ExTraceGlobals.NetworkChannelTracer.TraceDebug <NetworkChannelMessage.MessageType, string, string>((long)channel.GetHashCode(), "ReadMessage: Received {0} from {1} on {2}", messageType, channel.RemoteEndPointString, channel.LocalEndPointString);
            byte[] array = new byte[num2];
            Array.Copy(headerBuf, 0, array, 0, 16);
            int len = num2 - 16;

            channel.Read(array, 16, len);
            NetworkChannelMessage.MessageType messageType2 = messageType;
            if (messageType2 <= NetworkChannelMessage.MessageType.CompressionRequest)
            {
                if (messageType2 <= NetworkChannelMessage.MessageType.SeedLogCopyRequest)
                {
                    if (messageType2 <= NetworkChannelMessage.MessageType.Ping)
                    {
                        if (messageType2 <= NetworkChannelMessage.MessageType.PassiveStatus)
                        {
                            if (messageType2 == NetworkChannelMessage.MessageType.TestNetwork0)
                            {
                                return(new TestNetwork0Request(channel, array));
                            }
                            if (messageType2 != NetworkChannelMessage.MessageType.PassiveStatus)
                            {
                                goto IL_51C;
                            }
                            return(new PassiveStatusMsg(channel, array));
                        }
                        else
                        {
                            if (messageType2 == NetworkChannelMessage.MessageType.CompressionConfig)
                            {
                                return(new NetworkChannelCompressionConfigMsg(channel, array));
                            }
                            if (messageType2 != NetworkChannelMessage.MessageType.BlockModeCompressedData)
                            {
                                if (messageType2 != NetworkChannelMessage.MessageType.Ping)
                                {
                                    goto IL_51C;
                                }
                                return(new PingMessage(channel, array));
                            }
                        }
                    }
                    else if (messageType2 <= NetworkChannelMessage.MessageType.EnterBlockMode)
                    {
                        if (messageType2 == NetworkChannelMessage.MessageType.GranularTermination)
                        {
                            return(new GranularTerminationMsg(channel, array));
                        }
                        if (messageType2 != NetworkChannelMessage.MessageType.GranularLogData)
                        {
                            if (messageType2 != NetworkChannelMessage.MessageType.EnterBlockMode)
                            {
                                goto IL_51C;
                            }
                            return(new EnterBlockModeMsg(channel, array));
                        }
                    }
                    else
                    {
                        if (messageType2 == NetworkChannelMessage.MessageType.GetE00GenerationRequest)
                        {
                            return(new GetE00GenerationRequest(channel, array));
                        }
                        if (messageType2 == NetworkChannelMessage.MessageType.CancelCiFileRequest)
                        {
                            return(new CancelCiFileRequest(channel, array));
                        }
                        if (messageType2 != NetworkChannelMessage.MessageType.SeedLogCopyRequest)
                        {
                            goto IL_51C;
                        }
                        return(new SeedLogCopyRequest(channel, array));
                    }
                    throw new NetworkUnexpectedMessageException(channel.PartnerNodeName, string.Format("ReadMessage() does not support message type: {0}.", messageType));
                }
                if (messageType2 <= NetworkChannelMessage.MessageType.CopyLogRequest)
                {
                    if (messageType2 <= NetworkChannelMessage.MessageType.SeedDatabaseFileRequest)
                    {
                        if (messageType2 == NetworkChannelMessage.MessageType.PassiveDatabaseFileRequest)
                        {
                            return(new PassiveSeedDatabaseFileRequest(channel, array));
                        }
                        if (messageType2 == NetworkChannelMessage.MessageType.SeedDatabaseFileRequest)
                        {
                            return(new SeedDatabaseFileRequest(channel, array));
                        }
                    }
                    else
                    {
                        switch (messageType2)
                        {
                        case NetworkChannelMessage.MessageType.ContinuousLogCopyRequest:
                            return(new ContinuousLogCopyRequest(channel, array));

                        case (NetworkChannelMessage.MessageType) 1363627076:
                            break;

                        case NetworkChannelMessage.MessageType.NotifyEndOfLogRequest:
                            return(new NotifyEndOfLogRequest(channel, array));

                        default:
                            if (messageType2 == NetworkChannelMessage.MessageType.TestLogExistenceRequest)
                            {
                                return(new TestLogExistenceRequest(channel, array));
                            }
                            if (messageType2 == NetworkChannelMessage.MessageType.CopyLogRequest)
                            {
                                return(new CopyLogRequest(channel, array));
                            }
                            break;
                        }
                    }
                }
                else if (messageType2 <= NetworkChannelMessage.MessageType.SeedPageReaderRollLogFileRequest)
                {
                    if (messageType2 == NetworkChannelMessage.MessageType.QueryLogRangeRequest)
                    {
                        return(new QueryLogRangeRequest(channel, array));
                    }
                    if (messageType2 == NetworkChannelMessage.MessageType.TestHealthRequest)
                    {
                        return(new TestHealthRequest(channel, array));
                    }
                    if (messageType2 == NetworkChannelMessage.MessageType.SeedPageReaderRollLogFileRequest)
                    {
                        return(new SeedPageReaderRollLogFileRequest(channel, array));
                    }
                }
                else
                {
                    if (messageType2 == NetworkChannelMessage.MessageType.SeedPageReaderMultiplePageRequest)
                    {
                        return(new SeedPageReaderMultiplePageRequest(channel, array));
                    }
                    if (messageType2 == NetworkChannelMessage.MessageType.ProgressCiFileRequest)
                    {
                        return(new ProgressCiFileRequest(channel, array));
                    }
                    if (messageType2 == NetworkChannelMessage.MessageType.CompressionRequest)
                    {
                        return(new NetworkChannelCompressionRequest(channel, array));
                    }
                }
            }
            else if (messageType2 <= NetworkChannelMessage.MessageType.SeedDatabaseFileReply)
            {
                if (messageType2 <= NetworkChannelMessage.MessageType.ContinuousLogCopyRequest2)
                {
                    if (messageType2 <= NetworkChannelMessage.MessageType.SeedCiFileRequest)
                    {
                        if (messageType2 == NetworkChannelMessage.MessageType.SeedPageReaderSinglePageRequest)
                        {
                            return(new SeedPageReaderSinglePageRequest(channel, array));
                        }
                        if (messageType2 == NetworkChannelMessage.MessageType.SeedCiFileRequest)
                        {
                            return(new SeedCiFileRequest(channel, array));
                        }
                    }
                    else
                    {
                        if (messageType2 == NetworkChannelMessage.MessageType.SeedCiFileRequest2)
                        {
                            return(new SeedCiFileRequest2(channel, array));
                        }
                        if (messageType2 == NetworkChannelMessage.MessageType.SeedPageReaderPageSizeRequest)
                        {
                            return(new SeedPageReaderPageSizeRequest(channel, array));
                        }
                        if (messageType2 == NetworkChannelMessage.MessageType.ContinuousLogCopyRequest2)
                        {
                            return(new ContinuousLogCopyRequest2(channel, array));
                        }
                    }
                }
                else if (messageType2 <= NetworkChannelMessage.MessageType.GetE00GenerationReply)
                {
                    if (messageType2 == NetworkChannelMessage.MessageType.LogCopyServerStatus)
                    {
                        return(new LogCopyServerStatusMsg(channel, array));
                    }
                    if (messageType2 == NetworkChannelMessage.MessageType.GranularLogComplete)
                    {
                        return(new GranularLogCompleteMsg(channel, array));
                    }
                    if (messageType2 == NetworkChannelMessage.MessageType.GetE00GenerationReply)
                    {
                        return(new GetE00GenerationReply(channel, array));
                    }
                }
                else
                {
                    if (messageType2 == NetworkChannelMessage.MessageType.NotifyEndOfLogAsyncReply)
                    {
                        return(new NotifyEndOfLogAsyncReply(channel, array));
                    }
                    if (messageType2 == NetworkChannelMessage.MessageType.CancelCiFileReply)
                    {
                        return(new CancelCiFileReply(channel, array));
                    }
                    if (messageType2 == NetworkChannelMessage.MessageType.SeedDatabaseFileReply)
                    {
                        return(new SeedDatabaseFileReply(channel, array));
                    }
                }
            }
            else if (messageType2 <= NetworkChannelMessage.MessageType.TestHealthReply)
            {
                if (messageType2 <= NetworkChannelMessage.MessageType.TestLogExistenceReply)
                {
                    if (messageType2 == NetworkChannelMessage.MessageType.NotifyEndOfLogReply)
                    {
                        return(new NotifyEndOfLogReply(channel, messageType, array));
                    }
                    if (messageType2 == NetworkChannelMessage.MessageType.TestLogExistenceReply)
                    {
                        return(new TestLogExistenceReply(channel, array));
                    }
                }
                else
                {
                    if (messageType2 == NetworkChannelMessage.MessageType.CopyLogReply)
                    {
                        return(new CopyLogReply(channel, array));
                    }
                    if (messageType2 == NetworkChannelMessage.MessageType.QueryLogRangeReply)
                    {
                        return(new QueryLogRangeReply(channel, array));
                    }
                    if (messageType2 == NetworkChannelMessage.MessageType.TestHealthReply)
                    {
                        return(new TestHealthReply(channel, array));
                    }
                }
            }
            else if (messageType2 <= NetworkChannelMessage.MessageType.CompressionReply)
            {
                if (messageType2 == NetworkChannelMessage.MessageType.SeedPageReaderRollLogFileReply)
                {
                    return(new SeedPageReaderRollLogFileReply(channel, array));
                }
                if (messageType2 == NetworkChannelMessage.MessageType.ProgressCiFileReply)
                {
                    return(new ProgressCiFileReply(channel, array));
                }
                if (messageType2 == NetworkChannelMessage.MessageType.CompressionReply)
                {
                    return(new NetworkChannelCompressionReply(channel, array));
                }
            }
            else
            {
                if (messageType2 == NetworkChannelMessage.MessageType.SeedPageReaderSinglePageReply)
                {
                    return(new SeedPageReaderSinglePageReply(channel, array));
                }
                if (messageType2 == NetworkChannelMessage.MessageType.SeedCiFileReply)
                {
                    return(new SeedCiFileReply(channel, array));
                }
                if (messageType2 == NetworkChannelMessage.MessageType.SeedPageReaderPageSizeReply)
                {
                    return(new SeedPageReaderPageSizeReply(channel, array));
                }
            }
IL_51C:
            throw new NetworkUnexpectedMessageException(channel.PartnerNodeName, string.Format("Unknown message type: 0x{0:X}", (int)messageType));
        }