private void replaceConnection() { EndPoint endPoint = getEndPoint(); Connection connection = client.getConnectionFactory().newConnection(channel, endPoint, attachment); endPoint.getConnection().onClose(); endPoint.setConnection(connection); connection.onOpen(); }
@Override protected void connectionClosed(final Connection connection) { super.connectionClosed(connection); disconnects.mark(); final long duration = System.currentTimeMillis() - connection.getTimeStamp(); this.duration.update(duration, TimeUnit.MILLISECONDS); connections.dec(); }
@Override public Connection newConnection(Connector connector, EndPoint endPoint) { final Connection connection = connectionFactory.newConnection(connector, endPoint); connection.addListener( new Connection.Listener() { private Timer.Context context; @Override public void onOpened(Connection connection) { this.context = timer.time(); } @Override public void onClosed(Connection connection) { context.stop(); } }); return connection; }