private void InitializeInstance(RelayNodeConfig config, ForwardingConfig forwardingConfig, Dictionary <string, Dictionary <string, MessageQueue> > errorQueues)
        {
            Counters = new ForwardingCounters();

            if (config != null)
            {
                //without this we'll get a null ref exception
                if (forwardingConfig == null)
                {
                    throw new ArgumentNullException("forwardingConfig", "Requires a forwardingConfig to initialize");
                }

                Config           = config;
                ForwardingConfig = forwardingConfig;
                _zoneDefinitions = config.RelayNodeMapping.ZoneDefinitions;
                Counters.Initialize(Config.InstanceName);

                if (InMessageDispatcher != null)
                {
                    if (_log.IsInfoEnabled)
                    {
                        _log.Info("Relay Forwarder Node Manager Initialized with non-null Dispatcher.");
                    }
                }
                else
                {
                    InMessageDispatcher = new Dispatcher(forwardingConfig.NumberOfThreads, ThreadPriority.Normal, true, "Relay Forwarder");
                }

                if (OutMessageDispatcher == null)
                {
                    OutMessageDispatcher = new Dispatcher(forwardingConfig.NumberOfOutMessageThreads, ThreadPriority.Normal, true, "Relay Forwader Out Messages");
                }

                NodeGroup.MaximumQueuedItems = forwardingConfig.MaximumTaskQueueDepth;

                BuildNodeGroups(config, errorQueues);

                if (config.MyAddresses != null && config.MyAddresses.Count > 0)
                {
                    for (int i = 0; i < config.MyAddresses.Count; i++)
                    {
                        AddressFamily family = config.MyAddresses[i].AddressFamily;
                        if (family == AddressFamily.InterNetwork &&
                            !IPAddress.Loopback.Equals(config.MyAddresses[i])
                            )
                        {
                            MyIpAddress = config.MyAddresses[i];
                            break;
                        }
                    }
                }

                _queuedMessageCounterTimer = new Timer(CountQueuedMessages, null, 5000, 5000);

                _aggregateCounterTickTimer = new Timer(AggregateCounterTicker, null, 500, 500);
                _myNodeDefinition          = GetMyNodeDefinition();
            }
        }
예제 #2
0
		private void InitializeInstance(RelayNodeConfig config, ForwardingConfig forwardingConfig, Dictionary<string, Dictionary<string, MessageQueue>> errorQueues)
		{
			Counters = new ForwardingCounters();

			if (config != null)
			{
				//without this we'll get a null ref exception
				if (forwardingConfig == null) throw new ArgumentNullException("forwardingConfig", "Requires a forwardingConfig to initialize");
				  
				Config = config;
				ForwardingConfig = forwardingConfig;
				_zoneDefinitions = config.RelayNodeMapping.ZoneDefinitions;		
				Counters.Initialize(Config.InstanceName);

				if (InMessageDispatcher != null)
				{
					if (_log.IsInfoEnabled)
						_log.Info("Relay Forwarder Node Manager Initialized with non-null Dispatcher.");                    
				}
				else
				{
					InMessageDispatcher = new Dispatcher(forwardingConfig.NumberOfThreads, ThreadPriority.Normal, true, "Relay Forwarder");
				}

				if (OutMessageDispatcher == null)
				{
					OutMessageDispatcher = new Dispatcher(forwardingConfig.NumberOfOutMessageThreads, ThreadPriority.Normal, true, "Relay Forwader Out Messages");
				}
				
				NodeGroup.MaximumQueuedItems = forwardingConfig.MaximumTaskQueueDepth;

				BuildNodeGroups(config, errorQueues);

				if (config.MyAddresses != null && config.MyAddresses.Count > 0)
				{	
					for (int i = 0; i < config.MyAddresses.Count; i++)
					{
						AddressFamily family = config.MyAddresses[i].AddressFamily;
						if (family == AddressFamily.InterNetwork &&
							!IPAddress.Loopback.Equals(config.MyAddresses[i])
							)
						{
							MyIpAddress = config.MyAddresses[i];
							break;
						}
					}
				}

				_queuedMessageCounterTimer = new Timer(CountQueuedMessages, null, 5000, 5000);

				_aggregateCounterTickTimer = new Timer(AggregateCounterTicker, null, 500, 500);
				_myNodeDefinition = GetMyNodeDefinition();
			}
		}
예제 #3
0
        private void InitializeInstance(RelayNodeConfig config, ForwardingConfig forwardingConfig, Dictionary <string, Dictionary <string, ErrorQueue> > errorQueues)
        {
            Counters = new ForwardingCounters();

            if (config != null)
            {
                //without this we'll get a null ref exception
                if (forwardingConfig == null)
                {
                    throw new ArgumentNullException("forwardingConfig", "Requires a forwardingConfig to initialize");
                }

                Config           = config;
                ForwardingConfig = forwardingConfig;
                _zoneDefinitions = config.RelayNodeMapping.ZoneDefinitions;
                Counters.Initialize(Config.InstanceName);

                ExtractCommonConfigValues(forwardingConfig);

                if (InMessageDispatcher != null)
                {
                    if (_log.IsInfoEnabled)
                    {
                        _log.Info("Relay Forwarder Node Manager Initialized with non-null Dispatcher.");
                    }
                }
                else
                {
                    InMessageDispatcher = new Dispatcher(forwardingConfig.NumberOfThreads, ThreadPriority.Normal, true, "Relay Forwarder");
                }

                if (OutMessageDispatcher == null)
                {
                    OutMessageDispatcher = new Dispatcher(forwardingConfig.NumberOfOutMessageThreads, ThreadPriority.Normal, true, "Relay Forwader Out Messages");
                }



                BuildNodeGroups(config, errorQueues);

                MyIpAddress = config.GetAddressToUse();

                _queuedMessageCounterTimer = new Timer(CountQueuedMessages, null, 5000, 5000);

                _aggregateCounterTickTimer = new Timer(AggregateCounterTicker, null, 500, 500);
                _myNodeDefinition          = GetMyNodeDefinition();
                _myZone = Node.DetermineZone(_myNodeDefinition);
            }
        }