<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;

namespace EventStore.Core.Tests.Helper
{
    public static class TcpPortsHelper
    {
        private static readonly EventStore.Common.Concurrent.ConcurrentQueue<int> AvailablePorts = 
            new EventStore.Common.Concurrent.ConcurrentQueue<int>(GetRandomPorts(45000, 10000));

        public static int GetAvailablePort(IPAddress ip)
        {
            for (int i = 0; i < 50; ++i)
            {
                int port;
                if (!AvailablePorts.TryDequeue(out port))
                    throw new Exception("Couldn't get free TCP port for MiniNode.");
                try
                {
                    var listener = new TcpListener(ip, port);
                    listener.Start();

                    listener.Stop();
                    return port;
                }
                catch (Exception)
                {
                    AvailablePorts.Enqueue(port);
                }
            }<commit_msg>Changed: limited number of ports used by tests<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;

namespace EventStore.Core.Tests.Helper
{
    public static class TcpPortsHelper
    {
        private static readonly EventStore.Common.Concurrent.ConcurrentQueue<int> AvailablePorts = 
            new EventStore.Common.Concurrent.ConcurrentQueue<int>(GetRandomPorts(50000, 5000));

        public static int GetAvailablePort(IPAddress ip)
        {
            for (int i = 0; i < 50; ++i)
            {
                int port;
                if (!AvailablePorts.TryDequeue(out port))
                    throw new Exception("Couldn't get free TCP port for MiniNode.");
                try
                {
                    var listener = new TcpListener(ip, port);
                    listener.Start();

                    listener.Stop();
                    return port;
                }
                catch (Exception)
                {
                    AvailablePorts.Enqueue(port);
                }
            }
{'fraction_non_alphanumeric': 0.08153153153153153, 'fraction_numerical': 0.01126126126126126, 'mean_word_length': 1.5587557603686637, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4331511', 'n_tokens_mistral': 592, 'n_tokens_neox': 531, 'n_words': 137}