Пример #1
0
 public MessageCenter(SiloInitializationParameters silo, NodeConfiguration nodeConfig, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null)
 {
     this.Initialize(silo.SiloAddress.Endpoint, nodeConfig.Generation, config, metrics);
     if (nodeConfig.IsGatewayNode)
     {
         this.InstallGateway(nodeConfig.ProxyGatewayEndpoint);
     }
 }
Пример #2
0
        private void Initialize(IPEndPoint here, int generation, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null)
        {
            if(log.IsVerbose3) log.Verbose3("Starting initialization.");

            SocketManager = new SocketManager(config);
            ima = new IncomingMessageAcceptor(this, here, SocketDirection.SiloToSilo);
            MyAddress = SiloAddress.New((IPEndPoint)ima.AcceptingSocket.LocalEndPoint, generation);
            MessagingConfiguration = config;
            InboundQueue = new InboundMessageQueue();
            OutboundQueue = new OutboundMessageQueue(this, config);
            Gateway = null;
            Metrics = metrics;
            
            sendQueueLengthCounter = IntValueStatistic.FindOrCreate(StatisticNames.MESSAGE_CENTER_SEND_QUEUE_LENGTH, () => SendQueueLength);
            receiveQueueLengthCounter = IntValueStatistic.FindOrCreate(StatisticNames.MESSAGE_CENTER_RECEIVE_QUEUE_LENGTH, () => ReceiveQueueLength);

            if (log.IsVerbose3) log.Verbose3("Completed initialization.");
        }
Пример #3
0
 public QueueListener(
     IMessageTypesCache messageTypesCache,
     IMessagingLogger messagingLogger,
     UnprocessedMessagesResender unprocessedMessagesResender,
     IMessagingConfiguration messagingConfiguration,
     IListeningAgent listeningAgent,
     IDocumentMappingInitializer documentMappingInitializer,
     ISubscriptionAgent subscriptionAgent,
     ICollectionCreator collectionCreator
     )
 {
     _messageTypesCache           = messageTypesCache;
     _messagingLogger             = messagingLogger;
     _unprocessedMessagesResender = unprocessedMessagesResender;
     _messagingConfiguration      = messagingConfiguration;
     _listeningAgent             = listeningAgent;
     _documentMappingInitializer = documentMappingInitializer;
     _subscriptionAgent          = subscriptionAgent;
     _collectionCreator          = collectionCreator;
 }
Пример #4
0
        internal OutboundMessageQueue(MessageCenter mc, IMessagingConfiguration config)
        {
            messageCenter = mc;
            pingSender    = new SiloMessageSender("PingSender", messageCenter);
            systemSender  = new SiloMessageSender("SystemSender", messageCenter);
            senders       = new Lazy <SiloMessageSender> [config.SiloSenderQueues];

            for (int i = 0; i < senders.Length; i++)
            {
                int capture = i;
                senders[capture] = new Lazy <SiloMessageSender>(() =>
                {
                    var sender = new SiloMessageSender("AppMsgsSender_" + capture, messageCenter);
                    sender.Start();
                    return(sender);
                }, LazyThreadSafetyMode.ExecutionAndPublication);
            }
            logger  = LogManager.GetLogger("Messaging.OutboundMessageQueue");
            stopped = false;
        }
        internal OutboundMessageQueue(MessageCenter mc, IMessagingConfiguration config)
        {
            messageCenter = mc;
            pingSender = new SiloMessageSender("PingSender", messageCenter);
            systemSender = new SiloMessageSender("SystemSender", messageCenter);
            senders = new Lazy<SiloMessageSender>[config.SiloSenderQueues];

            for (int i = 0; i < senders.Length; i++)
            {
                int capture = i;
                senders[capture] = new Lazy<SiloMessageSender>(() =>
                {
                    var sender = new SiloMessageSender("AppMsgsSender_" + capture, messageCenter);
                    sender.Start();
                    return sender;
                }, LazyThreadSafetyMode.ExecutionAndPublication);
            }
            logger = TraceLogger.GetLogger("Messaging.OutboundMessageQueue");
            stopped = false;
        }
