3333 */
3434public class Http2ClientConnectionImpl extends Http2ConnectionImpl implements HttpClientConnection , Http2ClientConnection {
3535
36- private final HttpClientBase client ;
36+ private final HttpClientMetrics clientMetrics ;
37+ private final HttpClientOptions options ;
3738 private final ClientMetrics metrics ;
3839 private final HostAndPort authority ;
3940 private final long lifetimeEvictionTimestamp ;
@@ -43,24 +44,22 @@ public class Http2ClientConnectionImpl extends Http2ConnectionImpl implements Ht
4344 private boolean evicted ;
4445 private final VertxHttp2ConnectionHandler handler ;
4546
46- Http2ClientConnectionImpl (HttpClientBase client ,
47- ContextInternal context ,
47+ Http2ClientConnectionImpl (ContextInternal context ,
4848 HostAndPort authority ,
4949 VertxHttp2ConnectionHandler connHandler ,
50+ HttpClientMetrics clientMetrics ,
5051 ClientMetrics metrics ,
52+ HttpClientOptions options ,
5153 long maxLifetime ) {
5254 super (context , connHandler );
5355 this .metrics = metrics ;
54- this .client = client ;
56+ this .clientMetrics = clientMetrics ;
57+ this .options = options ;
5558 this .authority = authority ;
5659 this .lifetimeEvictionTimestamp = maxLifetime > 0 ? System .currentTimeMillis () + maxLifetime : Long .MAX_VALUE ;
5760 this .handler = connHandler ;
5861 }
5962
60- HttpClientBase client () {
61- return client ;
62- }
63-
6463 @ Override
6564 public MultiMap newHttpRequestHeaders () {
6665 return new HttpResponseHeaders (new DefaultHttp2Headers ());
@@ -90,7 +89,7 @@ public Http2ClientConnectionImpl concurrencyChangeHandler(Handler<Long> handler)
9089
9190 public long concurrency () {
9291 long concurrency = remoteSettings ().getMaxConcurrentStreams ();
93- long http2MaxConcurrency = client . options () .getHttp2MultiplexingLimit () <= 0 ? Long .MAX_VALUE : client . options () .getHttp2MultiplexingLimit ();
92+ long http2MaxConcurrency = options .getHttp2MultiplexingLimit () <= 0 ? Long .MAX_VALUE : options .getHttp2MultiplexingLimit ();
9493 if (http2MaxConcurrency > 0 ) {
9594 concurrency = Math .min (concurrency , http2MaxConcurrency );
9695 }
@@ -136,7 +135,7 @@ private void tryEvict() {
136135
137136 @ Override
138137 protected void concurrencyChanged (long concurrency ) {
139- int limit = client . options () .getHttp2MultiplexingLimit ();
138+ int limit = options .getHttp2MultiplexingLimit ();
140139 if (limit > 0 ) {
141140 concurrency = Math .min (concurrency , limit );
142141 }
@@ -145,7 +144,7 @@ protected void concurrencyChanged(long concurrency) {
145144
146145 @ Override
147146 public HttpClientMetrics metrics () {
148- return client . metrics () ;
147+ return clientMetrics ;
149148 }
150149
151150 ClientMetrics clientMetrics () {
@@ -154,7 +153,7 @@ ClientMetrics clientMetrics() {
154153
155154 public HttpClientStream upgradeStream (Object metric , Object trace , ContextInternal context ) {
156155 Http2Stream nettyStream = handler .connection ().stream (1 );
157- Http2ClientStream s = Http2ClientStream .create (nettyStream .id (), this , context , client . options .getTracingPolicy (), client . options .isDecompressionSupported (), clientMetrics (), isWritable (1 ));
156+ Http2ClientStream s = Http2ClientStream .create (nettyStream .id (), this , context , options .getTracingPolicy (), options .isDecompressionSupported (), clientMetrics (), isWritable (1 ));
158157 s .upgrade (metric , trace );
159158 nettyStream .setProperty (streamKey , s );
160159 return s .unwrap ();
@@ -176,13 +175,13 @@ private Http2ClientStream createStream0(ContextInternal context) {
176175 return Http2ClientStream .create (
177176 this ,
178177 context ,
179- client . options .getTracingPolicy (),
180- client . options .isDecompressionSupported (),
178+ options .getTracingPolicy (),
179+ options .isDecompressionSupported (),
181180 clientMetrics ());
182181 }
183182
184183 private void recycle () {
185- int timeout = client . options () .getHttp2KeepAliveTimeout ();
184+ int timeout = options .getHttp2KeepAliveTimeout ();
186185 expirationTimestamp = timeout > 0 ? System .currentTimeMillis () + timeout * 1000L : Long .MAX_VALUE ;
187186 }
188187
@@ -231,7 +230,7 @@ public synchronized void onPushPromiseRead(ChannelHandlerContext ctx, int stream
231230 if (stream != null ) {
232231 Http2Stream promisedStream = handler .connection ().stream (promisedStreamId );
233232// Http2ClientStreamImpl pushStream = new Http2ClientStreamImpl(this, context, client.options.getTracingPolicy(), client.options.isDecompressionSupported(), clientMetrics());
234- Http2ClientStream s = Http2ClientStream .create (this , context , client . options .getTracingPolicy (), client . options .isDecompressionSupported (), clientMetrics ());
233+ Http2ClientStream s = Http2ClientStream .create (this , context , options .getTracingPolicy (), options .isDecompressionSupported (), clientMetrics ());
235234// pushStream.init(s);
236235// pushStream.stream = s;
237236 promisedStream .setProperty (streamKey , s );
@@ -252,22 +251,21 @@ protected void handleIdle(IdleStateEvent event) {
252251 }
253252
254253 public static VertxHttp2ConnectionHandler <Http2ClientConnectionImpl > createHttp2ConnectionHandler (
255- HttpClientBase client ,
254+ HttpClientOptions options ,
255+ HttpClientMetrics clientMetrics ,
256256 ClientMetrics metrics ,
257257 ContextInternal context ,
258258 boolean upgrade ,
259259 Object socketMetric ,
260260 HostAndPort authority ,
261261 long maxLifetime ) {
262- HttpClientOptions options = client .options ();
263- HttpClientMetrics met = client .metrics ();
264262 VertxHttp2ConnectionHandler <Http2ClientConnectionImpl > handler = new VertxHttp2ConnectionHandlerBuilder <Http2ClientConnectionImpl >()
265263 .server (false )
266- .useDecompression (client . options () .isDecompressionSupported ())
264+ .useDecompression (options .isDecompressionSupported ())
267265 .gracefulShutdownTimeoutMillis (0 ) // So client close tests don't hang 30 seconds - make this configurable later but requires HTTP/1 impl
268- .initialSettings (client . options () .getInitialSettings ())
266+ .initialSettings (options .getInitialSettings ())
269267 .connectionFactory (connHandler -> {
270- Http2ClientConnectionImpl conn = new Http2ClientConnectionImpl (client , context , authority , connHandler , metrics , maxLifetime );
268+ Http2ClientConnectionImpl conn = new Http2ClientConnectionImpl (context , authority , connHandler , clientMetrics , metrics , options , maxLifetime );
271269 if (metrics != null ) {
272270 Object m = socketMetric ;
273271 conn .metric (m );
@@ -279,13 +277,13 @@ public static VertxHttp2ConnectionHandler<Http2ClientConnectionImpl> createHttp2
279277 handler .addHandler (conn -> {
280278 if (metrics != null ) {
281279 if (!upgrade ) {
282- met .endpointConnected (metrics );
280+ clientMetrics .endpointConnected (metrics );
283281 }
284282 }
285283 });
286284 handler .removeHandler (conn -> {
287285 if (metrics != null ) {
288- met .endpointDisconnected (metrics );
286+ clientMetrics .endpointDisconnected (metrics );
289287 }
290288 conn .tryEvict ();
291289 });
0 commit comments