Search in sources :

Example 31 with DomainSocketAddress

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

the class EpollServerDomainSocketChannel method doClose.

@Override
protected void doClose() throws Exception {
    try {
        super.doClose();
    } finally {
        DomainSocketAddress local = this.local;
        if (local != null) {
            // Delete the socket file if possible.
            File socketFile = new File(local.path());
            boolean success = socketFile.delete();
            if (!success && logger.isDebugEnabled()) {
                logger.debug("Failed to delete a domain socket file: {}", local.path());
            }
        }
    }
}
Also used : DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) File(java.io.File)

Example 32 with DomainSocketAddress

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

the class KQueueServerDomainSocketChannel method doClose.

@Override
protected void doClose() throws Exception {
    try {
        super.doClose();
    } finally {
        DomainSocketAddress local = this.local;
        if (local != null) {
            // Delete the socket file if possible.
            File socketFile = new File(local.path());
            boolean success = socketFile.delete();
            if (!success && logger.isDebugEnabled()) {
                logger.debug("Failed to delete a domain socket file: {}", local.path());
            }
        }
    }
}
Also used : DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) File(java.io.File)

Example 33 with DomainSocketAddress

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

the class SocketAddressPropertyTest method bindTypeWorks_uds.

@Test
public void bindTypeWorks_uds() {
    SocketAddress address = SocketAddressProperty.Decoder.INSTANCE.apply("UDS=/var/run/zuul.sock");
    assertEquals(DomainSocketAddress.class, address.getClass());
    DomainSocketAddress domainSocketAddress = (DomainSocketAddress) address;
    assertEquals("/var/run/zuul.sock", domainSocketAddress.path());
}
Also used : DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) Test(org.junit.Test)

Example 34 with DomainSocketAddress

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

the class NewConnectionProvider method acquire.

@Override
public Mono<? extends Connection> acquire(TransportConfig config, ConnectionObserver observer, @Nullable Supplier<? extends SocketAddress> remoteAddress, @Nullable AddressResolverGroup<?> resolverGroup) {
    return Mono.create(sink -> {
        SocketAddress remote = null;
        if (remoteAddress != null) {
            remote = Objects.requireNonNull(remoteAddress.get(), "Remote Address supplier returned null");
        }
        ConnectionObserver connectionObserver = new NewConnectionObserver(sink, observer);
        DisposableConnect disposableConnect = new DisposableConnect(sink, config.bindAddress());
        if (remote != null && resolverGroup != null) {
            ChannelInitializer<Channel> channelInitializer = config.channelInitializer(connectionObserver, remote, false);
            TransportConnector.connect(config, remote, resolverGroup, channelInitializer).subscribe(disposableConnect);
        } else {
            Objects.requireNonNull(config.bindAddress(), "bindAddress");
            SocketAddress local = Objects.requireNonNull(config.bindAddress().get(), "Bind Address supplier returned null");
            if (local instanceof InetSocketAddress) {
                InetSocketAddress localInet = (InetSocketAddress) local;
                if (localInet.isUnresolved()) {
                    local = AddressUtils.createResolved(localInet.getHostName(), localInet.getPort());
                }
            }
            ChannelInitializer<Channel> channelInitializer = config.channelInitializer(connectionObserver, null, true);
            TransportConnector.bind(config, channelInitializer, local, local instanceof DomainSocketAddress).subscribe(disposableConnect);
        }
    });
}
Also used : ConnectionObserver(reactor.netty.ConnectionObserver) InetSocketAddress(java.net.InetSocketAddress) Channel(io.netty.channel.Channel) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) SocketAddress(java.net.SocketAddress) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) InetSocketAddress(java.net.InetSocketAddress)

Example 35 with DomainSocketAddress

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

the class UriEndpoint method toExternalForm.

String toExternalForm() {
    StringBuilder sb = new StringBuilder();
    SocketAddress address = remoteAddress.get();
    if (address instanceof DomainSocketAddress) {
        sb.append(((DomainSocketAddress) address).path());
    } else {
        sb.append(scheme);
        sb.append("://");
        sb.append(address != null ? toSocketAddressStringWithoutDefaultPort(address, isSecure()) : "localhost");
        sb.append(pathAndQuery);
    }
    return sb.toString();
}
Also used : DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) SocketAddress(java.net.SocketAddress) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) InetSocketAddress(java.net.InetSocketAddress)

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