@Override public void close() { synchronized (this) { checkClosed(); closed = true; } if (creatingContext != null) { creatingContext.removeCloseHook(closeHook); } websocketCM.close(); httpCM.close(); if (metrics != null) { metrics.close(); } }
Endpoint endpoint = endpointMap.computeIfAbsent(key, targetAddress -> { int maxPoolSize = Math.max(client.getOptions().getMaxPoolSize(), client.getOptions().getHttp2MaxPoolSize()); Object metric = metrics != null ? metrics.createEndpoint(host, port, maxPoolSize) : null; HttpChannelConnector connector = new HttpChannelConnector(client, metric, version, ssl, peerHost, host, port); Pool<HttpClientConnection> pool = new Pool<>(ctx, connector, maxWaitQueueSize, connector.weight(), maxSize, v -> { if (metrics != null) { metrics.closeEndpoint(host, port, metric); Object metric; if (metrics != null) { metric = metrics.enqueueRequest(endpoint.metric); } else { metric = null; metrics.dequeueRequest(endpoint.metric, metric); } else { if (metrics != null) { metrics.dequeueRequest(endpoint.metric, metric);
if (metrics != null) { context.executeFromIO(v -> { Object socketMetric = metrics.connected(conn.remoteAddress(), conn.remoteName()); conn.metric(socketMetric); metrics.endpointConnected(endpointMetric, socketMetric); });
protected void handleClosed() { super.handleClosed(); if (metrics != null) { metrics.endpointDisconnected(endpointMetric, metric()); } WebSocketImpl ws; List<StreamImpl> list = Collections.emptyList(); synchronized (this) { ws = this.ws; for (StreamImpl r = responseInProgress;r != null;r = r.next) { if (metrics != null) { metrics.requestReset(r.request.metric()); } if (list.isEmpty()) { list = new ArrayList<>(); } list.add(r); } } if (ws != null) { ws.handleClosed(); } for (StreamImpl stream : list) { stream.handleException(CLOSED_EXCEPTION); } }
Object m = socketMetric; if (m == null) { m = metrics.connected(conn.remoteAddress(), conn.remoteName()); metrics.endpointConnected(queueMetric, m); handler.removeHandler(conn -> { if (metrics != null) { metrics.endpointDisconnected(queueMetric, conn.metric());
@Override public void beginRequest(HttpClientRequestImpl req) { synchronized (conn) { if (request != null) { throw new IllegalStateException("Already writing a request"); } if (conn.requestInProgress != this) { throw new IllegalStateException("Connection is already writing another request"); } request = req; if (conn.metrics != null) { Object reqMetric = conn.metrics.requestBegin(conn.endpointMetric, conn.metric(), conn.localAddress(), conn.remoteAddress(), request); request.metric(reqMetric); } } }
@Override void handleClosed() { synchronized (conn) { HttpClientMetrics metrics = ((Http1xClientConnection) conn).metrics(); if (metrics != null) { metrics.disconnected(getMetric()); } } super.handleClosed(); } }
private void handshakeComplete(ChannelHandlerContext ctx, FullHttpResponse response) { handshaking = false; ChannelHandler handler = ctx.pipeline().get(HttpContentDecompressor.class); if (handler != null) { // remove decompressor as its not needed anymore once connection was upgraded to websockets ctx.pipeline().remove(handler); } WebSocketImpl webSocket = new WebSocketImpl(vertx, Http1xClientConnection.this, supportsContinuation, options.getMaxWebsocketFrameSize(), options.getMaxWebsocketMessageSize()); ws = webSocket; handshaker.finishHandshake(chctx.channel(), response); ws.subProtocol(handshaker.actualSubprotocol()); context.executeFromIO(v -> { log.debug("WebSocket handshake complete"); if (metrics != null ) { webSocket.setMetric(metrics.connected(endpointMetric, metric(), webSocket)); } webSocket.registerHandler(vertx.eventBus()); wsConnect.handle(webSocket); }); } }
Object m = socketMetric; if (m == null) { m = metrics.connected(conn.remoteAddress(), conn.remoteName()); metrics.endpointConnected(queueMetric, m); handler.removeHandler(conn -> { if (metrics != null) { metrics.endpointDisconnected(queueMetric, conn.metric());
protected void handleClosed() { super.handleClosed(); if (metrics != null) { metrics.endpointDisconnected(endpointMetric, metric()); } WebSocketImpl ws; List<StreamImpl> list = Collections.emptyList(); synchronized (this) { ws = this.ws; for (StreamImpl r = responseInProgress;r != null;r = r.next) { if (metrics != null) { metrics.requestReset(r.request.metric()); } if (list.isEmpty()) { list = new ArrayList<>(); } list.add(r); } } if (ws != null) { ws.handleClosed(); } for (StreamImpl stream : list) { stream.handleException(CLOSED_EXCEPTION); } }
request.metric(conn.metrics.requestBegin(conn.queueMetric, conn.metric(), conn.localAddress(), conn.remoteAddress(), request));
@Override void handleClosed() { synchronized (conn) { HttpClientMetrics metrics = ((Http1xClientConnection) conn).metrics(); if (metrics != null) { metrics.disconnected(getMetric()); } } super.handleClosed(); } }
private void handshakeComplete(ChannelHandlerContext ctx, FullHttpResponse response) { handshaking = false; ChannelHandler handler = ctx.pipeline().get(HttpContentDecompressor.class); if (handler != null) { // remove decompressor as its not needed anymore once connection was upgraded to websockets ctx.pipeline().remove(handler); } WebSocketImpl webSocket = new WebSocketImpl(vertx, Http1xClientConnection.this, supportsContinuation, options.getMaxWebsocketFrameSize(), options.getMaxWebsocketMessageSize()); ws = webSocket; handshaker.finishHandshake(chctx.channel(), response); ws.subProtocol(handshaker.actualSubprotocol()); context.executeFromIO(v -> { log.debug("WebSocket handshake complete"); if (metrics != null ) { webSocket.setMetric(metrics.connected(endpointMetric, metric(), webSocket)); } webSocket.registerHandler(vertx.eventBus()); wsConnect.handle(webSocket); }); } }
Endpoint endpoint = endpointMap.computeIfAbsent(key, targetAddress -> { int maxPoolSize = Math.max(client.getOptions().getMaxPoolSize(), client.getOptions().getHttp2MaxPoolSize()); Object metric = metrics != null ? metrics.createEndpoint(host, port, maxPoolSize) : null; HttpChannelConnector connector = new HttpChannelConnector(client, metric, version, ssl, peerHost, host, port); Pool<HttpClientConnection> pool = new Pool<>(ctx, connector, maxWaitQueueSize, connector.weight(), maxSize, v -> { if (metrics != null) { metrics.closeEndpoint(host, port, metric); Object metric; if (metrics != null) { metric = metrics.enqueueRequest(endpoint.metric); } else { metric = null; metrics.dequeueRequest(endpoint.metric, metric); } else { if (metrics != null) { metrics.dequeueRequest(endpoint.metric, metric);
if (metrics != null) { context.executeFromIO(v -> { Object socketMetric = metrics.connected(conn.remoteAddress(), conn.remoteName()); conn.metric(socketMetric); metrics.endpointConnected(endpointMetric, socketMetric); });
@Override public void beginRequest(HttpClientRequestImpl req) { synchronized (conn) { if (request != null) { throw new IllegalStateException("Already writing a request"); } if (conn.requestInProgress != this) { throw new IllegalStateException("Connection is already writing another request"); } request = req; if (conn.metrics != null) { Object reqMetric = conn.metrics.requestBegin(conn.endpointMetric, conn.metric(), conn.localAddress(), conn.remoteAddress(), request); request.metric(reqMetric); } } }
@Override public void close() { synchronized (this) { checkClosed(); closed = true; } if (creatingContext != null) { creatingContext.removeCloseHook(closeHook); } websocketCM.close(); httpCM.close(); if (metrics != null) { metrics.close(); } }
request.metric(conn.metrics.requestBegin(conn.queueMetric, conn.metric(), conn.localAddress(), conn.remoteAddress(), request));