Beispiel #1
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>
		/// 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();
			
		}