Пример #6
0
        public Message Message { get; set; } // might hold metadata used by response pipeline

        public CallbackData(
            Action<Message, TaskCompletionSource<object>> callback, 
            Func<Message, bool> resendFunc, 
            TaskCompletionSource<object> ctx, 
            Message msg, 
            Action unregisterDelegate,
            IMessagingConfiguration config)
        {
            // We are never called without a callback func, but best to double check.
            if (callback == null) throw new ArgumentNullException("callback");
            // We are never called without a resend func, but best to double check.
            if (resendFunc == null) throw new ArgumentNullException("resendFunc");

            this.callback = callback;
            this.resendFunc = resendFunc;
            context = ctx;
            Message = msg;
            unregister = unregisterDelegate;
            alreadyFired = false;
            this.config = config;
        }
Пример #7
0
        private void Initialize(IPEndPoint here, int generation, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null)
        {
            if (log.IsVerbose3)
            {
                log.Verbose3("Starting initialization.");
            }

            SocketManager          = new SocketManager(config, this.loggerFactory);
            ima                    = new IncomingMessageAcceptor(this, here, SocketDirection.SiloToSilo, this.messageFactory, this.serializationManager, this.loggerFactory);
            MyAddress              = SiloAddress.New((IPEndPoint)ima.AcceptingSocket.LocalEndPoint, generation);
            MessagingConfiguration = config;
            InboundQueue           = new InboundMessageQueue(this.loggerFactory);
            OutboundQueue          = new OutboundMessageQueue(this, config, this.serializationManager, this.loggerFactory);
            Metrics                = metrics;

            sendQueueLengthCounter    = IntValueStatistic.FindOrCreate(StatisticNames.MESSAGE_CENTER_SEND_QUEUE_LENGTH, () => SendQueueLength);
            receiveQueueLengthCounter = IntValueStatistic.FindOrCreate(StatisticNames.MESSAGE_CENTER_RECEIVE_QUEUE_LENGTH, () => ReceiveQueueLength);

            if (log.IsVerbose3)
            {
                log.Verbose3("Completed initialization.");
            }
        }
Пример #8
0
 public ProxiedMessageCenter(
     ClientConfiguration config,
     IPAddress localAddress,
     int gen,
     GrainId clientId,
     IGatewayListProvider gatewayListProvider,
     MessageFactory messageFactory)
 {
     lockable               = new object();
     MyAddress              = SiloAddress.New(new IPEndPoint(localAddress, 0), gen);
     ClientId               = clientId;
     this.messageFactory    = messageFactory;
     Running                = false;
     MessagingConfiguration = config;
     GatewayManager         = new GatewayManager(config, gatewayListProvider);
     PendingInboundMessages = new BlockingCollection <Message>();
     gatewayConnections     = new Dictionary <Uri, GatewayConnection>();
     numMessages            = 0;
     grainBuckets           = new WeakReference[config.ClientSenderBuckets];
     logger = LogManager.GetLogger("Messaging.ProxiedMessageCenter", LoggerType.Runtime);
     if (logger.IsVerbose)
     {
         logger.Verbose("Proxy grain client constructed");
     }
     IntValueStatistic.FindOrCreate(StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () =>
     {
         lock (gatewayConnections)
         {
             return(gatewayConnections.Values.Count(conn => conn.IsLive));
         }
     });
     if (StatisticsCollector.CollectQueueStats)
     {
         queueTracking = new QueueTrackingStatistic("ClientReceiver");
     }
 }
Пример #9
0
 internal static void InitGlobalBufferPool(IMessagingConfiguration config)
 {
     GlobalPool = new BufferPool(config.BufferPoolBufferSize, config.BufferPoolMaxSize, config.BufferPoolPreallocationSize, "Global");
 }
Пример #10
0
 public LegacyMongoAgent(IMessagingConfiguration messagingConfiguration)
 {
     _messagingConfiguration = messagingConfiguration;
     _dbName = _messagingConfiguration.Database;
 }
Пример #11
0
 internal OutgoingMessageSender(string nameSuffix, IMessagingConfiguration config)
     : base(nameSuffix, config)
 {
 }
Пример #12
0
 public LegacyMongoAgent(IMessagingConfiguration messagingConfiguration)
 {
     _messagingConfiguration = messagingConfiguration;
     _dbName = _messagingConfiguration.Database;
     _db     = new Lazy <MongoDatabase>(GetDb);
 }
Пример #13
0
 internal ClientsReplyRoutingCache(IMessagingConfiguration messagingConfiguration)
 {
     clientRoutes = new ConcurrentDictionary <GrainId, Tuple <SiloAddress, DateTime> >();
     TIME_BEFORE_ROUTE_CACHED_ENTRY_EXPIRES = messagingConfiguration.ResponseTimeout.Multiply(5);
 }
