예제 #1
0
        /// <summary>
        /// Creates the output.
        /// </summary>
        /// <returns></returns>
        private PublisherConfigurator CreateOutput()
        {
            var uri = new Uri(_publisherConfig.Output.Uri);

            _output = AgentGatewayFactory.CreateOutputGateway(_identification, uri, _publisherConfig.Output.Transport);
            return(this);
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ErrorHandlingController"/> class.
 /// </summary>
 /// <param name="outputGateway">The output gateway.</param>
 /// <param name="identification">The identification.</param>
 internal ErrorHandlingController(IOutputGateway<IMessage> outputGateway, Identification identification)
 {
     _outputGateway = outputGateway;
     _identification = identification;
     _agentErrorHandlings = new List<IAgentErrorHandling>();
     _routerErrorHandlings = new List<IRouterErrorHandling>();
 }
예제 #3
0
        /// <summary>
        ///     Adds the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="service">The service.</param>
        /// <param name="outputGateway">The output gateway.</param>
        public void Add(SubscriptionKey key, Identification service, IOutputGateway <byte[]> outputGateway)
        {
            LoggerManager.Instance.Info(string.Format("Add Type {0}", key.Key));
            bool lockTaken = false;

            _lockKeys.Enter(ref lockTaken);
            if (lockTaken)
            {
                try
                {
                    if (!_keyDictionary.ContainsKey(key))
                    {
                        _keyDictionary.Add(key, new List <IOutputGateway <byte[]> >());
                    }
                    _keyDictionary[key].Add(outputGateway);

                    ReloadAssignableTypes(key, service, outputGateway);
                }
                catch (Exception exception)
                {
                    LoggerManager.Instance.Error(string.Format("Error al añadir suscriptor {0}", key.Key), exception);
                }
                finally
                {
                    LoggerManager.Instance.Info(string.Format("Se libera el lock {0}", key.Key));
                    _lockKeys.Exit();
                }
            }
        }
예제 #4
0
        /// <summary>
        ///     Unsubscribes the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="service"></param>
        /// <param name="sender">The sender.</param>
        public void Unsubscribe(SubscriptionKey type, Identification service, IOutputGateway <byte[]> sender)
        {
            bool lockTaken = false;

            _lockSubcriptorsList.Enter(ref lockTaken);
            if (lockTaken)
            {
                try
                {
                    if (_subcriptorsList.ContainsKey(service))
                    {
                        _subcriptorsList.Remove(service);
                    }
                }
                catch (Exception exception)
                {
                    LoggerManager.Instance.Error(string.Format("Error al añadir suscriptor {0}", service.Id), exception);
                }
                finally
                {
                    LoggerManager.Instance.Info(string.Format("Se libera el lock {0}", service.Id));
                    _lockSubcriptorsList.Exit();
                }
            }

            _gatewaysRepository.RemoveSender(type, service, sender);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ErrorHandlingController"/> class.
 /// </summary>
 /// <param name="outputGateway">The output gateway.</param>
 /// <param name="identification">The identification.</param>
 internal ErrorHandlingController(IOutputGateway <IMessage> outputGateway, Identification identification)
 {
     _outputGateway        = outputGateway;
     _identification       = identification;
     _agentErrorHandlings  = new List <IAgentErrorHandling>();
     _routerErrorHandlings = new List <IRouterErrorHandling>();
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Monitor"/> class.
 /// </summary>
 /// <param name="controller">The controller.</param>
 /// <param name="outputGateway">The output gateway.</param>
 public Monitor(IController controller, IOutputGateway <IMessage> outputGateway)
 {
     _samplers      = new List <ISampler>();
     _controller    = controller;
     _outputGateway = outputGateway;
     ConfigureStateMachine();
 }
        /// <summary>
        /// Creates the output.
        /// </summary>
        /// <returns></returns>
        private ErrorHandlingControllerConfigurator CreateOutput()
        {
            var uri = new Uri(_errorHandlingControllerConfig.Output.Uri);

            _output = AgentGatewayFactory.CreateOutputGateway(_identification, uri, _errorHandlingControllerConfig.Output.Transport);
            return(this);
        }
예제 #8
0
파일: Monitor.cs 프로젝트: petxo/HermEsb
 /// <summary>
 /// Initializes a new instance of the <see cref="Monitor"/> class.
 /// </summary>
 /// <param name="controller">The controller.</param>
 /// <param name="outputGateway">The output gateway.</param>
 public Monitor(IController controller, IOutputGateway<IMessage> outputGateway)
 {
     _samplers = new List<ISampler>();
     _controller = controller;
     _outputGateway = outputGateway;
     ConfigureStateMachine();
 }
예제 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ControlProcessor"/> class.
 /// </summary>
 /// <param name="identification">The identification.</param>
 /// <param name="inputGateway">The input gateway.</param>
 /// <param name="outputGateway">The output gateway.</param>
 /// <param name="handlerRepository">The handler repository.</param>
 /// <param name="messageBuilder">The message builder.</param>
 /// <param name="reinjectionEngine">The reinjection engine.</param>
 internal ControlProcessor(Identification identification,
                           IInputGateway <IControlMessage, MessageHeader> inputGateway,
                           IOutputGateway <IControlMessage> outputGateway,
                           IHandlerRepository handlerRepository, IMessageBuilder messageBuilder, IReinjectionEngine reinjectionEngine)
     : base(identification, inputGateway, handlerRepository, messageBuilder, reinjectionEngine)
 {
     OutputGateway = outputGateway;
 }
예제 #10
0
        /// <summary>
        /// Creates the specified monitorable processor.
        /// </summary>
        /// <param name="controller">The controller.</param>
        /// <param name="outputGateway">The output gateway.</param>
        /// <param name="assemblies">The assemblies.</param>
        /// <returns></returns>
        public IMonitor Create(IController controller,
                               IOutputGateway<IMessage> outputGateway,
                               IEnumerable<string> assemblies)
        {
            var samplers = CreateSamplers(assemblies, controller.Processor);

            var monitor = new Monitor(controller, outputGateway);
            foreach (var sampler in samplers)
            {
                monitor.AddSampler(sampler);
            }

            return monitor;
        }
예제 #11
0
        /// <summary>
        ///     Removes the specified output gateway.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="service"></param>
        /// <param name="outputGateway">The output gateway.</param>
        public void Remove(SubscriptionKey key, Identification service, IOutputGateway <byte[]> outputGateway)
        {
            LoggerManager.Instance.Info(string.Format("Remove Type {0}", key.Key));
            bool lockTaken = false;

            _lockKeys.Enter(ref lockTaken);
            if (lockTaken)
            {
                try
                {
                    if (_keyDictionary.ContainsKey(key))
                    {
                        _keyDictionary[key].Remove(outputGateway);
                        if (_keyDictionary[key].Count == 0)
                        {
                            _keyDictionary.Remove(key);
                        }
                    }
                }
                finally
                {
                    _lockKeys.Exit();
                }
            }

            lockTaken = false;
            _lockAsignableTypes.Enter(ref lockTaken);
            if (lockTaken)
            {
                try
                {
                    SpinWait.SpinUntil(() => _numThreadsRunning == 0);

                    foreach (var assignableType in _assignableTypesList)
                    {
                        assignableType.Value.Remove(service.Type, outputGateway);
                    }

                    foreach (var assignableType in _assignableTypesList.Where(pair => pair.Value.Count == 0).ToList())
                    {
                        _assignableTypesList.Remove(assignableType);
                    }
                }
                finally
                {
                    _lockAsignableTypes.Exit();
                }
            }
        }
예제 #12
0
 /// <summary>
 ///     Creates the control processor.
 /// </summary>
 /// <param name="identification">The identification.</param>
 /// <param name="inputGateway">The input gateway.</param>
 /// <param name="outputGateway">The output gateway.</param>
 /// <param name="handlerRepository">The handler repository.</param>
 /// <returns></returns>
 public static IController CreateControlProcessor(Identification identification,
                                                  IInputGateway <IControlMessage, MessageHeader> inputGateway,
                                                  IOutputGateway <IControlMessage> outputGateway,
                                                  IHandlerRepository handlerRepository)
 {
     return(new ControlProcessor(identification,
                                 inputGateway,
                                 outputGateway,
                                 handlerRepository,
                                 MessageBuilderFactory.CreateDefaultBuilder(),
                                 ReinjectionEngineFactory.CreateDefaultEngine(inputGateway))
     {
         Logger = LoggerManager.Instance
     });
 }
예제 #13
0
        /// <summary>
        /// Creates the specified monitorable processor.
        /// </summary>
        /// <param name="controller">The controller.</param>
        /// <param name="outputGateway">The output gateway.</param>
        /// <param name="assemblies">The assemblies.</param>
        /// <returns></returns>
        public IMonitor Create(IController controller,
                               IOutputGateway <IMessage> outputGateway,
                               IEnumerable <string> assemblies)
        {
            var samplers = CreateSamplers(assemblies, controller.Processor);

            var monitor = new Monitor(controller, outputGateway);

            foreach (var sampler in samplers)
            {
                monitor.AddSampler(sampler);
            }

            return(monitor);
        }
예제 #14
0
 /// <summary>
 ///     Creates the control processor.
 /// </summary>
 /// <param name="identification">The identification.</param>
 /// <param name="inputGateway">The input gateway.</param>
 /// <param name="outputGateway">The output gateway.</param>
 /// <param name="handlerRepository">The handler repository.</param>
 /// <returns></returns>
 public static IController CreateControlProcessor(Identification identification,
                                                  IInputGateway<IControlMessage, MessageHeader> inputGateway,
                                                  IOutputGateway<IControlMessage> outputGateway,
                                                  IHandlerRepository handlerRepository)
 {
     return new ControlProcessor(identification,
                                 inputGateway,
                                 outputGateway,
                                 handlerRepository,
                                 MessageBuilderFactory.CreateDefaultBuilder(),
                                 ReinjectionEngineFactory.CreateDefaultEngine(inputGateway))
         {
             Logger = LoggerManager.Instance
         };
 }
예제 #15
0
        /// <summary>
        ///     Reloads the assignable types.
        /// </summary>
        /// <param name="subscriptionKey">The subscription key.</param>
        /// <param name="service">The service.</param>
        /// <param name="outputGateway">The output gateway.</param>
        private void ReloadAssignableTypes(SubscriptionKey subscriptionKey, Identification service,
                                           IOutputGateway <byte[]> outputGateway)
        {
            //Recargamos la lista de tipos asignables
            bool lockTaken = false;

            _lockAsignableTypes.Enter(ref lockTaken);
            if (lockTaken)
            {
                SpinWait.SpinUntil(() => _numThreadsRunning == 0);

                foreach (var assignableType in _assignableTypesList)
                {
                    KeyValuePair <SubscriptionKey, List <IOutputGateway <byte[]> > > key =
                        _keyDictionary.FirstOrDefault(pair => pair.Key.Key == assignableType.Key);

                    if (key.Key != null && key.Key.IsAssignableKey(subscriptionKey.Key))
                    {
                        if (!assignableType.Value.Exists(outputGateway))
                        {
                            assignableType.Value.Add(service.Type, outputGateway);
                        }
                    }
                }

                if (!_assignableTypesList.ContainsKey(subscriptionKey.Key))
                {
                    var loadBalancerController = new LoadBalancerController <string, IOutputGateway <byte[]> >();
                    _assignableTypesList.Add(subscriptionKey.Key, loadBalancerController);

                    loadBalancerController.Add(service.Type, outputGateway);
                }

                _lockAsignableTypes.Exit();
            }
        }
예제 #16
0
 /// <summary>
 ///     Unsubscribes the specified message type.
 /// </summary>
 /// <param name="messageType">Type of the message.</param>
 /// <param name="service"></param>
 /// <param name="outputGateway">The message sender.</param>
 public void Unsubscribe(SubscriptionKey messageType, Identification service,
                         IOutputGateway<byte[]> outputGateway)
 {
     _routerOutputHelper.Unsubscribe(messageType, service, outputGateway);
 }
예제 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BusPublisher"/> class.
 /// </summary>
 /// <param name="outputGateway">The output gateway.</param>
 /// <param name="messageBuilder">The message builder.</param>
 public BusPublisher(IOutputGateway<IMessage> outputGateway, IMessageBuilder messageBuilder)
 {
     _outputGateway = outputGateway;
     _messageBuilder = messageBuilder;
 }
예제 #18
0
 /// <summary>
 /// Configures the output gateway.
 /// </summary>
 /// <param name="outputGateway">The output gateway.</param>
 public void ConfigureOutputGateway(IOutputGateway <IMessage> outputGateway)
 {
     OutputGateway = outputGateway;
 }
 /// <summary>
 /// Creates the output.
 /// </summary>
 /// <returns></returns>
 private ErrorHandlingControllerConfigurator CreateOutput()
 {
     var uri = new Uri(_errorHandlingControllerConfig.Output.Uri);
     _output = AgentGatewayFactory.CreateOutputGateway(_identification, uri, _errorHandlingControllerConfig.Output.Transport);
     return this;
 }
예제 #20
0
 /// <summary>
 /// Creates the output.
 /// </summary>
 /// <returns></returns>
 private PublisherConfigurator CreateOutput()
 {
     var uri = new Uri(_publisherConfig.Output.Uri);
     _output = AgentGatewayFactory.CreateOutputGateway(_identification, uri, _publisherConfig.Output.Transport);
     return this;
 }
예제 #21
0
        /// <summary>
        ///     Unsubscribes the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="service"></param>
        /// <param name="sender">The sender.</param>
        public void Unsubscribe(SubscriptionKey type, Identification service, IOutputGateway<byte[]> sender)
        {
            bool lockTaken = false;
            _lockSubcriptorsList.Enter(ref lockTaken);
            if (lockTaken)
            {
                try
                {
                    if (_subcriptorsList.ContainsKey(service))
                    {
                        _subcriptorsList.Remove(service);
                    }
                }
                catch (Exception exception)
                {
                    LoggerManager.Instance.Error(string.Format("Error al añadir suscriptor {0}", service.Id), exception);
                }
                finally
                {
                    LoggerManager.Instance.Info(string.Format("Se libera el lock {0}", service.Id));
                    _lockSubcriptorsList.Exit();
                }
            }

            _gatewaysRepository.RemoveSender(type, service, sender);
        }
예제 #22
0
 /// <summary>
 /// Removes the sender.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="service"></param>
 /// <param name="sender">The sender.</param>
 public abstract void RemoveSender(SubscriptionKey type, Identification service, IOutputGateway<byte[]> sender);
예제 #23
0
 /// <summary>
 ///     Unsubscribes the specified message type.
 /// </summary>
 /// <param name="messageType">Type of the message.</param>
 /// <param name="service"></param>
 /// <param name="outputGateway">The message sender.</param>
 public void Unsubscribe(SubscriptionKey messageType, Identification service,
                         IOutputGateway <byte[]> outputGateway)
 {
     _routerOutputHelper.Unsubscribe(messageType, service, outputGateway);
 }
 /// <summary>
 /// Creates the specified output gateway.
 /// </summary>
 /// <param name="outputGateway">The output gateway.</param>
 /// <param name="identification">The identification.</param>
 /// <returns></returns>
 public static IErrorHandlingController Create(IOutputGateway<IMessage> outputGateway, Identification identification)
 {
     return new ErrorHandlingController(outputGateway, identification);
 }
예제 #25
0
 /// <summary>
 ///     Adds the sender.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="service"></param>
 /// <param name="sender">The sender.</param>
 public override void AddSender(SubscriptionKey type, Identification service, IOutputGateway <byte[]> sender)
 {
     LoggerManager.Instance.Debug(string.Format("Add Sender: {0}", type.Key));
     HierarchicalKeyEngine.Add(type, service, sender);
 }
예제 #26
0
 /// <summary>
 ///     Removes the sender.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="service"></param>
 /// <param name="sender">The sender.</param>
 public override void RemoveSender(SubscriptionKey type, Identification service, IOutputGateway <byte[]> sender)
 {
     HierarchicalKeyEngine.Remove(type, service, sender);
 }
예제 #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BusPublisher"/> class.
 /// </summary>
 /// <param name="outputGateway">The output gateway.</param>
 /// <param name="messageBuilder">The message builder.</param>
 public BusPublisher(IOutputGateway <IMessage> outputGateway, IMessageBuilder messageBuilder)
 {
     _outputGateway  = outputGateway;
     _messageBuilder = messageBuilder;
 }
예제 #28
0
 /// <summary>
 /// Creates the bus publisher.
 /// </summary>
 /// <param name="output">The output.</param>
 /// <param name="messageBuilder">The message builder.</param>
 /// <returns></returns>
 public static BusPublisher CreateBusPublisher(IOutputGateway<IMessage> output, IMessageBuilder messageBuilder)
 {
     return new BusPublisher(output, messageBuilder);
 }
예제 #29
0
 /// <summary>
 /// Removes the sender.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="service"></param>
 /// <param name="sender">The sender.</param>
 public abstract void RemoveSender(SubscriptionKey type, Identification service, IOutputGateway <byte[]> sender);
 /// <summary>
 /// Creates the specified output gateway.
 /// </summary>
 /// <param name="outputGateway">The output gateway.</param>
 /// <param name="identification">The identification.</param>
 /// <returns></returns>
 public static IErrorHandlingController Create(IOutputGateway <IMessage> outputGateway, Identification identification)
 {
     return(new ErrorHandlingController(outputGateway, identification));
 }
예제 #31
0
 /// <summary>
 ///     Adds the sender.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="service"></param>
 /// <param name="sender">The sender.</param>
 public override void AddSender(SubscriptionKey type, Identification service, IOutputGateway<byte[]> sender)
 {
     LoggerManager.Instance.Debug(string.Format("Add Sender: {0}", type.Key));
     HierarchicalKeyEngine.Add(type, service, sender);
 }
예제 #32
0
 /// <summary>
 /// Creates the bus publisher.
 /// </summary>
 /// <param name="output">The output.</param>
 /// <param name="messageBuilder">The message builder.</param>
 /// <returns></returns>
 public static BusPublisher CreateBusPublisher(IOutputGateway <IMessage> output, IMessageBuilder messageBuilder)
 {
     return(new BusPublisher(output, messageBuilder));
 }
예제 #33
0
 /// <summary>
 ///     Removes the sender.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="service"></param>
 /// <param name="sender">The sender.</param>
 public override void RemoveSender(SubscriptionKey type, Identification service, IOutputGateway<byte[]> sender)
 {
     HierarchicalKeyEngine.Remove(type, service, sender);
 }