Search in sources :

Example 21 with DomainSocketAddress

use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project reactor-netty by reactor.

the class Application method main.

public static void main(String[] args) {
    DisposableServer server = TcpServer.create().bindAddress(// <1>
    () -> new DomainSocketAddress("/tmp/test.sock")).bindNow();
    server.onDispose().block();
}
Also used : DisposableServer(reactor.netty.DisposableServer) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress)

Example 22 with DomainSocketAddress

use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project reactor-netty by reactor.

the class UdpClientTest method newDomainSocketAddress.

private static DomainSocketAddress newDomainSocketAddress() {
    try {
        File tempFile = Files.createTempFile("UdpClientTest", "UDS").toFile();
        assertThat(tempFile.delete()).isTrue();
        tempFile.deleteOnExit();
        return new DomainSocketAddress(tempFile);
    } catch (Exception e) {
        throw new RuntimeException("Error creating a  temporary file", e);
    }
}
Also used : DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException)

Example 23 with DomainSocketAddress

use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project reactor-netty by reactor.

the class HttpServerTests method doTestHttpServerWithDomainSockets.

private void doTestHttpServerWithDomainSockets(HttpServer server, HttpClient client, String expectedScheme) {
    assumeThat(LoopResources.hasNativeSupport()).isTrue();
    disposableServer = server.bindAddress(() -> new DomainSocketAddress("/tmp/test.sock")).wiretap(true).handle((req, res) -> {
        req.withConnection(conn -> {
            assertThat(conn.channel().localAddress()).isNull();
            assertThat(conn.channel().remoteAddress()).isNull();
            assertThat(req.hostAddress()).isNull();
            assertThat(req.remoteAddress()).isNull();
            assertThat(req.scheme()).isNotNull().isEqualTo(expectedScheme);
        });
        assertThat(req.requestHeaders().get(HttpHeaderNames.HOST)).isEqualTo("localhost");
        return res.send(req.receive().retain());
    }).bindNow();
    String response = client.remoteAddress(disposableServer::address).wiretap(true).post().uri("/").send(ByteBufFlux.fromString(Flux.just("1", "2", "3"))).responseContent().aggregate().asString().block(Duration.ofSeconds(30));
    assertThat(response).isEqualTo("123");
}
Also used : DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress)

Example 24 with DomainSocketAddress

use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project netty by netty.

the class EpollSocketTestPermutation method newSocketAddress.

public static DomainSocketAddress newSocketAddress() {
    try {
        File file = File.createTempFile("netty", "dsocket");
        file.delete();
        return new DomainSocketAddress(file);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
Also used : DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) IOException(java.io.IOException) File(java.io.File)

Example 25 with DomainSocketAddress

use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project beam by apache.

the class ManagedChannelFactory method forDescriptor.

public ManagedChannel forDescriptor(ApiServiceDescriptor apiServiceDescriptor) {
    ManagedChannelBuilder<?> channelBuilder;
    switch(type) {
        case EPOLL:
            SocketAddress address = SocketAddressFactory.createFrom(apiServiceDescriptor.getUrl());
            channelBuilder = NettyChannelBuilder.forAddress(address).channelType(address instanceof DomainSocketAddress ? EpollDomainSocketChannel.class : EpollSocketChannel.class).eventLoopGroup(new EpollEventLoopGroup());
            break;
        case DEFAULT:
            channelBuilder = ManagedChannelBuilder.forTarget(apiServiceDescriptor.getUrl());
            break;
        case IN_PROCESS:
            channelBuilder = InProcessChannelBuilder.forName(apiServiceDescriptor.getUrl());
            break;
        default:
            throw new IllegalStateException("Unknown type " + type);
    }
    channelBuilder = channelBuilder.usePlaintext().maxInboundMessageSize(Integer.MAX_VALUE).intercept(interceptors);
    if (directExecutor) {
        channelBuilder = channelBuilder.directExecutor();
    }
    return channelBuilder.build();
}
Also used : EpollEventLoopGroup(org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.epoll.EpollEventLoopGroup) EpollDomainSocketChannel(org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.epoll.EpollDomainSocketChannel) DomainSocketAddress(org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress) EpollSocketChannel(org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.epoll.EpollSocketChannel) SocketAddress(java.net.SocketAddress) DomainSocketAddress(org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress)

Aggregations

DomainSocketAddress (io.netty.channel.unix.DomainSocketAddress)42 File (java.io.File)15 InetSocketAddress (java.net.InetSocketAddress)15 SocketAddress (java.net.SocketAddress)14 IOException (java.io.IOException)9 Test (org.junit.jupiter.api.Test)8 Connection (reactor.netty.Connection)7 ByteBuf (io.netty.buffer.ByteBuf)6 Test (org.junit.Test)6 Mono (reactor.core.publisher.Mono)5 DisposableServer (reactor.netty.DisposableServer)5 ByteString (com.google.protobuf.ByteString)4 AddressedEnvelope (io.netty.channel.AddressedEnvelope)4 DefaultAddressedEnvelope (io.netty.channel.DefaultAddressedEnvelope)4 Duration (java.time.Duration)4 List (java.util.List)4 TimeUnit (java.util.concurrent.TimeUnit)4 LoopResources (reactor.netty.resources.LoopResources)4 Channel (io.netty.channel.Channel)3 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)3