public async Task Open()

in src/Apache.IoTDB/SessionPool.cs [233:293]


        public async Task Open(CancellationToken cancellationToken = default)
        {
            _clients = new ConcurrentClientQueue();
            _clients.Timeout = _timeout * 5;

            if (_nodeUrls.Count == 0)
            {
                for (var index = 0; index < _poolSize; index++)
                {
                    try
                    {
                        _clients.Add(await CreateAndOpen(_host, _port, _enableRpcCompression, _timeout, _sqlDialect, _database, cancellationToken));
                    }
                    catch (Exception e)
                    {
                        if (_debugMode)
                        {
                            _logger.LogWarning(e, "Currently connecting to {0}:{1} failed", _host, _port);
                        }
                    }
                }
            }
            else
            {
                int startIndex = 0;
                for (var index = 0; index < _poolSize; index++)
                {
                    bool isConnected = false;
                    for (int i = 0; i < _endPoints.Count; i++)
                    {
                        var endPointIndex = (startIndex + i) % _endPoints.Count;
                        var endPoint = _endPoints[endPointIndex];
                        try
                        {
                            var client = await CreateAndOpen(endPoint.Ip, endPoint.Port, _enableRpcCompression, _timeout, _sqlDialect, _database, cancellationToken);
                            _clients.Add(client);
                            isConnected = true;
                            startIndex = (endPointIndex + 1) % _endPoints.Count;
                            break;
                        }
                        catch (Exception e)
                        {
                            if (_debugMode)
                            {
                                _logger.LogWarning(e, "Currently connecting to {0}:{1} failed", endPoint.Ip, endPoint.Port);
                            }
                        }
                    }
                    if (!isConnected) // current client could not connect to any endpoint
                    {
                        throw new TException("Error occurs when opening session pool. Could not connect to any server", null);
                    }
                }
            }

            if (_clients.ClientQueue.Count != _poolSize)
            {
                throw new TException(string.Format("Error occurs when opening session pool. Client pool size is not equal to the expected size. Client pool size: {0}, expected size: {1}, Please check the server status", _clients.ClientQueue.Count, _poolSize), null);
            }
            _isClose = false;
        }