Skip to content

Commit

Permalink
TCP_NODELAY=true
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed May 18, 2024
1 parent 0f53aa9 commit cdfe3d3
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
import io.grpc.stub.StreamObserver;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.unix.DomainSocketAddress;
import io.netty.channel.unix.ServerDomainSocketChannel;
Expand Down Expand Up @@ -192,6 +193,7 @@ public void register(SubContext context) {
private ManagedChannel handler(DomainSocketAddress address) {
return NettyChannelBuilder.forAddress(address)
.executor(executor)
.withOption(ChannelOption.TCP_NODELAY, true)
.eventLoopGroup(eventLoopGroup)
.channelType(clientChannelType)
.keepAliveTime(1, TimeUnit.SECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.grpc.netty.DomainSocketNegotiatorHandler.DomainSocketNegotiator;
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.unix.DomainSocketAddress;
import org.slf4j.Logger;
Expand Down Expand Up @@ -85,6 +86,7 @@ public RouterImpl router(ServerConnectionCache.Builder cacheBuilder, Supplier<Li
.executor(executor)
.protocolNegotiator(new DomainSocketNegotiator(IMPL))
.channelType(IMPL.getServerDomainSocketChannelClass())
.withChildOption(ChannelOption.TCP_NODELAY, true)
.workerEventLoopGroup(IMPL.getEventLoopGroup())
.bossEventLoopGroup(IMPL.getEventLoopGroup())
.intercept(new DomainSocketServerInterceptor())
Expand Down Expand Up @@ -129,6 +131,7 @@ public void start(Listener<RespT> responseListener, Metadata headers) {
}
};
final var builder = NettyChannelBuilder.forAddress(bridge)
.withOption(ChannelOption.TCP_NODELAY, true)
.executor(executor)
.eventLoopGroup(eventLoopGroup)
.channelType(channelType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.grpc.ManagedChannel;
import io.grpc.Status;
import io.grpc.netty.NettyChannelBuilder;
import io.netty.channel.ChannelOption;
import io.netty.handler.ssl.ClientAuth;

import java.net.SocketAddress;
Expand All @@ -33,6 +34,7 @@ public MtlsClient(SocketAddress address, ClientAuth clientAuth, String alias, Cl
Limiter<GrpcClientRequestContext> limiter = new GrpcClientLimiterBuilder().blockOnLimit(false).build();
channel = NettyChannelBuilder.forAddress(address)
.executor(executor)
.withOption(ChannelOption.TCP_NODELAY, true)
.sslContext(supplier.forClient(clientAuth, alias, validator, MtlsServer.TL_SV1_3))
.intercept(new ConcurrencyLimitClientInterceptor(limiter,
() -> Status.RESOURCE_EXHAUSTED.withDescription(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.grpc.netty.DomainSocketNegotiatorHandler.DomainSocketNegotiator;
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.unix.DomainSocketAddress;

Expand Down Expand Up @@ -86,6 +87,7 @@ public void start(Listener<RespT> responseListener, Metadata headers) {
};
return NettyChannelBuilder.forAddress(address)
.executor(executor)
.withOption(ChannelOption.TCP_NODELAY, true)
.eventLoopGroup(eventLoopGroup)
.channelType(channelType)
.keepAliveTime(keepAlive.toNanos(), TimeUnit.NANOSECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
import io.grpc.stub.StreamObserver;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.unix.DomainSocketAddress;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -114,6 +115,7 @@ public void smokin() throws Exception {

private ManagedChannel handler(DomainSocketAddress address) {
return NettyChannelBuilder.forAddress(address)
.withOption(ChannelOption.TCP_NODELAY, true)
.executor(executor)
.eventLoopGroup(eventLoopGroup)
.channelType(channelType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
import io.grpc.stub.StreamObserver;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.unix.DomainSocketAddress;
import org.joou.ULong;
Expand Down Expand Up @@ -148,6 +149,7 @@ public void smokin() throws Exception {

private ManagedChannel handler(DomainSocketAddress address) {
return NettyChannelBuilder.forAddress(address)
.withOption(ChannelOption.TCP_NODELAY, true)
.executor(executor)
.eventLoopGroup(eventLoopGroup)
.channelType(channelType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io.grpc.netty.DomainSocketNegotiatorHandler;
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.unix.DomainSocketAddress;
import org.joou.ULong;
Expand Down Expand Up @@ -84,6 +85,7 @@ public ProcessContainerDomain(Digest group, ControlledIdentifierMember member, P
.protocolNegotiator(
new DomainSocketNegotiatorHandler.DomainSocketNegotiator(
IMPL))
.withChildOption(ChannelOption.TCP_NODELAY, true)
.channelType(IMPL.getServerDomainSocketChannelClass())
.workerEventLoopGroup(portalEventLoopGroup)
.bossEventLoopGroup(portalEventLoopGroup)
Expand All @@ -94,6 +96,7 @@ public ProcessContainerDomain(Digest group, ControlledIdentifierMember member, P
outerContextService = NettyServerBuilder.forAddress(outerContextEndpoint)
.protocolNegotiator(
new DomainSocketNegotiatorHandler.DomainSocketNegotiator(IMPL))
.withChildOption(ChannelOption.TCP_NODELAY, true)
.channelType(IMPL.getServerDomainSocketChannelClass())
.addService(new DemesneKERLServer(dht, null))
.addService(outerContextService())
Expand Down Expand Up @@ -207,6 +210,7 @@ protected void stopServices() {

private ManagedChannel handler(DomainSocketAddress address) {
return NettyChannelBuilder.forAddress(address)
.withOption(ChannelOption.TCP_NODELAY, true)
.executor(executor)
.eventLoopGroup(clientEventLoopGroup)
.channelType(channelType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import io.grpc.ManagedChannel;
import io.grpc.netty.NettyChannelBuilder;
import io.netty.channel.Channel;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.unix.DomainSocketAddress;
import org.slf4j.Logger;
Expand Down Expand Up @@ -189,6 +190,7 @@ private CachingKERL kerlFrom(File address) {
ManagedChannel channel = null;
try {
channel = NettyChannelBuilder.forAddress(serverAddress)
.withOption(ChannelOption.TCP_NODELAY, true)
.executor(executor)
.intercept(clientInterceptor(kerlContext))
.eventLoopGroup(eventLoopGroup)
Expand All @@ -210,6 +212,7 @@ private CachingKERL kerlFrom(File address) {

private OuterContextClient outerFrom(File address) {
return new OuterContextClient(NettyChannelBuilder.forAddress(new DomainSocketAddress(address))
.withOption(ChannelOption.TCP_NODELAY, true)
.executor(executor)
.intercept(clientInterceptor(context.getId()))
.eventLoopGroup(eventLoopGroup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.NettyServerBuilder;
import io.grpc.stub.StreamObserver;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.unix.DomainSocketAddress;
import io.netty.channel.unix.ServerDomainSocketChannel;
Expand Down Expand Up @@ -149,7 +150,9 @@ public void portal() throws Exception {
.bossEventLoopGroup(
IMPL.getEventLoopGroup())
.intercept(
new DomainSocketServerInterceptor()),
new DomainSocketServerInterceptor())
.withChildOption(
ChannelOption.TCP_NODELAY, true),
s -> handler(portalEndpoint), bridge, Duration.ofMillis(1), s -> routes.get(s));

final var endpoint1 = new DomainSocketAddress(Path.of("target").resolve(UUID.randomUUID().toString()).toFile());
Expand Down Expand Up @@ -280,6 +283,7 @@ public void register(SubContext context) {

private ManagedChannel handler(DomainSocketAddress address) {
return NettyChannelBuilder.forAddress(address)
.withOption(ChannelOption.TCP_NODELAY, true)
.executor(executor)
.eventLoopGroup(eventLoopGroup)
.channelType(clientChannelType)
Expand Down

0 comments on commit cdfe3d3

Please sign in to comment.