@Override public void onOpened(Connection connection) { synchronized (monitor) { connectionsAccepting.remove(connection.getEndPoint().getTransport()); ++connectionOpened; } }
@Override public void onOpened(Connection connection) { synchronized (this) { _accepting.remove(connection.getEndPoint().getTransport()); _connections++; if (LOG.isDebugEnabled()) LOG.debug("onOpened ({}+{}) < {} {}",_accepting.size(),_connections,_maxConnections,connection); check(); } }
@Override public void onOpened(Connection connection) { EndPoint endp = connection.getEndPoint(); boolean ssl=false; if (_ssl && endp instanceof DecryptedEndPoint) { endp = ((DecryptedEndPoint)endp).getSslConnection().getEndPoint(); ssl=true; } if (endp instanceof ChannelEndPoint) { Socket socket = ((ChannelEndPoint)endp).getSocket(); customize(socket,connection.getClass(),ssl); } }
@Override public void onOpen() { super.onOpen(); final int remaining = buffer.remaining(); write(getConnection().getEndPoint(), buffer, new Callback() { @Override public void succeeded() { if (LOG.isDebugEnabled()) LOG.debug("{} wrote initial {} bytes to server", DownstreamConnection.this, remaining); fillInterested(); } @Override public void failed(Throwable x) { if (LOG.isDebugEnabled()) LOG.debug(this + " failed to write initial " + remaining + " bytes to server", x); close(); getConnection().close(); } }); }
/** * Replaces the given {@code oldConnection} with the given {@code newConnection} on the * {@link EndPoint} associated with {@code oldConnection}, performing connection lifecycle management. * <p /> * The {@code oldConnection} will be closed by invoking {@link org.eclipse.jetty.io.Connection#onClose()} * and the {@code newConnection} will be opened by invoking {@link org.eclipse.jetty.io.Connection#onOpen(ByteBuffer)}. * @param oldConnection the old connection to replace * @param newConnection the new connection replacement */ public static void replaceConnection(Connection oldConnection, Connection newConnection) { close(oldConnection); oldConnection.getEndPoint().setConnection(newConnection); open(newConnection); }
@Override public void onOpened(Connection connection) { EndPoint endp = connection.getEndPoint(); boolean ssl=false; if (_ssl && endp instanceof DecryptedEndPoint) { endp = ((DecryptedEndPoint)endp).getSslConnection().getEndPoint(); ssl=true; } if (endp instanceof SocketChannelEndPoint) { Socket socket = ((SocketChannelEndPoint)endp).getSocket(); customize(socket,connection.getClass(),ssl); } }
@Override public void configure(SSLEngine sslEngine, Connection connection) { ALPNClientConnection alpn = (ALPNClientConnection)connection; SSLParameters sslParameters = sslEngine.getSSLParameters(); List<String> protocols = alpn.getProtocols(); sslParameters.setApplicationProtocols(protocols.toArray(new String[protocols.size()])); sslEngine.setSSLParameters(sslParameters); ((DecryptedEndPoint)connection.getEndPoint()).getSslConnection() .addHandshakeListener(new ALPNListener(alpn)); }
@Override public void upgrade(Connection newConnection) { Connection old_connection = getConnection(); if (LOG.isDebugEnabled()) LOG.debug("{} upgrading from {} to {}", this, old_connection, newConnection); ByteBuffer prefilled = (old_connection instanceof Connection.UpgradeFrom) ?((Connection.UpgradeFrom)old_connection).onUpgradeFrom():null; old_connection.onClose(); old_connection.getEndPoint().setConnection(newConnection); if (newConnection instanceof Connection.UpgradeTo) ((Connection.UpgradeTo)newConnection).onUpgradeTo(prefilled); else if (BufferUtil.hasContent(prefilled)) throw new IllegalStateException(); newConnection.onOpen(); }
@Override public void upgrade(Connection newConnection) { Connection old_connection = getConnection(); if (LOG.isDebugEnabled()) LOG.debug("{} upgrading from {} to {}", this, old_connection, newConnection); ByteBuffer prefilled = (old_connection instanceof Connection.UpgradeFrom) ?((Connection.UpgradeFrom)old_connection).onUpgradeFrom():null; old_connection.onClose(); old_connection.getEndPoint().setConnection(newConnection); if (newConnection instanceof Connection.UpgradeTo) ((Connection.UpgradeTo)newConnection).onUpgradeTo(prefilled); else if (BufferUtil.hasContent(prefilled)) throw new IllegalStateException(); newConnection.onOpen(); }
@Override public void upgrade(Connection newConnection) { Connection old_connection = getConnection(); if (LOG.isDebugEnabled()) LOG.debug("{} upgrading from {} to {}", this, old_connection, newConnection); ByteBuffer prefilled = (old_connection instanceof Connection.UpgradeFrom) ?((Connection.UpgradeFrom)old_connection).onUpgradeFrom():null; old_connection.onClose(); old_connection.getEndPoint().setConnection(newConnection); if (newConnection instanceof Connection.UpgradeTo) ((Connection.UpgradeTo)newConnection).onUpgradeTo(prefilled); else if (BufferUtil.hasContent(prefilled)) throw new IllegalStateException(); newConnection.onOpen(); }
@Override public void upgrade(Connection newConnection) { Connection old_connection = getConnection(); if (LOG.isDebugEnabled()) LOG.debug("{} upgrading from {} to {}", this, old_connection, newConnection); ByteBuffer prefilled = (old_connection instanceof Connection.UpgradeFrom) ?((Connection.UpgradeFrom)old_connection).onUpgradeFrom():null; old_connection.onClose(); old_connection.getEndPoint().setConnection(newConnection); if (newConnection instanceof Connection.UpgradeTo) ((Connection.UpgradeTo)newConnection).onUpgradeTo(prefilled); else if (BufferUtil.hasContent(prefilled)) throw new IllegalStateException(); newConnection.onOpen(); }
connection.getEndPoint().write(new Callback() { connection.getEndPoint().shutdownOutput();
if (filled > 0) write(connection.getEndPoint(), buffer, this); return Action.SCHEDULED; connection.getEndPoint().shutdownOutput(); return Action.SUCCEEDED;