Search in sources :

Example 16 with DomainSocketAddress

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

the class GrpcDataServer method createServerBuilder.

private GrpcServerBuilder createServerBuilder(String hostName, SocketAddress bindAddress, ChannelType type) {
    // Create an executor for Worker RPC server.
    mRPCExecutor = ExecutorServiceBuilder.buildExecutorService(ExecutorServiceBuilder.RpcExecutorHost.WORKER);
    MetricsSystem.registerGaugeIfAbsent(MetricKey.WORKER_RPC_QUEUE_LENGTH.getName(), mRPCExecutor::getRpcQueueLength);
    // Create underlying gRPC server.
    GrpcServerBuilder builder = GrpcServerBuilder.forAddress(GrpcServerAddress.create(hostName, bindAddress), ServerConfiguration.global(), ServerUserState.global()).executor(mRPCExecutor);
    int bossThreadCount = ServerConfiguration.getInt(PropertyKey.WORKER_NETWORK_NETTY_BOSS_THREADS);
    // If number of worker threads is 0, Netty creates (#processors * 2) threads by default.
    int workerThreadCount = ServerConfiguration.getInt(PropertyKey.WORKER_NETWORK_NETTY_WORKER_THREADS);
    String dataServerEventLoopNamePrefix = "data-server-" + ((mSocketAddress instanceof DomainSocketAddress) ? "domain-socket" : "tcp-socket");
    mBossGroup = NettyUtils.createEventLoop(type, bossThreadCount, dataServerEventLoopNamePrefix + "-boss-%d", true);
    mWorkerGroup = NettyUtils.createEventLoop(type, workerThreadCount, dataServerEventLoopNamePrefix + "-worker-%d", true);
    Class<? extends ServerChannel> socketChannelClass = NettyUtils.getServerChannelClass(mSocketAddress instanceof DomainSocketAddress, ServerConfiguration.global());
    if (type == ChannelType.EPOLL) {
        builder.withChildOption(EpollChannelOption.EPOLL_MODE, EpollMode.LEVEL_TRIGGERED);
    }
    return builder.bossEventLoopGroup(mBossGroup).workerEventLoopGroup(mWorkerGroup).channelType(socketChannelClass).withChildOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT).withChildOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, (int) ServerConfiguration.getBytes(PropertyKey.WORKER_NETWORK_NETTY_WATERMARK_HIGH)).withChildOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, (int) ServerConfiguration.getBytes(PropertyKey.WORKER_NETWORK_NETTY_WATERMARK_LOW));
}
Also used : GrpcServerBuilder(alluxio.grpc.GrpcServerBuilder) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress)

Example 17 with DomainSocketAddress

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

the class AddressUtils method updateHost.

/**
 * Update the provided address with the new host string.
 *
 * @param address the address supplier
 * @param host the new host string
 * @return the updated address
 */
public static SocketAddress updateHost(@Nullable Supplier<? extends SocketAddress> address, String host) {
    if (address == null) {
        return createUnresolved(host, 0);
    }
    SocketAddress socketAddress = address.get();
    if (socketAddress instanceof DomainSocketAddress) {
        throw new IllegalArgumentException("Cannot update DomainSocketAddress with host name [" + host + "].");
    }
    if (!(socketAddress instanceof InetSocketAddress)) {
        return createUnresolved(host, 0);
    }
    InetSocketAddress inet = (InetSocketAddress) socketAddress;
    return createUnresolved(host, inet.getPort());
}
Also used : InetSocketAddress(java.net.InetSocketAddress) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) SocketAddress(java.net.SocketAddress) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) InetSocketAddress(java.net.InetSocketAddress)

Example 18 with DomainSocketAddress

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

the class AddressUtils method updatePort.

/**
 * Update the provided address with the new port.
 *
 * @param address the address supplier
 * @param port the new port
 * @return the updated address
 */
public static SocketAddress updatePort(@Nullable Supplier<? extends SocketAddress> address, int port) {
    if (address == null) {
        return createUnresolved(NetUtil.LOCALHOST.getHostAddress(), port);
    }
    SocketAddress socketAddress = address.get();
    if (socketAddress instanceof DomainSocketAddress) {
        throw new IllegalArgumentException("Cannot update DomainSocketAddress with post number [" + port + "].");
    }
    if (!(address.get() instanceof InetSocketAddress)) {
        return createUnresolved(NetUtil.LOCALHOST.getHostAddress(), port);
    }
    InetSocketAddress inet = (InetSocketAddress) address.get();
    InetAddress addr = inet.getAddress();
    String host = addr == null ? inet.getHostName() : addr.getHostAddress();
    return createUnresolved(host, port);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) SocketAddress(java.net.SocketAddress) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress)

Example 19 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) {
    Connection connection = TcpClient.create().remoteAddress(// <1>
    () -> new DomainSocketAddress("/tmp/test.sock")).connectNow();
    connection.onDispose().block();
}
Also used : Connection(reactor.netty.Connection) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress)

Example 20 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) {
    Connection connection = UdpClient.create().bindAddress(Application::newDomainSocketAddress).remoteAddress(// <1>
    () -> new DomainSocketAddress("/tmp/test-server.sock")).handle((in, out) -> out.sendString(Mono.just("hello")).then(in.receive().asString().doOnNext(System.out::println).then())).connectNow();
    connection.onDispose().block();
}
Also used : DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress) UdpClient(reactor.netty.udp.UdpClient) Mono(reactor.core.publisher.Mono) Connection(reactor.netty.Connection) File(java.io.File) Connection(reactor.netty.Connection) DomainSocketAddress(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