Search in sources :

Example 6 with BytesSentStreamSinkConduit

use of io.undertow.conduits.BytesSentStreamSinkConduit in project undertow by undertow-io.

the class Http2ClientProvider method createHttp2Channel.

private static Http2ClientConnection createHttp2Channel(StreamConnection connection, ByteBufferPool bufferPool, OptionMap options, String defaultHost) {
    final ClientStatisticsImpl clientStatistics;
    //first we set up statistics, if required
    if (options.get(UndertowOptions.ENABLE_STATISTICS, false)) {
        clientStatistics = new ClientStatisticsImpl();
        connection.getSinkChannel().setConduit(new BytesSentStreamSinkConduit(connection.getSinkChannel().getConduit(), new ByteActivityCallback() {

            @Override
            public void activity(long bytes) {
                clientStatistics.written += bytes;
            }
        }));
        connection.getSourceChannel().setConduit(new BytesReceivedStreamSourceConduit(connection.getSourceChannel().getConduit(), new ByteActivityCallback() {

            @Override
            public void activity(long bytes) {
                clientStatistics.read += bytes;
            }
        }));
    } else {
        clientStatistics = null;
    }
    Http2Channel http2Channel = new Http2Channel(connection, null, bufferPool, null, true, false, options);
    return new Http2ClientConnection(http2Channel, false, defaultHost, clientStatistics, true);
}
Also used : Http2Channel(io.undertow.protocols.http2.Http2Channel) ByteActivityCallback(io.undertow.conduits.ByteActivityCallback) BytesSentStreamSinkConduit(io.undertow.conduits.BytesSentStreamSinkConduit) BytesReceivedStreamSourceConduit(io.undertow.conduits.BytesReceivedStreamSourceConduit)

Aggregations

BytesReceivedStreamSourceConduit (io.undertow.conduits.BytesReceivedStreamSourceConduit)6 BytesSentStreamSinkConduit (io.undertow.conduits.BytesSentStreamSinkConduit)6 ByteActivityCallback (io.undertow.conduits.ByteActivityCallback)3 Http2Channel (io.undertow.protocols.http2.Http2Channel)3 IOException (java.io.IOException)3 ReadTimeoutStreamSourceConduit (io.undertow.conduits.ReadTimeoutStreamSourceConduit)2 WriteTimeoutStreamSinkConduit (io.undertow.conduits.WriteTimeoutStreamSinkConduit)2 AjpClientChannel (io.undertow.protocols.ajp.AjpClientChannel)1 ByteBuffer (java.nio.ByteBuffer)1 ConduitStreamSinkChannel (org.xnio.conduits.ConduitStreamSinkChannel)1