@Override public Connector build(Server server, MetricRegistry metrics, String name, @Nullable ThreadPool threadPool) { final HttpConfiguration httpConfig = buildHttpConfiguration(); final HttpConnectionFactory httpConnectionFactory = buildHttpConnectionFactory(httpConfig); final Scheduler scheduler = new ScheduledExecutorScheduler(); final ByteBufferPool bufferPool = buildBufferPool(); return buildConnector(server, scheduler, bufferPool, name, threadPool, new Jetty93InstrumentedConnectionFactory(httpConnectionFactory, metrics.timer(httpConnections()))); }
@Override public void afterPropertiesSet() throws Exception { String name = this.threadPrefix + "@" + Integer.toHexString(hashCode()); if (this.executor == null) { QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setName(name); this.executor = threadPool; } if (this.byteBufferPool == null) { this.byteBufferPool = new MappedByteBufferPool(2048, this.executor instanceof ThreadPool.SizedThreadPool ? ((ThreadPool.SizedThreadPool) executor).getMaxThreads() / 2 : ProcessorUtils.availableProcessors() * 2); } if (this.scheduler == null) { this.scheduler = new ScheduledExecutorScheduler(name + "-scheduler", false); } if (this.executor instanceof LifeCycle) { ((LifeCycle)this.executor).start(); } this.scheduler.start(); }
@Override public Connector build(Server server, MetricRegistry metrics, String name, @Nullable ThreadPool threadPool) { // Prepare connection factories for HTTP/2c final HttpConfiguration httpConfig = buildHttpConfiguration(); final HttpConnectionFactory http11 = buildHttpConnectionFactory(httpConfig); final HTTP2ServerConnectionFactory http2c = new HTTP2CServerConnectionFactory(httpConfig); http2c.setMaxConcurrentStreams(maxConcurrentStreams); http2c.setInitialStreamRecvWindow(initialStreamRecvWindow); // The server connector should use HTTP/1.1 by default. It affords to the server to stay compatible // with old clients. New clients which want to use HTTP/2, however, will make an HTTP/1.1 OPTIONS // request with an Upgrade header with "h2c" value. The server supports HTTP/2 clear text connections, // so it will return the predefined HTTP/2 preamble and the client and the server will switch to the // new protocol. return buildConnector(server, new ScheduledExecutorScheduler(), buildBufferPool(), name, threadPool, new Jetty93InstrumentedConnectionFactory(http11, metrics.timer(httpConnections())), http2c); } }
@Override public void afterPropertiesSet() throws Exception { String name = this.threadPrefix + "@" + Integer.toHexString(hashCode()); if (this.executor == null) { QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setName(name); this.executor = threadPool; } if (this.byteBufferPool == null) { this.byteBufferPool = new MappedByteBufferPool(2048, this.executor instanceof ThreadPool.SizedThreadPool ? ((ThreadPool.SizedThreadPool) executor).getMaxThreads() / 2 : ProcessorUtils.availableProcessors() * 2); } if (this.scheduler == null) { this.scheduler = new ScheduledExecutorScheduler(name + "-scheduler", false); } if (this.executor instanceof LifeCycle) { ((LifeCycle)this.executor).start(); } this.scheduler.start(); }
@Override public Connector build(Server server, MetricRegistry metrics, String name, @Nullable ThreadPool threadPool) { final HttpConfiguration httpConfig = buildHttpConfiguration(); final HttpConnectionFactory httpConnectionFactory = buildHttpConnectionFactory(httpConfig); final SslContextFactory sslContextFactory = configureSslContextFactory(new SslContextFactory()); sslContextFactory.addLifeCycleListener(logSslInfoOnStart(sslContextFactory)); server.addBean(sslContextFactory); server.addBean(new SslReload(sslContextFactory, this::configureSslContextFactory)); final SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.toString()); final Scheduler scheduler = new ScheduledExecutorScheduler(); final ByteBufferPool bufferPool = buildBufferPool(); return buildConnector(server, scheduler, bufferPool, name, threadPool, new Jetty93InstrumentedConnectionFactory( sslConnectionFactory, metrics.timer(httpConnections())), httpConnectionFactory); }
@Override public Connector build(Server server, MetricRegistry metrics, String name, @Nullable ThreadPool threadPool) { // HTTP/2 requires that a server MUST support TLSv1.2 and TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher // See http://http2.github.io/http2-spec/index.html#rfc.section.9.2.2 setSupportedProtocols(Collections.singletonList("TLSv1.2")); checkSupportedCipherSuites(); // Setup connection factories final HttpConfiguration httpConfig = buildHttpConfiguration(); final HttpConnectionFactory http1 = buildHttpConnectionFactory(httpConfig); final HTTP2ServerConnectionFactory http2 = new HTTP2ServerConnectionFactory(httpConfig); http2.setMaxConcurrentStreams(maxConcurrentStreams); http2.setInitialStreamRecvWindow(initialStreamRecvWindow); final NegotiatingServerConnectionFactory alpn = new ALPNServerConnectionFactory(H2, H2_17); alpn.setDefaultProtocol(HTTP_1_1); // Speak HTTP 1.1 over TLS if negotiation fails final SslContextFactory sslContextFactory = configureSslContextFactory(new SslContextFactory()); sslContextFactory.addLifeCycleListener(logSslInfoOnStart(sslContextFactory)); server.addBean(sslContextFactory); server.addBean(new SslReload(sslContextFactory, this::configureSslContextFactory)); // We should use ALPN as a negotiation protocol. Old clients that don't support it will be served // via HTTPS. New clients, however, that want to use HTTP/2 will use TLS with ALPN extension. // If negotiation succeeds, the client and server switch to HTTP/2 protocol. final SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, "alpn"); return buildConnector(server, new ScheduledExecutorScheduler(), buildBufferPool(), name, threadPool, new Jetty93InstrumentedConnectionFactory(sslConnectionFactory, metrics.timer(httpConnections())), alpn, http2, http1); }
ArmeriaConnector(Server server) { this.server = server; executor = server.getThreadPool(); final HttpConfiguration httpConfig = server.getBean(HttpConfiguration.class); this.httpConfig = httpConfig != null ? httpConfig : new HttpConfiguration(); final Scheduler scheduler = server.getBean(Scheduler.class); this.scheduler = scheduler != null ? scheduler : new ScheduledExecutorScheduler(); final ByteBufferPool byteBufferPool = server.getBean(ByteBufferPool.class); this.byteBufferPool = byteBufferPool != null ? byteBufferPool : new ArrayByteBufferPool(); addBean(server, false); addBean(executor); unmanage(executor); addBean(this.httpConfig); addBean(this.scheduler); addBean(this.byteBufferPool); connectionFactory = new ArmeriaConnectionFactory(); connectionFactories = Collections.singleton(connectionFactory); }
server.addBean(new ScheduledExecutorScheduler("JettyScheduler", true), true);
server.addBean(new ScheduledExecutorScheduler());
private static Scheduler createScheduler(String name, int timeoutConcurrency, int timeoutThreads) { Scheduler scheduler; String threadName = "http-client-" + name + "-scheduler"; if ((timeoutConcurrency == 1) && (timeoutThreads == 1)) { scheduler = new ScheduledExecutorScheduler(threadName, true); } else { checkArgument(timeoutConcurrency >= 1, "timeoutConcurrency must be at least one"); int threads = max(1, timeoutThreads / timeoutConcurrency); scheduler = new ConcurrentScheduler(timeoutConcurrency, threads, threadName); } try { scheduler.start(); } catch (Exception e) { throwIfUnchecked(e); throw new RuntimeException(e); } return scheduler; }
private static Scheduler createScheduler(String name, int timeoutConcurrency, int timeoutThreads) { Scheduler scheduler; String threadName = "http-client-" + name + "-scheduler"; if ((timeoutConcurrency == 1) && (timeoutThreads == 1)) { scheduler = new ScheduledExecutorScheduler(threadName, true); } else { checkArgument(timeoutConcurrency >= 1, "timeoutConcurrency must be at least one"); int threads = max(1, timeoutThreads / timeoutConcurrency); scheduler = new ConcurrentScheduler(timeoutConcurrency, threads, threadName); } try { scheduler.start(); } catch (Exception e) { throwIfUnchecked(e); throw new RuntimeException(e); } return scheduler; }
@Override public Connector build(Server server, MetricRegistry metrics, String name, @Nullable ThreadPool threadPool) { final HttpConfiguration httpConfig = buildHttpConfiguration(); final HttpConnectionFactory httpConnectionFactory = buildHttpConnectionFactory(httpConfig); final Scheduler scheduler = new ScheduledExecutorScheduler(); final ByteBufferPool bufferPool = buildBufferPool(); return buildConnector(server, scheduler, bufferPool, name, threadPool, new Jetty93InstrumentedConnectionFactory(httpConnectionFactory, metrics.timer(httpConnections()))); }
@Override public void afterPropertiesSet() throws Exception { String name = this.threadPrefix + "@" + Integer.toHexString(hashCode()); if (this.executor == null) { QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setName(name); this.executor = threadPool; } if (this.byteBufferPool == null) { this.byteBufferPool = new MappedByteBufferPool(2048, this.executor instanceof ThreadPool.SizedThreadPool ? ((ThreadPool.SizedThreadPool) executor).getMaxThreads() / 2 : ProcessorUtils.availableProcessors() * 2); } if (this.scheduler == null) { this.scheduler = new ScheduledExecutorScheduler(name + "-scheduler", false); } if (this.executor instanceof LifeCycle) { ((LifeCycle)this.executor).start(); } this.scheduler.start(); }
@Override public void afterPropertiesSet() throws Exception { String name = this.threadPrefix + "@" + Integer.toHexString(hashCode()); if (this.executor == null) { QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setName(name); this.executor = threadPool; } if (this.byteBufferPool == null) { this.byteBufferPool = new MappedByteBufferPool(2048, this.executor instanceof ThreadPool.SizedThreadPool ? ((ThreadPool.SizedThreadPool) executor).getMaxThreads() / 2 : ProcessorUtils.availableProcessors() * 2); } if (this.scheduler == null) { this.scheduler = new ScheduledExecutorScheduler(name + "-scheduler", false); } if (this.executor instanceof LifeCycle) { ((LifeCycle)this.executor).start(); } this.scheduler.start(); }
HttpServiceContext( final HandlerContainer parent, final Map<String, String> initParams, final Map<String, Object> attributes, final String contextName, final WebContainerContext httpContext, final AccessControlContext accessControllerContext, final Map<ServletContainerInitializer, Set<Class<?>>> containerInitializers, URL jettyWebXmlUrl, List<String> virtualHosts) { super(parent, "/" + contextName, SESSIONS | SECURITY); LOG.info("registering context {}, with context-name: {}", httpContext, contextName); getInitParams().putAll(initParams); this.attributes = attributes; this.httpContext = httpContext; this.accessControllerContext = accessControllerContext; setDisplayName(httpContext.getContextId()); this.servletContainerInitializers = containerInitializers != null ? containerInitializers : new HashMap<>(); this.virtualHosts = new ArrayList<>(virtualHosts); jettyWebXmlURL = jettyWebXmlUrl; _scontext = new SContext(); // TCCL of sessionManager timer threads will be set to thread of pax-web-jetty bundle, not to current TCCL ScheduledExecutorScheduler executorScheduler = new ScheduledExecutorScheduler(getSessionHandler().toString() + "Timer", true, getClass().getClassLoader()); getSessionHandler().addBean(executorScheduler, true); _scontext.setAttribute("org.eclipse.jetty.server.session.timer", executorScheduler); setServletHandler(new HttpServiceServletHandler(httpContext)); setErrorHandler(new ErrorPageErrorHandler()); }
@Override public Connector build(Server server, MetricRegistry metrics, String name, @Nullable ThreadPool threadPool) { // Prepare connection factories for HTTP/2c final HttpConfiguration httpConfig = buildHttpConfiguration(); final HttpConnectionFactory http11 = buildHttpConnectionFactory(httpConfig); final HTTP2ServerConnectionFactory http2c = new HTTP2CServerConnectionFactory(httpConfig); http2c.setMaxConcurrentStreams(maxConcurrentStreams); http2c.setInitialStreamRecvWindow(initialStreamRecvWindow); // The server connector should use HTTP/1.1 by default. It affords to the server to stay compatible // with old clients. New clients which want to use HTTP/2, however, will make an HTTP/1.1 OPTIONS // request with an Upgrade header with "h2c" value. The server supports HTTP/2 clear text connections, // so it will return the predefined HTTP/2 preamble and the client and the server will switch to the // new protocol. return buildConnector(server, new ScheduledExecutorScheduler(), buildBufferPool(), name, threadPool, new Jetty93InstrumentedConnectionFactory(http11, metrics.timer(httpConnections())), http2c); } }
/** * Get a scheduler. First try a common scheduler, failing that * create our own. * * @throws Exception when the scheduler cannot be started */ protected void findScheduler() throws Exception { if (_scheduler == null) { if (_sessionIdManager instanceof DefaultSessionIdManager) { //try and use a common scheduler, fallback to own _scheduler = ((DefaultSessionIdManager)_sessionIdManager).getServer().getBean(Scheduler.class); } if (_scheduler == null) { _scheduler = new ScheduledExecutorScheduler(); _ownScheduler = true; _scheduler.start(); if (LOG.isDebugEnabled()) LOG.debug("Using own scheduler for scavenging"); } else if (!_scheduler.isStarted()) throw new IllegalStateException("Shared scheduler not started"); } }
if (scheduler==null) scheduler=_server.getBean(Scheduler.class); _scheduler=scheduler!=null?scheduler:new ScheduledExecutorScheduler(); if (pool==null) pool=_server.getBean(ByteBufferPool.class);
if (scheduler==null) scheduler=_server.getBean(Scheduler.class); _scheduler=scheduler!=null?scheduler:new ScheduledExecutorScheduler(); if (pool==null) pool=_server.getBean(ByteBufferPool.class);
_timer=new ScheduledExecutorScheduler(toString()+"Timer",true); addBean(_timer,true);