Ejemplo n.º 1
0
        private void TrySendStatusMessageToActive(PassiveStatusMsg.Flags statusFlags, long requestAckCounter, out NetworkTransportException sendException, out bool sendSkippedBecauseChannelBusy)
        {
            sendException = null;
            sendSkippedBecauseChannelBusy = false;
            NetworkChannel netCh = this.m_netChannel;

            if (this.m_asyncNetWritePending || netCh == null)
            {
                PassiveBlockMode.Tracer.TraceError((long)this.GetHashCode(), "SendStatusMessageToActive skipped because channel is busy");
                sendSkippedBecauseChannelBusy = true;
                return;
            }
            ReplayState replayState        = this.Configuration.ReplayState;
            long        highestCompleteGen = replayState.CopyNotificationGenerationNumber;

            byte[] statusMsgBuf = PassiveStatusMsg.SerializeToBytes(statusFlags, requestAckCounter, (uint)highestCompleteGen, (uint)replayState.CopyGenerationNumber, (uint)replayState.InspectorGenerationNumber, (uint)replayState.ReplayGenerationNumber, this.m_isCrossSite);
            bool   writeStarted = false;

            try
            {
                Exception ex = NetworkChannel.RunNetworkFunction(delegate
                {
                    ExTraceGlobals.FaultInjectionTracer.TraceTest(PassiveBlockMode.ackMessageSendFailed);
                    PassiveBlockMode.Tracer.TraceDebug <string, long>((long)this.GetHashCode(), "Sending PassiveStatusMsg({0}) Gen 0x{1:X}", this.DatabaseName, highestCompleteGen);
                    this.m_nextPingDue          = DateTime.UtcNow.AddMilliseconds((double)RegistryParameters.LogShipTimeoutInMsec);
                    this.m_asyncNetWritePending = true;
                    netCh.TcpChannel.Stream.BeginWrite(statusMsgBuf, 0, statusMsgBuf.Length, new AsyncCallback(this.NetWriteCompletion), netCh);
                    writeStarted = true;
                });
                if (ex != null)
                {
                    PassiveBlockMode.Tracer.TraceError <Exception>((long)this.GetHashCode(), "SendStatusMessageToActive Failed to ping Active: {0}", ex);
                    ReplayEventLogConstants.Tuple_NotifyActiveSendFailed.LogEvent(null, new object[]
                    {
                        this.DatabaseName,
                        replayState.ReplayGenerationNumber,
                        replayState.InspectorGenerationNumber,
                        replayState.CopyGenerationNumber,
                        ex.Message
                    });
                    sendException = (ex as NetworkTransportException);
                    if (sendException == null)
                    {
                        sendException = new NetworkCommunicationException(netCh.PartnerNodeName, ex.Message, ex);
                    }
                }
            }
            finally
            {
                if (!writeStarted)
                {
                    this.m_asyncNetWritePending = false;
                }
            }
        }
Ejemplo n.º 2
0
        // 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;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void NetWriteCompletion(IAsyncResult ar)
        {
            PassiveBlockMode.Tracer.TraceFunction <string>((long)this.GetHashCode(), "NetWriteCompletion({0})", this.DatabaseName);
            NetworkChannel netCh = (NetworkChannel)ar.AsyncState;
            Exception      ex    = NetworkChannel.RunNetworkFunction(delegate
            {
                netCh.TcpChannel.Stream.EndWrite(ar);
            });

            if (netCh == this.m_netChannel)
            {
                this.m_asyncNetWritePending = false;
                if (ex != null)
                {
                    PassiveBlockMode.Tracer.TraceError <string, Exception>((long)this.GetHashCode(), "NetWriteCompletion({0}) failed: {1}", this.DatabaseName, ex);
                    this.Terminate();
                }
            }
        }