示例#1
0
 public PeerMaintainerBase(PeerNodeConfig config, PeerNeighborManager neighborManager, PeerFlooder flooder)
 {
     this.neighborManager = neighborManager;
     this.flooder         = flooder;
     this.config          = config;
     this.thisLock        = new object();
     this.referralCache   = new Dictionary <EndpointAddress, Referral>();
     this.maintainerTimer = new IOThreadTimer(new Action <object>(this.OnMaintainerTimer), this, false);
 }
 public PeerFlooderBase(PeerNodeConfig config, PeerNeighborManager neighborManager)
 {
     this.thisLock             = new object();
     this.neighborManager      = neighborManager;
     this.neighbors            = new List <IPeerNeighbor>();
     this.config               = config;
     this.neighbors            = this.neighborManager.GetConnectedNeighbors();
     this.quotaHelper          = new PeerThrottleHelper <TFloodContract, TLinkContract>(this, this.config.MaxPendingOutgoingCalls);
     this.OnMessageSentHandler = new EventHandler(this.OnMessageSent);
 }
示例#3
0
        public PeerConnector(PeerNodeConfig config, PeerNeighborManager neighborManager,
                             PeerMaintainer maintainer)
        {
            Fx.Assert(config != null, "Config is expected to non-null");
            Fx.Assert(neighborManager != null, "NeighborManager is expected to be non-null");
            Fx.Assert(maintainer != null, "Maintainer is expected to be non-null");
            Fx.Assert(config.NodeId != PeerTransportConstants.InvalidNodeId, "Invalid NodeId");
            Fx.Assert(config.MaxNeighbors > 0, "MaxNeighbors is expected to be non-zero positive value");
            Fx.Assert(config.ConnectTimeout > 0, "ConnectTimeout is expected to be non-zero positive value");

            this.thisLock        = new object();
            this.config          = config;
            this.neighborManager = neighborManager;
            this.maintainer      = maintainer;
            this.timerTable      = new Dictionary <IPeerNeighbor, IOThreadTimer>();
            this.state           = State.Created;
        }
示例#4
0
 // Guaranteed not to throw anything other than fatal exceptions
 static internal Exception CloseNeighborIfKnownException(PeerNeighborManager neighborManager, Exception exception, IPeerNeighbor peer)
 {
     try
     {
         //ignore this one since the channel is already closed.
         if (exception is ObjectDisposedException)
         {
             return(null);
         }
         else if (
             (exception is CommunicationException && !(exception.InnerException is QuotaExceededException)) ||
             (exception is TimeoutException) ||
             (exception is InvalidOperationException) ||
             (exception is MessageSecurityException)
             )
         {
             //is this the right close reason?
             neighborManager.CloseNeighbor(peer, PeerCloseReason.InternalFailure, PeerCloseInitiator.LocalNode, exception);
             return(null);
         }
         else
         {
             //exception that we dont know or cant act on.
             //we will throw this exception to the user.
             return(exception);
         }
     }
     catch (Exception e)
     {
         if (Fx.IsFatal(e))
         {
             throw;
         }
         DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
         return(e);
     }
 }
示例#5
0
 public PeerMaintainer(PeerNodeConfig config, PeerNeighborManager neighborManager, PeerFlooder flooder) : base(config, neighborManager, flooder)
 {
 }
示例#6
0
 public FloodAsyncResult(PeerNeighborManager owner, TimeSpan timeout, AsyncCallback callback, object state)
     : base(callback, state)
 {
     this.pnm           = owner;
     this.timeoutHelper = new TimeoutHelper(timeout);
 }
示例#7
0
 internal PeerFlooderSimple(PeerNodeConfig config, PeerNeighborManager neighborManager)
     : base(config, neighborManager)
 {
     //we want a message id cache that holds message ids for atmost 5 mins.
     this.messageIds = new ListManager(MaxBuckets);
 }
示例#8
0
 PeerFlooder(PeerNodeConfig config, PeerNeighborManager neighborManager) : base(config, neighborManager)
 {
 }
示例#9
0
 internal PeerFlooderSimple(PeerNodeConfig config, PeerNeighborManager neighborManager) : base(config, neighborManager)
 {
     this.messageIds = new ListManager(5);
 }