Пример #1
0
        public static void Main(string[] args)
        {
            ConsoleAppender consoleAppender = new ConsoleAppender();
            consoleAppender.Layout =
                new PatternLayout("[%thread] - %message%newline");
            log4net.Config.BasicConfigurator.Configure(consoleAppender);

            string serverURI = "http://127.0.0.1:8003";
            if (args.Length > 1)
                serverURI = args[1];
            int max1, max2;
            ThreadPool.GetMaxThreads(out max1, out max2);
            m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} max threads = {1} - {2}", serverURI, max1, max2);
            ThreadPool.GetMinThreads(out max1, out max2);
            m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} min threads = {1} - {2}", serverURI, max1, max2);

            if (!ThreadPool.SetMinThreads(1, 1))
                m_log.WarnFormat("[ASSET CLIENT]: Failed to set min threads");

            if (!ThreadPool.SetMaxThreads(10, 3))
                m_log.WarnFormat("[ASSET CLIENT]: Failed to set max threads");

            ThreadPool.GetMaxThreads(out max1, out max2);
            m_log.InfoFormat("[ASSET CLIENT]: Post set max threads = {1} - {2}", serverURI, max1, max2);
            ThreadPool.GetMinThreads(out max1, out max2);
            m_log.InfoFormat("[ASSET CLIENT]: Post set min threads = {1} - {2}", serverURI, max1, max2);

            ServicePointManager.DefaultConnectionLimit = 12;

            AssetServicesConnector m_Connector = new AssetServicesConnector(serverURI);
            m_Connector.MaxAssetRequestConcurrency = 30;

            for (int i = 0; i < NREQS; i++)
            {
                UUID uuid = UUID.Random();
                m_Connector.Get(uuid.ToString(), null, ResponseReceived);
                m_log.InfoFormat("[ASSET CLIENT]: [{0}] requested asset {1}", i, uuid);
            }

            for (int i = 0; i < 500; i++)
            {
                var x = i;
                ThreadPool.QueueUserWorkItem(delegate
                {
                    Dummy(x);
                });
            }

            Thread.Sleep(30 * 1000);
            m_log.InfoFormat("[ASSET CLIENT]: Received responses {0}", m_NReceived);
        }