Ejemplo n.º 1
0
 void PruneNeighborCallback(IPeerNeighbor peer)
 {
     lock (ThisLock)
     {
         if (this.Neighbors.Count <= 1)
         {
             return;
         }
         if (DiagnosticUtility.ShouldTraceWarning)
         {
             string message = SR.GetString(SR.PeerThrottlePruning, this.config.MeshId);
             PeerThrottleTraceRecord record = new PeerThrottleTraceRecord(this.config.MeshId, message);
             TraceUtility.TraceEvent(TraceEventType.Warning, TraceCode.PeerFlooderReceiveMessageQuotaExceeded,
                                     SR.GetString(SR.TraceCodePeerFlooderReceiveMessageQuotaExceeded), record, this, null);
         }
     }
     try
     {
         peer.Abort(PeerCloseReason.NodeTooSlow, PeerCloseInitiator.LocalNode);
     }
     catch (Exception e)
     {
         if (Fx.IsFatal(e))
         {
             throw;
         }
         if (null != CloseNeighborIfKnownException(neighborManager, e, peer))
         {
             throw;
         }
         DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
     }
 }
 private void PruneNeighborCallback(IPeerNeighbor peer)
 {
     lock (this.ThisLock)
     {
         if (this.Neighbors.Count <= 1)
         {
             return;
         }
         if (System.ServiceModel.DiagnosticUtility.ShouldTraceWarning)
         {
             string message = System.ServiceModel.SR.GetString("PeerThrottlePruning", new object[] { this.config.MeshId });
             PeerThrottleTraceRecord extendedData = new PeerThrottleTraceRecord(this.config.MeshId, message);
             TraceUtility.TraceEvent(TraceEventType.Warning, 0x4004f, System.ServiceModel.SR.GetString("TraceCodePeerFlooderReceiveMessageQuotaExceeded"), extendedData, this, null);
         }
     }
     try
     {
         peer.Abort(PeerCloseReason.NodeTooSlow, PeerCloseInitiator.LocalNode);
     }
     catch (Exception exception)
     {
         if (Fx.IsFatal(exception))
         {
             throw;
         }
         if (PeerFlooderBase <TFloodContract, TLinkContract> .CloseNeighborIfKnownException(this.neighborManager, exception, peer) != null)
         {
             throw;
         }
         System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
     }
 }
Ejemplo n.º 3
0
        void IFlooderForThrottle.OnThrottleReached()
        {
            if (DiagnosticUtility.ShouldTraceInformation)
            {
                string message = SR.GetString(SR.PeerThrottleWaiting, this.config.MeshId);
                PeerThrottleTraceRecord record = new PeerThrottleTraceRecord(this.config.MeshId, message);
                TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.PeerFlooderReceiveMessageQuotaExceeded,
                                        SR.GetString(SR.TraceCodePeerFlooderReceiveMessageQuotaExceeded), record, this, null);
            }

            IPeerNeighbor peer = this.neighborManager.SlowestNeighbor();

            if (peer == null)
            {
                return;
            }
            UtilityExtension extension = peer.Utility;

            if (peer.IsConnected && extension != null)
            {
                if (extension.PendingMessages > PeerTransportConstants.MessageThreshold)
                {
                    extension.BeginCheckPoint(new UtilityExtension.PruneNeighborCallback(PruneNeighborCallback));
                }
                else
                {
                    Fx.Assert(false, "Neighbor is marked slow with messages " + extension.PendingMessages);
                }
                FireReachedEvent();
            }
        }
        void IFlooderForThrottle.OnThrottleReached()
        {
            if (System.ServiceModel.DiagnosticUtility.ShouldTraceInformation)
            {
                string message = System.ServiceModel.SR.GetString("PeerThrottleWaiting", new object[] { this.config.MeshId });
                PeerThrottleTraceRecord extendedData = new PeerThrottleTraceRecord(this.config.MeshId, message);
                TraceUtility.TraceEvent(TraceEventType.Information, 0x4004f, System.ServiceModel.SR.GetString("TraceCodePeerFlooderReceiveMessageQuotaExceeded"), extendedData, this, null);
            }
            IPeerNeighbor neighbor = this.neighborManager.SlowestNeighbor();

            if (neighbor != null)
            {
                UtilityExtension utility = neighbor.Utility;
                if (neighbor.IsConnected && (utility != null))
                {
                    if (utility.PendingMessages > 0x20)
                    {
                        utility.BeginCheckPoint(new System.ServiceModel.Channels.UtilityExtension.PruneNeighborCallback(this.PruneNeighborCallback));
                    }
                    this.FireReachedEvent();
                }
            }
        }