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));
}
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());
}
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);
}
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();
}
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();
}
Aggregations