Esempio n. 1
0
        private static QueuedThreadPool CreateQueuedThreadPool(JettyThreadCalculator jtc)
        {
            BlockingQueue <ThreadStart> queue      = new BlockingArrayQueue <ThreadStart>(jtc.MinThreads, jtc.MinThreads, jtc.MaxCapacity);
            QueuedThreadPool            threadPool = new QueuedThreadPool(jtc.MaxThreads, jtc.MinThreads, JETTY_THREAD_POOL_IDLE_TIMEOUT, queue);

            threadPool.ThreadPoolBudget = null;               // mute warnings about Jetty thread pool size
            return(threadPool);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void start() throws Exception
        public override void Start()
        {
            if (_jetty == null)
            {
                VerifyAddressConfiguration();

                JettyThreadCalculator jettyThreadCalculator = new JettyThreadCalculator(_jettyMaxThreads);
                _jetty = new Server(CreateQueuedThreadPool(jettyThreadCalculator));

                if (_httpAddress != null)
                {
                    _httpConnector = _connectorFactory.createConnector(_jetty, _httpAddress, jettyThreadCalculator);
                    _jetty.addConnector(_httpConnector);
                }

                if (_httpsAddress != null)
                {
                    if (_sslPolicy == null)
                    {
                        throw new Exception("HTTPS set to enabled, but no SSL policy provided");
                    }
                    _httpsConnector = _sslSocketFactory.createConnector(_jetty, _sslPolicy, _httpsAddress, jettyThreadCalculator);
                    _jetty.addConnector(_httpsConnector);
                }

                if (_jettyCreatedCallback != null)
                {
                    _jettyCreatedCallback.accept(_jetty);
                }
            }

            _handlers      = new HandlerList();
            _jetty.Handler = _handlers;
            _handlers.addHandler(new MovedContextHandler());

            LoadAllMounts();

            if (_requestLog != null)
            {
                LoadRequestLogging();
            }

            StartJetty();
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveCorrectAmountOfThreads()
        public virtual void ShouldHaveCorrectAmountOfThreads()
        {
            JettyThreadCalculator jtc = new JettyThreadCalculator(1);

            assertEquals("Wrong acceptor value for 1 core", 1, jtc.Acceptors);
            assertEquals("Wrong selector value for 1 core", 1, jtc.Selectors);
            assertEquals("Wrong maxThreads value for 1 core", 12, jtc.MaxThreads);
            assertEquals("Wrong minThreads value for 1 core", 6, jtc.MinThreads);
            assertEquals("Wrong capacity value for 1 core", 480000, jtc.MaxCapacity);

            jtc = new JettyThreadCalculator(4);
            assertEquals("Wrong acceptor value for 4 cores", 1, jtc.Acceptors);
            assertEquals("Wrong selector value for 4 cores", 2, jtc.Selectors);
            assertEquals("Wrong maxThreads value for 4 cores", 14, jtc.MaxThreads);
            assertEquals("Wrong minThreads value for 4 cores", 8, jtc.MinThreads);
            assertEquals("Wrong capacity value for 4 cores", 480000, jtc.MaxCapacity);

            jtc = new JettyThreadCalculator(16);
            assertEquals("Wrong acceptor value for 16 cores", 2, jtc.Acceptors);
            assertEquals("Wrong selector value for 16 cores", 3, jtc.Selectors);
            assertEquals("Wrong maxThreads value for 16 cores", 21, jtc.MaxThreads);
            assertEquals("Wrong minThreads value for 16 cores", 14, jtc.MinThreads);
            assertEquals("Wrong capacity value for 16 cores", 660000, jtc.MaxCapacity);

            jtc = new JettyThreadCalculator(64);
            assertEquals("Wrong acceptor value for 64 cores", 4, jtc.Acceptors);
            assertEquals("Wrong selector value for 64 cores", 8, jtc.Selectors);
            assertEquals("Wrong maxThreads value for 64 cores", 76, jtc.MaxThreads);
            assertEquals("Wrong minThreads value for 64 cores", 36, jtc.MinThreads);
            assertEquals("Wrong capacity value for 64 cores", 3120000, jtc.MaxCapacity);

            jtc = new JettyThreadCalculator(MAX_THREADS);
            assertEquals("Wrong acceptor value for max cores", 2982, jtc.Acceptors);
            assertEquals("Wrong selector value for max cores", 5965, jtc.Selectors);
            assertEquals("Wrong maxThreads value for max cores", 53685, jtc.MaxThreads);
            assertEquals("Wrong minThreads value for max cores", 26841, jtc.MinThreads);
            assertEquals("Wrong capacity value for max cores", 2147460000, jtc.MaxCapacity);
        }
Esempio n. 4
0
        public virtual ServerConnector CreateConnector(Server server, ListenSocketAddress address, JettyThreadCalculator jettyThreadCalculator, params ConnectionFactory[] httpFactories)
        {
            int acceptors = jettyThreadCalculator.Acceptors;
            int selectors = jettyThreadCalculator.Selectors;

            ServerConnector connector = new ServerConnector(server, null, null, null, acceptors, selectors, httpFactories);

            connector.Name = _name;

            connector.ConnectionFactories = Arrays.asList(httpFactories);

            // TCP backlog, per socket, 50 is the default, consider adapting if needed
            connector.AcceptQueueSize = 50;

            connector.Host = address.Hostname;
            connector.Port = address.Port;

            return(connector);
        }
Esempio n. 5
0
        public virtual ServerConnector CreateConnector(Server server, ListenSocketAddress address, JettyThreadCalculator jettyThreadCalculator)
        {
            ConnectionFactory httpFactory = CreateHttpConnectionFactory();

            return(CreateConnector(server, address, jettyThreadCalculator, httpFactory));
        }