Пример #14
0
 public ProxiedMessageCenter(ClientConfiguration config, IPAddress localAddress, int gen, GrainId clientId, IGatewayListProvider gatewayListProvider)
 {
     lockable = new object();
     MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen);
     ClientId = clientId;
     Running = false;
     MessagingConfiguration = config;
     GatewayManager = new GatewayManager(config, gatewayListProvider);
     PendingInboundMessages = new BlockingCollection<Message>();
     gatewayConnections = new Dictionary<Uri, GatewayConnection>();
     numMessages = 0;
     grainBuckets = new WeakReference[config.ClientSenderBuckets];
     logger = LogManager.GetLogger("Messaging.ProxiedMessageCenter", LoggerType.Runtime);
     if (logger.IsVerbose) logger.Verbose("Proxy grain client constructed");
     IntValueStatistic.FindOrCreate(StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () =>
         {
             lock (gatewayConnections)
             {
                 return gatewayConnections.Values.Count(conn => conn.IsLive);
             }
         });
     if (StatisticsCollector.CollectQueueStats)
     {
         queueTracking = new QueueTrackingStatistic("ClientReceiver");
     }
 }
 internal static void CopyNetworkingOptions(IMessagingConfiguration configuration, NetworkingOptions options)
 {
     options.OpenConnectionTimeout = configuration.OpenConnectionTimeout;
     options.MaxSocketAge          = configuration.MaxSocketAge;
 }
Пример #16
0
 internal SocketManager(IMessagingConfiguration config)
 {
     cache = new LRU <IPEndPoint, Socket>(MAX_SOCKETS, config.MaxSocketAge, SendingSocketCreator);
     cache.RaiseFlushEvent += FlushHandler;
 }
Пример #17
0
 public MessageCenter(IPEndPoint here, int generation, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null)
 {
     Initialize(here, generation, config, metrics);
 }
Пример #18
0
 public MessageCenter(SiloInitializationParameters silo, NodeConfiguration nodeConfig, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null)
 {
     this.Initialize(silo.SiloAddress.Endpoint, nodeConfig.Generation, config, metrics);
     if (nodeConfig.IsGatewayNode)
     {
         this.InstallGateway(nodeConfig.ProxyGatewayEndpoint);
     }
 }
Пример #19
0
 public MessageCenter(IPEndPoint here, int generation, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null)
 {
     Initialize(here, generation, config, metrics);
 }
Пример #20
0
 public MessagingFacility()
 {
     MessagingConfiguration = m_DefaultMessagingConfiguration;
 }
Пример #21
0
 // Resends are used by the sender, usualy due to en error to send or due to a transient rejection.
 public bool MayResend(IMessagingConfiguration config)
 {
     return(ResendCount < config.MaxResendCount);
 }
Пример #22
0
 public MessagingFacility WithConfiguration(IMessagingConfiguration configuration)
 {
     m_IsExplicitConfigurationProvided = true;
     MessagingConfiguration            = configuration;
     return(this);
 }
Пример #23
0
        public bool IsExpirableMessage(IMessagingConfiguration config)
        {
            if (!config.DropExpiredMessages) return false;

            GrainId id = TargetGrain;
            if (id == null) return false;

            // don't set expiration for one way, system target and system grain messages.
            return Direction != Directions.OneWay && !id.IsSystemTarget && !Constants.IsSystemGrain(id);
        }
Пример #24
0
 // Resends are used by the sender, usualy due to en error to send or due to a transient rejection.
 public bool MayResend(IMessagingConfiguration config)
 {
     return ResendCount < config.MaxResendCount;
 }
Пример #25
0
 internal static void InitGlobalBufferPool(IMessagingConfiguration config)
 {
     GlobalPool = new BufferPool(config.BufferPoolBufferSize, config.BufferPoolMaxSize, config.BufferPoolPreallocationSize, "Global");
 }
Пример #26
0
 internal SocketManager(IMessagingConfiguration config)
 {
     cache = new LRU<IPEndPoint, Socket>(MAX_SOCKETS, config.MaxSocketAge, SendingSocketCreator);
     cache.RaiseFlushEvent += FlushHandler;
 }
Пример #27
0
 internal OutgoingMessageSender(string nameSuffix, IMessagingConfiguration config, SerializationManager serializationManager)
     : base(nameSuffix, config)
 {
     this.serializationManager = serializationManager;
 }
Пример #28
0
 public virtual void ConfigureSubscribers(IMessagingConfiguration configuration)
 {
 }