예제 #1
0
 public UdpDispatcherImpl(Identity identity, UdpClient udpClient, DuplicateFilter duplicateFilter, PayloadSender payloadSender, AcknowledgementCoordinator acknowledgementCoordinator, RoutingTable routingTable, PeerTable peerTable, InboundMessageDispatcher inboundMessageDispatcher, MultiPartPacketReassembler multiPartPacketReassembler, IUdpUnicasterFactory udpUnicasterFactory, IAuditCounter announcementsReceivedCounter, IAuditCounter tossedCounter, IAuditCounter duplicateReceivesCounter, IAuditAggregator<int> multiPartChunksBytesReceivedAggregator) {
    this.identity = identity;
    this.udpClient = udpClient;
    this.duplicateFilter = duplicateFilter;
    this.payloadSender = payloadSender;
    this.acknowledgementCoordinator = acknowledgementCoordinator;
    this.routingTable = routingTable;
    this.peerTable = peerTable;
    this.inboundMessageDispatcher = inboundMessageDispatcher;
    this.multiPartPacketReassembler = multiPartPacketReassembler;
    this.udpUnicasterFactory = udpUnicasterFactory;
    this.announcementsReceivedCounter = announcementsReceivedCounter;
    this.tossedCounter = tossedCounter;
    this.duplicateReceivesCounter = duplicateReceivesCounter;
    this.multiPartChunksBytesReceivedAggregator = multiPartChunksBytesReceivedAggregator;
 }
예제 #2
0
 public UdpDispatcherImpl(Identity identity, UdpClient udpClient, DuplicateFilter duplicateFilter, PayloadSender payloadSender, AcknowledgementCoordinator acknowledgementCoordinator, RoutingTable routingTable, PeerTable peerTable, InboundMessageDispatcher inboundMessageDispatcher, MultiPartPacketReassembler multiPartPacketReassembler, IUdpUnicasterFactory udpUnicasterFactory, IAuditCounter announcementsReceivedCounter, IAuditCounter tossedCounter, IAuditCounter duplicateReceivesCounter, IAuditAggregator <int> multiPartChunksBytesReceivedAggregator)
 {
     this.identity                               = identity;
     this.udpClient                              = udpClient;
     this.duplicateFilter                        = duplicateFilter;
     this.payloadSender                          = payloadSender;
     this.acknowledgementCoordinator             = acknowledgementCoordinator;
     this.routingTable                           = routingTable;
     this.peerTable                              = peerTable;
     this.inboundMessageDispatcher               = inboundMessageDispatcher;
     this.multiPartPacketReassembler             = multiPartPacketReassembler;
     this.udpUnicasterFactory                    = udpUnicasterFactory;
     this.announcementsReceivedCounter           = announcementsReceivedCounter;
     this.tossedCounter                          = tossedCounter;
     this.duplicateReceivesCounter               = duplicateReceivesCounter;
     this.multiPartChunksBytesReceivedAggregator = multiPartChunksBytesReceivedAggregator;
 }
