io.netty.channel.socket.DuplexChannel Java Examples

The following examples show how to use io.netty.channel.socket.DuplexChannel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RequestResponseCloseHandler.java    From servicetalk with Apache License 2.0 5 votes vote down vote up
@Override
void closeChannelInbound(final Channel channel) {
    if (!has(state, IN_CLOSED)) {
        LOGGER.debug("{} Half-Closing INBOUND (reset)", channel);
        setSocketResetOnClose(channel);
        ((DuplexChannel) channel).shutdownInput().addListener((ChannelFutureListener) this::onHalfClosed);
    }
}
 
Example #2
Source File: RequestResponseCloseHandler.java    From servicetalk with Apache License 2.0 5 votes vote down vote up
@Override
void closeChannelOutbound(final Channel channel) {
    if (!has(state, OUT_CLOSED)) {
        LOGGER.debug("{} Half-Closing OUTBOUND (reset)", channel);
        setSocketResetOnClose(channel);
        ((DuplexChannel) channel).shutdownOutput().addListener((ChannelFutureListener) this::onHalfClosed);
    }
}
 
Example #3
Source File: RequestResponseCloseHandler.java    From servicetalk with Apache License 2.0 5 votes vote down vote up
private void clientHalfCloseOutbound(final Channel channel) {
    assert isClient;
    if (!has(state, OUT_CLOSED) && channel instanceof DuplexChannel) {
        LOGGER.debug("{} Half-Closing OUTBOUND", channel);
        state = unset(state, WRITE);
        ((DuplexChannel) channel).shutdownOutput().addListener((ChannelFutureListener) this::onHalfClosed);
    }
}
 
Example #4
Source File: RequestResponseCloseHandler.java    From servicetalk with Apache License 2.0 5 votes vote down vote up
private void onHalfClosed(ChannelFuture future) {
    DuplexChannel dplxChannel = (DuplexChannel) future.channel();
    if (dplxChannel.isInputShutdown() && dplxChannel.isOutputShutdown()) {
        LOGGER.debug("{} Fully closing socket channel, both input and output shutdown", dplxChannel);
        closeChannel(dplxChannel, null);
    }
}
 
Example #5
Source File: NettyDockerCmdExecFactory.java    From docker-java with Apache License 2.0 5 votes vote down vote up
private DuplexChannel connect() {
    try {
        return connect(bootstrap);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}
 
Example #6
Source File: NettyDockerCmdExecFactory.java    From docker-java with Apache License 2.0 5 votes vote down vote up
@Override
public DuplexChannel connect(Bootstrap bootstrap) throws InterruptedException {
    DockerClientConfig dockerClientConfig = getDockerClientConfig();
    String path = dockerClientConfig.getDockerHost().getPath();

    return (DuplexChannel) bootstrap.connect(new DomainSocketAddress(path)).sync().channel();
}
 
Example #7
Source File: NettyDockerCmdExecFactory.java    From docker-java with Apache License 2.0 5 votes vote down vote up
@Override
public DuplexChannel connect(Bootstrap bootstrap) throws InterruptedException {
    DockerClientConfig dockerClientConfig = getDockerClientConfig();
    String host = dockerClientConfig.getDockerHost().getHost();
    int port = dockerClientConfig.getDockerHost().getPort();

    if (port == -1) {
        throw new RuntimeException("no port configured for " + host);
    }

    final DuplexChannel channel = (DuplexChannel) bootstrap.connect(host, port).sync().channel();

    final SslHandler ssl = initSsl(dockerClientConfig);

    if (ssl != null) {
        channel.pipeline().addFirst(ssl);

        // https://tools.ietf.org/html/rfc5246#section-7.2.1
        // TLS has its own special message about connection termination. Because TLS is a
        // session-level protocol, it can be covered by any transport-level protocol like
        // TCP, UTP and so on. But we know exactly that data being transferred over TCP and
        // that other side will never send any byte into this TCP connection, so this
        // channel should be closed.
        // RFC says that we must notify opposite side about closing. This could be done only
        // in sun.security.ssl.SSLEngineImpl and unfortunately it does not send this
        // message. On the other hand RFC does not enforce the opposite side to wait for
        // such message.
        ssl.sslCloseFuture().addListener(future -> channel.eventLoop().execute(channel::close));
    }

    return channel;
}
 
Example #8
Source File: WebConnectionImpl.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@Override
public void close() throws IOException {
    ((DuplexChannel) context.channel()).shutdownOutput();
}
 
Example #9
Source File: WebConnectionImpl.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@Override
public void close() throws IOException {
    ((DuplexChannel) context.channel()).shutdownOutput();
}
 
Example #10
Source File: NettyInvocationBuilder.java    From docker-java with Apache License 2.0 4 votes vote down vote up
private DuplexChannel getChannel() {
    return channelProvider.getChannel();
}
 
Example #11
Source File: NettyDockerCmdExecFactory.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public DuplexChannel getChannel() {
    DuplexChannel channel = connect();
    channel.pipeline().addLast(new LoggingHandler(getClass()));
    return channel;
}
 
Example #12
Source File: NettyDockerCmdExecFactory.java    From docker-java with Apache License 2.0 4 votes vote down vote up
private DuplexChannel connect(final Bootstrap bootstrap) throws InterruptedException {
    return nettyInitializer.connect(bootstrap);
}
 
Example #13
Source File: ChannelProvider.java    From docker-java with Apache License 2.0 votes vote down vote up
DuplexChannel getChannel(); 
Example #14
Source File: NettyDockerCmdExecFactory.java    From docker-java with Apache License 2.0 votes vote down vote up
DuplexChannel connect(final Bootstrap bootstrap) throws InterruptedException;