Exemple #1
0
        /// <summary>
        /// Stops the <see cref="RelayNode"/> server from accepting TCP/IP requests.
        /// </summary>
        public void Stop()
        {
            if (queuedMessageCounterTimer != null)
            {
                queuedMessageCounterTimer.Change(Timeout.Infinite, Timeout.Infinite);
                queuedMessageCounterTimer.Dispose();
            }

            var timer = Interlocked.Exchange(ref resetConnectionRefusalTimer, null);

            if (timer != null)
            {
                timer.Change(Timeout.Infinite, Timeout.Infinite);
                timer.Dispose();
            }

            if (RefuseOutOfClusterConnection)
            {
                RefuseOutOfClusterConnection = false;
            }

            if (log.IsInfoEnabled)
            {
                log.Info("Shutting down socket transport.");
            }
            SocketServerAdapter.Shutdown();

            if (log.IsInfoEnabled)
            {
                log.Info("Disposing Dispatcher.");
            }
            inDispatcher.Dispose();
            var od = outDispatcher;             //in case of config reload to null

            if (od != null)
            {
                outDispatcher.Dispose();
            }

            StopHttpServer();

            components.Shutdown();

            if (log.IsInfoEnabled)
            {
                log.Info("Resetting Counters");
            }

            if (counters != null)
            {
                counters.ResetCounters();
                counters.Shutdown();
                counters = null;
            }

            if (log.IsInfoEnabled)
            {
                log.Info("Relay Node Stopped.");
            }
        }
Exemple #2
0
        /// <summary>
        /// Starts the <see cref="RelayNode"/> server to listen for incoming TCP/IP
        /// requests on the configured port.
        /// </summary>
        public void Start()
        {
            counters         = new RelayNodeCounters();
            countersInternal = new RelayNodeCounters();
            countersInternal.Initialize("Internal");
            counters.Initialize(instanceName);
            if (portNumber != 0)
            {
                var  resetDuration = GetResetDuration();
                bool whitelistOnly = resetDuration > 0;
                if (whitelistOnly && clusterAddresses == null)
                {
                    throw new ApplicationException(
                              "Cannot configure refuse out of cluster connections when node not in cluster.");
                }

                SocketServerAdapter.Initialize(instanceName, portNumber, this,
                                               configuration.OutMessagesOnRelayThreads, IsInCluster,
                                               whitelistOnly);

                if (whitelistOnly)
                {
                    resetConnectionRefusalTimer = new Timer(state =>
                    {
                        var timer = Interlocked.Exchange(ref resetConnectionRefusalTimer, null);
                        if (timer != null)
                        {
                            RefuseOutOfClusterConnection = false;
                            timer.Dispose();
                        }
                    }, null, resetDuration * 1000, Timeout.Infinite);
                }
                else
                {
                    resetConnectionRefusalTimer = null;
                }
            }

            StartHttpServer();
        }
		/// <summary>
		/// Stops the <see cref="RelayNode"/> server from accepting TCP/IP requests.
		/// </summary>
		public void Stop()
		{
			if (queuedMessageCounterTimer != null)
			{
				queuedMessageCounterTimer.Change(Timeout.Infinite, Timeout.Infinite);
				queuedMessageCounterTimer.Dispose();
			}

			var timer = Interlocked.Exchange(ref resetConnectionRefusalTimer, null);
			if (timer != null)
			{
				timer.Change(Timeout.Infinite, Timeout.Infinite);
				timer.Dispose();
			}

			if (RefuseOutOfClusterConnection)
			{
				RefuseOutOfClusterConnection = false;
			}

            if(log.IsInfoEnabled)
                    log.Info("Shutting down socket transport.");
			SocketServerAdapter.Shutdown();
            
            if (log.IsInfoEnabled)
                log.Info("Disposing Dispatcher.");
			inDispatcher.Dispose();
			var od = outDispatcher; //in case of config reload to null
			if (od != null) outDispatcher.Dispose();

			StopHttpServer();

			components.Shutdown();

            if (log.IsInfoEnabled)
                log.Info("Resetting Counters");

			if (counters != null)
			{
				counters.ResetCounters();
				counters.Shutdown();
				counters = null;
			}
            
            if (log.IsInfoEnabled)
                log.Info("Relay Node Stopped.");
		}
		/// <summary>
		/// Starts the <see cref="RelayNode"/> server to listen for incoming TCP/IP 
		/// requests on the configured port.
		/// </summary>
		public void Start()
		{
			counters = new RelayNodeCounters();
			countersInternal = new RelayNodeCounters();
			countersInternal.Initialize("Internal");
			counters.Initialize(instanceName);
			if (portNumber != 0)
			{
				var resetDuration = GetResetDuration();
				bool whitelistOnly = resetDuration > 0;
				if (whitelistOnly && clusterAddresses == null)
				{
					throw new ApplicationException(
						"Cannot configure refuse out of cluster connections when node not in cluster.");
				}
				
				SocketServerAdapter.Initialize(instanceName, portNumber, this,
					configuration.OutMessagesOnRelayThreads, IsInCluster,
					whitelistOnly);

				if (whitelistOnly)
				{
					resetConnectionRefusalTimer = new Timer(state =>
                	{
                		var timer = Interlocked.Exchange(ref resetConnectionRefusalTimer, null);
						if (timer != null)
						{
							RefuseOutOfClusterConnection = false;
							timer.Dispose();
						}
                	}, null, resetDuration*1000, Timeout.Infinite);
				}
				else
				{
					resetConnectionRefusalTimer = null;
				}
			}

			StartHttpServer();
			
		}