예제 #3
0
        public Task <ITransport> CreateAsync(MobOperations mobOperations, Identity identity, RoutingTable routingTable, PeerTable peerTable, InboundMessageDispatcher inboundMessageDispatcher, AuditService auditService)
        {
            // setup identity
            identity.Properties[UdpConstants.kUnicastPortIdentityPropertyKey] = configuration.UnicastReceiveEndpoint.Port.ToString();

            var duplicateFilter = new DuplicateFilter();

            duplicateFilter.Initialize();

            var inboundBytesAggregator  = auditService.GetAggregator <double>(DataSetNames.kInboundBytes);
            var outboundBytesAggregator = auditService.GetAggregator <double>(DataSetNames.kOutboundBytes);
            var inboundReceiveProcessDispatchLatencyAggregator = auditService.GetAggregator <double>(DataSetNames.kInboundProcessDispatchLatency);
            var resendsCounter                     = auditService.GetCounter(DataSetNames.kTotalResends);
            var resendsAggregator                  = auditService.GetAggregator <int>(DataSetNames.kMessageResends);
            var tossedCounter                      = auditService.GetCounter(DataSetNames.kTossed);
            var duplicatesReceivedCounter          = auditService.GetCounter(DataSetNames.kDuplicatesReceived);
            var announcementsReceivedCounter       = auditService.GetCounter(DataSetNames.kAnnouncementsReceived);
            var multiPartChunksSentCounter         = auditService.GetCounter(DataSetNames.kMultiPartChunksSent);
            var multiPartChunksReceivedAggregator  = auditService.GetAggregator <int>(DataSetNames.kMultiPartChunksBytesReceived);
            var outboundMessageRateLimitAggregator = auditService.GetAggregator <double>(DataSetNames.kOutboundMessageRateLimit);
            var sendQueueDepthAggregator           = auditService.GetAggregator <double>(DataSetNames.kSendQueueDepth);

            mobOperations.RegisterMob(new UdpDebugMob());

            var shutdownCts = new CancellationTokenSource();
            var acknowledgementCoordinator = new AcknowledgementCoordinator(identity);
            var udpUnicastScheduler        = SchedulerFactory.CreateWithCustomThreadPool($"Courier.Udp({identity.Id.ToShortString()}).Unicast");
            var sendReceiveBufferPool      = ObjectPool.CreateStackBacked(() => new byte[UdpConstants.kMaximumTransportSize]);
            var client        = UdpClient.Create(configuration, udpUnicastScheduler, sendReceiveBufferPool, inboundBytesAggregator, outboundBytesAggregator, inboundReceiveProcessDispatchLatencyAggregator);
            var payloadSender = new PayloadSender(client);
            var multiPartPacketReassembler = new MultiPartPacketReassembler();
            var udpUnicasterFactory        = new UdpUnicasterFactory(identity, client, acknowledgementCoordinator, sendReceiveBufferPool, resendsCounter, resendsAggregator, outboundMessageRateLimitAggregator, sendQueueDepthAggregator);
            var udpDispatcher = new UdpDispatcherImpl(identity, client, duplicateFilter, payloadSender, acknowledgementCoordinator, routingTable, peerTable, inboundMessageDispatcher, multiPartPacketReassembler, udpUnicasterFactory, announcementsReceivedCounter, tossedCounter, duplicatesReceivedCounter, multiPartChunksReceivedAggregator);

            multiPartPacketReassembler.SetUdpDispatcher(udpDispatcher);
            var announcer = new Announcer(identity, payloadSender, shutdownCts.Token);

            announcer.Initialize();
            var udpFacade      = new UdpFacade(client, udpDispatcher, shutdownCts);
            var udpBroadcaster = new UdpBroadcaster(identity, client);
            var transport      = new UdpTransport(udpBroadcaster, udpFacade);

            client.StartReceiving(udpDispatcher);

            return(Task.FromResult <ITransport>(transport));
        }
      public Task<ITransport> CreateAsync(MobOperations mobOperations, Identity identity, RoutingTable routingTable, PeerTable peerTable, InboundMessageDispatcher inboundMessageDispatcher, AuditService auditService) {
         // setup identity
         identity.Properties[UdpConstants.kUnicastPortIdentityPropertyKey] = configuration.UnicastReceiveEndpoint.Port.ToString();

         var duplicateFilter = new DuplicateFilter();
         duplicateFilter.Initialize();

         var inboundBytesAggregator = auditService.GetAggregator<double>(DataSetNames.kInboundBytes);
         var outboundBytesAggregator = auditService.GetAggregator<double>(DataSetNames.kOutboundBytes);
         var inboundReceiveProcessDispatchLatencyAggregator = auditService.GetAggregator<double>(DataSetNames.kInboundProcessDispatchLatency);
         var resendsCounter = auditService.GetCounter(DataSetNames.kTotalResends);
         var resendsAggregator = auditService.GetAggregator<int>(DataSetNames.kMessageResends);
         var tossedCounter = auditService.GetCounter(DataSetNames.kTossed);
         var duplicatesReceivedCounter = auditService.GetCounter(DataSetNames.kDuplicatesReceived);
         var announcementsReceivedCounter = auditService.GetCounter(DataSetNames.kAnnouncementsReceived);
         var multiPartChunksSentCounter = auditService.GetCounter(DataSetNames.kMultiPartChunksSent);
         var multiPartChunksReceivedAggregator = auditService.GetAggregator<int>(DataSetNames.kMultiPartChunksBytesReceived);
         var outboundMessageRateLimitAggregator = auditService.GetAggregator<double>(DataSetNames.kOutboundMessageRateLimit);
         var sendQueueDepthAggregator = auditService.GetAggregator<double>(DataSetNames.kSendQueueDepth);

         mobOperations.RegisterMob(new UdpDebugMob());

         var shutdownCts = new CancellationTokenSource();
         var acknowledgementCoordinator = new AcknowledgementCoordinator(identity);
         var udpUnicastScheduler = SchedulerFactory.CreateWithCustomThreadPool($"Courier.Udp({identity.Id.ToShortString()}).Unicast");
         var sendReceiveBufferPool = ObjectPool.CreateStackBacked(() => new byte[UdpConstants.kMaximumTransportSize]);
         var client = UdpClient.Create(configuration, udpUnicastScheduler, sendReceiveBufferPool, inboundBytesAggregator, outboundBytesAggregator, inboundReceiveProcessDispatchLatencyAggregator);
         var payloadSender = new PayloadSender(client);
         var multiPartPacketReassembler = new MultiPartPacketReassembler();
         var udpUnicasterFactory = new UdpUnicasterFactory(identity, client, acknowledgementCoordinator, sendReceiveBufferPool, resendsCounter, resendsAggregator, outboundMessageRateLimitAggregator, sendQueueDepthAggregator);
         var udpDispatcher = new UdpDispatcherImpl(identity, client, duplicateFilter, payloadSender, acknowledgementCoordinator, routingTable, peerTable, inboundMessageDispatcher, multiPartPacketReassembler, udpUnicasterFactory, announcementsReceivedCounter, tossedCounter, duplicatesReceivedCounter, multiPartChunksReceivedAggregator);
         multiPartPacketReassembler.SetUdpDispatcher(udpDispatcher);
         var announcer = new Announcer(identity, payloadSender, shutdownCts.Token);
         announcer.Initialize();
         var udpFacade = new UdpFacade(client, udpDispatcher, shutdownCts);
         var udpBroadcaster = new UdpBroadcaster(identity, client);
         var transport = new UdpTransport(udpBroadcaster, udpFacade);
         client.StartReceiving(udpDispatcher);

         return Task.FromResult<ITransport>(transport);
      }