예제 #1
0
 private void ConsumeData()
 {
     while (this.IsBlockModeActive)
     {
         QueuedBlockMsg queuedBlockMsg = this.m_oldestMessage;
         if (queuedBlockMsg == null)
         {
             return;
         }
         if (queuedBlockMsg.WasProcessed)
         {
             queuedBlockMsg = queuedBlockMsg.NextMsg;
             if (queuedBlockMsg == null)
             {
                 return;
             }
         }
         queuedBlockMsg.WasProcessed = true;
         this.m_oldestMessage        = queuedBlockMsg;
         this.m_consumer.Write(queuedBlockMsg.EmitContext, queuedBlockMsg.LogDataBuf, queuedBlockMsg.LogDataStartOffset);
         if (this.m_oldestMessage.IOBuffer != this.m_oldestBuffer && this.m_oldestMessage.IOBuffer != null)
         {
             this.RemoveOldestBuffer();
         }
     }
 }
예제 #2
0
        private void ProcessInput(QueuedBlockMsg dataMsg)
        {
            dataMsg.GetMessageSize();
            if (this.m_newestMessage != null)
            {
                this.m_newestMessage.NextMsg = dataMsg;
                this.m_newestMessage         = dataMsg;
            }
            else
            {
                this.m_newestMessage = dataMsg;
                this.m_oldestMessage = dataMsg;
            }
            bool flag = BitMasker.IsOn((int)dataMsg.EmitContext.grbitOperationalFlags, 16);

            if (PassiveBlockMode.IsDebugTraceEnabled)
            {
                long num = StopwatchStamp.TicksToMicroSeconds(dataMsg.ReadDurationInTics);
                PassiveBlockMode.Tracer.TraceDebug((long)this.GetHashCode(), "MessageArrived({0}) Gen=0x{1:X} Sector=0x{2:X} JBits=0x{3:X} EmitSeq=0x{4:X} LogDataLen=0x{5:X} ReadUSec={6}", new object[]
                {
                    this.DatabaseName,
                    dataMsg.EmitContext.lgposLogData.lGeneration,
                    dataMsg.EmitContext.lgposLogData.isec,
                    (int)dataMsg.EmitContext.grbitOperationalFlags,
                    dataMsg.EmitContext.qwSequenceNum,
                    dataMsg.LogDataLength,
                    num
                });
            }
            this.Copier.PerfmonCounters.RecordGranularBytesReceived((long)dataMsg.LogDataLength, flag);
            ExchangeNetworkPerfmonCounters perfCounters = this.m_netChannel.PerfCounters;

            if (perfCounters != null)
            {
                perfCounters.RecordLogCopyThruputReceived((long)dataMsg.LogDataLength);
                if (dataMsg.CompressedLogDataLength > 0)
                {
                    perfCounters.RecordCompressedDataReceived(dataMsg.CompressedLogDataLength, dataMsg.LogDataLength, NetworkPath.ConnectionPurpose.LogCopy);
                }
            }
            this.TriggerConsumer();
            if (flag || DateTime.UtcNow >= this.m_nextPingDue)
            {
                uint lGeneration = (uint)dataMsg.EmitContext.lgposLogData.lGeneration;
                if (flag)
                {
                    this.Copier.TrackKnownEndOfLog((long)((ulong)lGeneration), dataMsg.EmitContext.logtimeEmit);
                }
                NetworkTransportException ex;
                bool flag2;
                this.TrySendStatusMessageToActive(flag ? PassiveStatusMsg.Flags.AckEndOfGeneration : PassiveStatusMsg.Flags.None, dataMsg.RequestAckCounter, out ex, out flag2);
                if (ex != null)
                {
                    throw ex;
                }
            }
        }
예제 #3
0
 private void ProcessReadCallback(PassiveReadRequest ioReq, int bytesAvailable, bool completionIsSynchronous, Exception readEx)
 {
     PassiveBlockMode.Tracer.TraceFunction <string>((long)this.GetHashCode(), "ProcessReadCallback({0}) entered", this.DatabaseName);
     lock (this.m_workerLock)
     {
         this.DisableTimer();
         Exception ex    = null;
         bool      flag2 = false;
         try
         {
             this.m_recursionDepth++;
             DiagCore.RetailAssert(this.m_recursionDepth == 1 || completionIsSynchronous, "recursive async completion", new object[0]);
             ioReq.CompletionWasProcessed = true;
             if (completionIsSynchronous)
             {
                 ioReq.CompletedSynchronously = completionIsSynchronous;
             }
             if (readEx != null)
             {
                 PassiveBlockMode.Tracer.TraceError <string, Exception>((long)this.GetHashCode(), "ProcessReadCallback({0}) read failed: ex={1}", this.DatabaseName, readEx);
                 ex = new NetworkCommunicationException(this.Configuration.SourceMachine, readEx.Message, readEx);
             }
             else if (bytesAvailable == 0)
             {
                 PassiveBlockMode.Tracer.TraceError <string>((long)this.GetHashCode(), "ProcessReadCallback({0}) active closed connection", this.DatabaseName);
                 ex = new NetworkEndOfDataException(this.Configuration.SourceMachine, ReplayStrings.NetworkReadEOF);
             }
             else if (ioReq.Channel != this.m_netChannel)
             {
                 ex    = new NetworkEndOfDataException(this.Configuration.SourceMachine, ReplayStrings.NetworkReadEOF);
                 flag2 = true;
                 ioReq.Channel.Close();
             }
             else if (!this.IsBlockModeActive)
             {
                 PassiveBlockMode.Tracer.TraceError <string>((long)this.GetHashCode(), "Discarding read since BM was already terminated", this.DatabaseName);
             }
             else
             {
                 QueuedBlockMsg queuedBlockMsg = this.ReadInputMessage(ioReq.Channel);
                 if (queuedBlockMsg != null)
                 {
                     this.ProcessInput(queuedBlockMsg);
                     if (BitMasker.IsOn((int)queuedBlockMsg.EmitContext.grbitOperationalFlags, 2))
                     {
                         this.HandleActiveDismount();
                         return;
                     }
                     if (BitMasker.IsOn((int)queuedBlockMsg.EmitContext.grbitOperationalFlags, 16))
                     {
                         this.Copier.TrackLastContactTime(queuedBlockMsg.MessageUtc);
                     }
                 }
                 if (this.m_recursionDepth == 1)
                 {
                     while (this.IsBlockModeActive)
                     {
                         PassiveReadRequest passiveReadRequest = this.StartRead();
                         if (!passiveReadRequest.CompletionWasProcessed)
                         {
                             if (!this.m_runningAcll)
                             {
                                 this.ScheduleTimer();
                                 break;
                             }
                             break;
                         }
                     }
                 }
                 else
                 {
                     PassiveBlockMode.Tracer.TraceDebug <int>((long)this.GetHashCode(), "Recursive read avoided. Depth={0}", this.m_recursionDepth);
                 }
             }
         }
         catch (NetworkTransportException ex2)
         {
             ex = ex2;
         }
         catch (NetworkRemoteException ex3)
         {
             ex = ex3;
         }
         catch (GranularReplicationOverflowException ex4)
         {
             ex = ex4;
         }
         finally
         {
             this.m_recursionDepth--;
             if (ex != null && !flag2)
             {
                 this.Terminate();
             }
             PassiveBlockMode.Tracer.TraceFunction <string>((long)this.GetHashCode(), "ProcessReadCallback({0}) exits", this.DatabaseName);
         }
     }
 }