Search in sources :

Example 1 with FlowControlStrategy

use of org.eclipse.jetty.http2.FlowControlStrategy in project jetty.project by eclipse.

the class HTTP2ClientConnectionFactory method newConnection.

@Override
public Connection newConnection(EndPoint endPoint, Map<String, Object> context) throws IOException {
    HTTP2Client client = (HTTP2Client) context.get(CLIENT_CONTEXT_KEY);
    ByteBufferPool byteBufferPool = (ByteBufferPool) context.get(BYTE_BUFFER_POOL_CONTEXT_KEY);
    Executor executor = (Executor) context.get(EXECUTOR_CONTEXT_KEY);
    Scheduler scheduler = (Scheduler) context.get(SCHEDULER_CONTEXT_KEY);
    Session.Listener listener = (Session.Listener) context.get(SESSION_LISTENER_CONTEXT_KEY);
    @SuppressWarnings("unchecked") Promise<Session> promise = (Promise<Session>) context.get(SESSION_PROMISE_CONTEXT_KEY);
    Generator generator = new Generator(byteBufferPool);
    FlowControlStrategy flowControl = client.getFlowControlStrategyFactory().newFlowControlStrategy();
    HTTP2ClientSession session = new HTTP2ClientSession(scheduler, endPoint, generator, listener, flowControl);
    Parser parser = new Parser(byteBufferPool, session, 4096, 8192);
    HTTP2ClientConnection connection = new HTTP2ClientConnection(client, byteBufferPool, executor, endPoint, parser, session, client.getInputBufferSize(), promise, listener);
    connection.addListener(connectionListener);
    return customize(connection, context);
}
Also used : ByteBufferPool(org.eclipse.jetty.io.ByteBufferPool) Scheduler(org.eclipse.jetty.util.thread.Scheduler) Parser(org.eclipse.jetty.http2.parser.Parser) FlowControlStrategy(org.eclipse.jetty.http2.FlowControlStrategy) Promise(org.eclipse.jetty.util.Promise) Executor(java.util.concurrent.Executor) Session(org.eclipse.jetty.http2.api.Session) ISession(org.eclipse.jetty.http2.ISession) Generator(org.eclipse.jetty.http2.generator.Generator)

Example 2 with FlowControlStrategy

use of org.eclipse.jetty.http2.FlowControlStrategy in project jetty.project by eclipse.

the class AbstractHTTP2ServerConnectionFactory method newConnection.

@Override
public Connection newConnection(Connector connector, EndPoint endPoint) {
    ServerSessionListener listener = newSessionListener(connector, endPoint);
    Generator generator = new Generator(connector.getByteBufferPool(), getMaxDynamicTableSize(), getMaxHeaderBlockFragment());
    FlowControlStrategy flowControl = getFlowControlStrategyFactory().newFlowControlStrategy();
    HTTP2ServerSession session = new HTTP2ServerSession(connector.getScheduler(), endPoint, generator, listener, flowControl);
    session.setMaxLocalStreams(getMaxConcurrentStreams());
    session.setMaxRemoteStreams(getMaxConcurrentStreams());
    // For a single stream in a connection, there will be a race between
    // the stream idle timeout and the connection idle timeout. However,
    // the typical case is that the connection will be busier and the
    // stream idle timeout will expire earlier than the connection's.
    long streamIdleTimeout = getStreamIdleTimeout();
    if (streamIdleTimeout <= 0)
        streamIdleTimeout = endPoint.getIdleTimeout();
    session.setStreamIdleTimeout(streamIdleTimeout);
    session.setInitialSessionRecvWindow(getInitialSessionRecvWindow());
    ServerParser parser = newServerParser(connector, session);
    HTTP2Connection connection = new HTTP2ServerConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, httpConfiguration, parser, session, getInputBufferSize(), listener);
    connection.addListener(connectionListener);
    return configure(connection, connector, endPoint);
}
Also used : FlowControlStrategy(org.eclipse.jetty.http2.FlowControlStrategy) BufferingFlowControlStrategy(org.eclipse.jetty.http2.BufferingFlowControlStrategy) HTTP2Connection(org.eclipse.jetty.http2.HTTP2Connection) ServerParser(org.eclipse.jetty.http2.parser.ServerParser) ServerSessionListener(org.eclipse.jetty.http2.api.server.ServerSessionListener) Generator(org.eclipse.jetty.http2.generator.Generator)

Aggregations

FlowControlStrategy (org.eclipse.jetty.http2.FlowControlStrategy)2 Generator (org.eclipse.jetty.http2.generator.Generator)2 Executor (java.util.concurrent.Executor)1 BufferingFlowControlStrategy (org.eclipse.jetty.http2.BufferingFlowControlStrategy)1 HTTP2Connection (org.eclipse.jetty.http2.HTTP2Connection)1 ISession (org.eclipse.jetty.http2.ISession)1 Session (org.eclipse.jetty.http2.api.Session)1 ServerSessionListener (org.eclipse.jetty.http2.api.server.ServerSessionListener)1 Parser (org.eclipse.jetty.http2.parser.Parser)1 ServerParser (org.eclipse.jetty.http2.parser.ServerParser)1 ByteBufferPool (org.eclipse.jetty.io.ByteBufferPool)1 Promise (org.eclipse.jetty.util.Promise)1 Scheduler (org.eclipse.jetty.util.thread.Scheduler)1