Caucho.IIS.Server.OpenConnection C# (CSharp) Method

OpenConnection() public method

public OpenConnection ( ) : HmuxConnection
return HmuxConnection
        public HmuxConnection OpenConnection()
        {
            long now = Utils.CurrentTimeMillis();
              lock (this) {
            if (_failTime > 0 && (_failTime + _loadBalanceRecoverTime) > now) {
              return null;
            }

            if (_busyTime > 0 && (_busyTime + _loadBalanceRecoverTime) > now) {
              return null;
            }

            //only allow a single thread to open connection
            if ((_failTime > 0 || _busyTime > 0) && _startingCount > 0) {
              return null;
            }
              }

              HmuxConnection channel = OpenRecycle();

              if (channel != null)
            return channel;

              return Connect();
        }

Usage Example

Exemplo n.º 1
0
        public HmuxConnection OpenAnyServer(Server xChannelFactory)
        {
            int serverCount = _servers.Length;

            Server         server     = null;
            HmuxConnection connection = null;

            int id = 0;

            lock (this) {
                _roundRobinIdx = _roundRobinIdx % serverCount;
                id             = _roundRobinIdx;
                _roundRobinIdx++;
            }

            server     = _servers[id];
            connection = server.OpenConnection();

            if (connection != null)
            {
                return(connection);
            }

            lock (this) {
                _roundRobinIdx = _random.Next(serverCount);

                for (int i = 0; i < serverCount; i++)
                {
                    id = (i + _roundRobinIdx) % serverCount;

                    server = _servers[id];
                    if (xChannelFactory != server || serverCount == 1)
                    {
                        connection = server.OpenConnection();
                    }

                    _roundRobinIdx = id;

                    if (connection != null)
                    {
                        break;
                    }
                }
            }

            Trace.TraceInformation("open any server {0}", connection);

            return(connection);
        }
All Usage Examples Of Caucho.IIS.Server::OpenConnection