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); } }
public void OnNeighborOpened(object sender, EventArgs args) { IPeerNeighbor neighbor = sender as IPeerNeighbor; EventHandler handler = this.OnNeighborAuthenticated; if (handler == null) { neighbor.Abort(PeerCloseReason.LeavingMesh, PeerCloseInitiator.LocalNode); return; } if (this.authenticationMode == PeerAuthenticationMode.Password) { if (!(neighbor.Extensions.Find <PeerChannelAuthenticatorExtension>() == null)) { throw Fx.AssertAndThrow("extension already exists!"); } PeerChannelAuthenticatorExtension extension = new PeerChannelAuthenticatorExtension(this, handler, args, this.MeshId); neighbor.Extensions.Add(extension); if (neighbor.IsInitiator) { extension.InitiateHandShake(); } } else { neighbor.TrySetState(PeerNeighborState.Authenticated); handler(sender, args); } }
public override void ProcessLinkUtility(IPeerNeighbor neighbor, UtilityInfo utilityInfo) { if (!PeerNeighborStateHelper.IsConnected(neighbor.State)) { neighbor.Abort(PeerCloseReason.InvalidNeighbor, PeerCloseInitiator.LocalNode); return; } try { UtilityExtension.ProcessLinkUtility(neighbor, utilityInfo); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (null != CloseNeighborIfKnownException(neighborManager, e, neighbor)) { throw; } DiagnosticUtility.TraceHandledException(e, TraceEventType.Information); } }
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); } }
public override void ProcessLinkUtility(IPeerNeighbor neighbor, UtilityInfo utilityInfo) { if (!PeerNeighborStateHelper.IsConnected(neighbor.State)) { neighbor.Abort(PeerCloseReason.InvalidNeighbor, PeerCloseInitiator.LocalNode); } else { try { UtilityExtension.ProcessLinkUtility(neighbor, utilityInfo); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } if (PeerFlooderBase <Message, UtilityInfo> .CloseNeighborIfKnownException(base.neighborManager, exception, neighbor) != null) { throw; } DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information); } } }
private void KillSlowNeighbor() { IPeerNeighbor neighbor = this.neighborManager.SlowestNeighbor(); if (neighbor != null) { neighbor.Abort(PeerCloseReason.NodeTooSlow, PeerCloseInitiator.LocalNode); } }
void IPeerServiceContract.Fault(Message message) { IPeerNeighbor neighbor = this.GetNeighbor(); if (neighbor == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ObjectDisposedException(typeof(IPeerNeighbor).ToString())); } neighbor.Abort(PeerCloseReason.Faulted, PeerCloseInitiator.RemoteNode); }
public bool PingNeighbor(IPeerNeighbor peer) { bool result = true; Message message = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, PeerStrings.PingAction); try { peer.Ping(message); } catch (Exception e) { if (Fx.IsFatal(e)) throw; DiagnosticUtility.TraceHandledException(e, TraceEventType.Information); peer.Abort(PeerCloseReason.InternalFailure, PeerCloseInitiator.LocalNode); result = false; } return result; }
void Abort(IPeerNeighbor neighbor) { neighbor.Abort(PeerCloseReason.AuthenticationFailure, PeerCloseInitiator.LocalNode); }