@Override protected ConduitStreamSourceChannel getSourceChannel() { return channel.getSourceChannel(); }
@Override public StreamSourceChannel getResponseChannel() { return new DetachableStreamSourceChannel(clientConnection.getConnection().getSourceChannel()) { @Override protected boolean isFinished() { return anyAreSet(state, RESPONSE_TERMINATED); } }; }
@Override protected void notifyReadClosed() { IoUtils.safeClose(delegate.getSourceChannel()); }
private void doResume() { if (readData != null && !readData.isFreed()) { channel.getSourceChannel().wakeupReads(); } else { channel.getSourceChannel().resumeReads(); } }
@Override public void run() { if (allAreSet(state, FLAG_READS_RESUMED)) { delegate.getSourceChannel().resumeReads(); } runReadListenerCommand.run(); } };
@Override public void suspendReads() { state &= ~FLAG_READS_RESUMED; if(!allAreSet(state, FLAG_WRITES_RESUMED | FLAG_WRITE_REQUIRES_READ)) { delegate.getSourceChannel().suspendReads(); } }
@Override protected StreamConnection upgradeChannel() { clearChannel(); if (extraBytes != null) { channel.getSourceChannel().setConduit(new ReadDataStreamSourceConduit(channel.getSourceChannel().getConduit(), this)); } return channel; }
@Override public void handleEvent(StreamSinkChannel channel) { channel.suspendWrites(); new UpgradeResultListener().handleEvent(connection.getSourceChannel()); } }, new ChannelExceptionHandler<StreamSinkChannel>() {
/** * 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); } /**
private void callOpenListener(StreamConnection streamConnection, final PooledByteBuffer buffer) { if (openListener instanceof DelegateOpenListener) { ((DelegateOpenListener) openListener).handleEvent(streamConnection, buffer); } else { if (buffer != null) { PushBackStreamSourceConduit conduit = new PushBackStreamSourceConduit(streamConnection.getSourceChannel().getConduit()); conduit.pushBack(new PooledAdaptor(buffer)); streamConnection.getSourceChannel().setConduit(conduit); } openListener.handleEvent(streamConnection); } }
@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 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(); } } }
RemoteConnection(final StreamConnection connection, final SslChannel sslChannel, final OptionMap optionMap, final RemoteConnectionProvider remoteConnectionProvider) { this.connection = connection; this.messageReader = new MessageReader(connection.getSourceChannel(), writeListener.queue); this.sslChannel = sslChannel; this.optionMap = optionMap; heartbeatInterval = optionMap.get(RemotingOptions.HEARTBEAT_INTERVAL, RemotingOptions.DEFAULT_HEARTBEAT_INTERVAL); Messages.conn.tracef("Initialized connection from %s to %s with options %s", connection.getPeerAddress(), connection.getLocalAddress(), optionMap); this.executor = remoteConnectionProvider.getExecutor(); this.remoteConnectionProvider = remoteConnectionProvider; }
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()); } }