@Override public StreamSinkChannel getRequestChannel() { return new DetachableStreamSinkChannel(clientConnection.getConnection().getSinkChannel()) { @Override protected boolean isFinished() { return anyAreSet(state, REQUEST_TERMINATED); } }; }
@Override public void suspendWrites() { state &= ~FLAG_WRITES_RESUMED; if(!allAreSet(state, FLAG_READS_RESUMED | FLAG_READ_REQUIRES_WRITE)) { delegate.getSinkChannel().suspendWrites(); } }
@Override public void truncateWrites() throws IOException { try { notifyWriteClosed(); } finally { delegate.getSinkChannel().close(); } }
/** * Resets the channel to its original state, effectively disabling all current conduit * wrappers. The current state is lost. */ public void clearChannel() { channel.getSinkChannel().setConduit(originalSinkConduit); channel.getSourceChannel().setConduit(originalSourceConduit); } /**
@Override public void setWriteReadyHandler(WriteReadyHandler handler) { delegate.getSinkChannel().getConduit().setWriteReadyHandler(writeReadyHandler = new SslWriteReadyHandler(handler)); }
@Override public void restoreChannel(ConduitState state) { super.restoreChannel(state); channel.getSinkChannel().getConduit().setWriteReadyHandler(writeReadyHandler); }
@Override public ConduitState resetChannel() { ConduitState state = super.resetChannel(); channel.getSinkChannel().getConduit().setWriteReadyHandler(writeReadyHandler); return state; }
@Override public void clearChannel() { super.clearChannel(); channel.getSinkChannel().getConduit().setWriteReadyHandler(writeReadyHandler); }
/** * Restores the channel conduits to a previous state. * * @param state The original state * @see #resetChannel() */ public void restoreChannel(final ConduitState state) { channel.getSinkChannel().setConduit(state.sink); channel.getSourceChannel().setConduit(state.source); }
/** * Gets the channel wrapper that implements the buffering */ public void setupPipelineBuffer(final HttpServerExchange exchange) { ((HttpServerConnection) exchange.getConnection()).getChannel().getSinkChannel().setConduit(this); }
@Override public void resumeWrites() { state |= FLAG_WRITES_RESUMED; if(anyAreSet(state, FLAG_WRITE_REQUIRES_READ)) { delegate.getSourceChannel().resumeReads(); } else { delegate.getSinkChannel().resumeWrites(); } }
public IdleTimeoutConduit(StreamConnection connection) { this.sink = connection.getSinkChannel().getConduit(); this.source = connection.getSourceChannel().getConduit(); setWriteReadyHandler(new WriteReadyHandler.ChannelListenerHandler<>(connection.getSinkChannel())); setReadReadyHandler(new ReadReadyHandler.ChannelListenerHandler<>(connection.getSourceChannel())); }
public void handleEvent(final StreamConnection channel) { final AssembledConnectedStreamChannel assembledChannel = new AssembledConnectedStreamChannel(channel, channel.getSourceChannel(), channel.getSinkChannel()); if (!futureResult.setResult(assembledChannel)) { safeClose(assembledChannel); } else { ChannelListeners.invokeChannelListener(assembledChannel, openListener); } } }
public StreamConnection performUpgrade() throws IOException { log.debugf("connection to %s is being upgraded", getPeerAddress()); // Upgrade the connection // Set the upgraded flag already to prevent new requests after this one if (allAreSet(state, UPGRADED | CLOSE_REQ | CLOSED)) { throw new IOException(UndertowClientMessages.MESSAGES.connectionClosed()); } state |= UPGRADED; connection.getSinkChannel().setConduit(originalSinkConduit); connection.getSourceChannel().setConduit(pushBackStreamSourceConduit); return connection; }
public ChannelPipe<StreamChannel, StreamChannel> createFullDuplexPipe() throws IOException { final ChannelPipe<StreamConnection, StreamConnection> connection = createFullDuplexPipeConnection(); final StreamChannel left = new AssembledStreamChannel(connection.getLeftSide(), connection.getLeftSide().getSourceChannel(), connection.getLeftSide().getSinkChannel()); final StreamChannel right = new AssembledStreamChannel(connection.getRightSide(), connection.getRightSide().getSourceChannel(), connection.getRightSide().getSinkChannel()); return new ChannelPipe<StreamChannel, StreamChannel>(left, right); }
AddressWrappedConnection(StreamConnection delegate, SocketAddress source, SocketAddress dest) { super(delegate.getIoThread()); this.delegate = delegate; this.source = source; this.dest = dest; setSinkConduit(delegate.getSinkChannel().getConduit()); setSourceConduit(delegate.getSourceChannel().getConduit()); }
private void resumeReads(boolean wakeup) { state |= FLAG_READS_RESUMED; if(anyAreSet(state, FLAG_READ_REQUIRES_WRITE)) { delegate.getSinkChannel().resumeWrites(); } else { if(anyAreSet(state, FLAG_DATA_TO_UNWRAP) || wakeup || unwrappedData != null) { runReadListener(true); } else { delegate.getSourceChannel().resumeReads(); } } }
JsseSslConnection(final StreamConnection streamConnection, final SSLEngine engine, final Pool<ByteBuffer> socketBufferPool, final Pool<ByteBuffer> applicationBufferPool) { super(streamConnection.getIoThread()); this.streamConnection = streamConnection; conduit = new JsseStreamConduit(this, engine, streamConnection.getSourceChannel().getConduit(), streamConnection.getSinkChannel().getConduit(), socketBufferPool, applicationBufferPool); setSourceConduit(conduit); setSinkConduit(conduit); }
JsseSslStreamConnection(StreamConnection connection, SSLEngine sslEngine, final Pool<ByteBuffer> socketBufferPool, final Pool<ByteBuffer> applicationBufferPool, final boolean startTls) { super(connection.getIoThread()); this.connection = connection; final StreamSinkConduit sinkConduit = connection.getSinkChannel().getConduit(); final StreamSourceConduit sourceConduit = connection.getSourceChannel().getConduit(); sslConduitEngine = new JsseSslConduitEngine(this, sinkConduit, sourceConduit, sslEngine, socketBufferPool, applicationBufferPool); tls = ! startTls; setSinkConduit(new JsseSslStreamSinkConduit(sinkConduit, sslConduitEngine, tls)); setSourceConduit(new JsseSslStreamSourceConduit(sourceConduit, sslConduitEngine, tls)); }
private void handleAccepted(final StreamConnection accepted, final SslChannel sslChannel, final OptionMap serverOptionMap, final SaslAuthenticationFactory saslAuthenticationFactory) { final RemoteConnection connection = new RemoteConnection(accepted, sslChannel, serverOptionMap, RemoteConnectionProvider.this); final ServerConnectionOpenListener openListener = new ServerConnectionOpenListener(connection, connectionProviderContext, saslAuthenticationFactory, serverOptionMap); accepted.getSinkChannel().setWriteListener(connection.getWriteListener()); log.tracef("Accepted connection from %s to %s", connection.getPeerAddress(), connection.getLocalAddress()); openListener.handleEvent(accepted.getSourceChannel()); } }