Search in sources :

Example 6 with ServerSessionListener

use of org.eclipse.jetty.http2.api.server.ServerSessionListener in project jetty.project by eclipse.

the class FlowControlStrategyTest method start.

protected void start(ServerSessionListener listener) throws Exception {
    QueuedThreadPool serverExecutor = new QueuedThreadPool();
    serverExecutor.setName("server");
    server = new Server(serverExecutor);
    RawHTTP2ServerConnectionFactory connectionFactory = new RawHTTP2ServerConnectionFactory(new HttpConfiguration(), listener);
    connectionFactory.setFlowControlStrategyFactory(FlowControlStrategyTest.this::newFlowControlStrategy);
    connector = new ServerConnector(server, connectionFactory);
    server.addConnector(connector);
    server.start();
    client = new HTTP2Client();
    QueuedThreadPool clientExecutor = new QueuedThreadPool();
    clientExecutor.setName("client");
    client.setExecutor(clientExecutor);
    client.setFlowControlStrategyFactory(FlowControlStrategyTest.this::newFlowControlStrategy);
    client.start();
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) RawHTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory) Server(org.eclipse.jetty.server.Server) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration)

Example 7 with ServerSessionListener

use of org.eclipse.jetty.http2.api.server.ServerSessionListener in project jetty.project by eclipse.

the class AbstractTest method start.

protected void start(ServerSessionListener listener) throws Exception {
    prepareServer(new RawHTTP2ServerConnectionFactory(new HttpConfiguration(), listener));
    server.start();
    prepareClient();
    client.start();
}
Also used : RawHTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration)

Example 8 with ServerSessionListener

use of org.eclipse.jetty.http2.api.server.ServerSessionListener 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

HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)7 RawHTTP2ServerConnectionFactory (org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory)5 ServerSessionListener (org.eclipse.jetty.http2.api.server.ServerSessionListener)3 Server (org.eclipse.jetty.server.Server)3 ServerConnector (org.eclipse.jetty.server.ServerConnector)3 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 HttpFields (org.eclipse.jetty.http.HttpFields)2 MetaData (org.eclipse.jetty.http.MetaData)2 Session (org.eclipse.jetty.http2.api.Session)2 Stream (org.eclipse.jetty.http2.api.Stream)2 HeadersFrame (org.eclipse.jetty.http2.frames.HeadersFrame)2 Generator (org.eclipse.jetty.http2.generator.Generator)2 EndPoint (org.eclipse.jetty.io.EndPoint)2 Connector (org.eclipse.jetty.server.Connector)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 ByteBuffer (java.nio.ByteBuffer)1 SocketChannel (java.nio.channels.SocketChannel)1