Fix client connection

This commit is contained in:
Andrea Cavalli 2024-10-02 18:57:59 +02:00
parent a6320722a1
commit 310f94d473

View File

@ -12,10 +12,12 @@ import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder; import io.grpc.ManagedChannelBuilder;
import io.grpc.netty.NettyChannelBuilder; import io.grpc.netty.NettyChannelBuilder;
import io.grpc.stub.*; import io.grpc.stub.*;
import io.netty.channel.epoll.EpollDomainSocketChannel;
import io.netty.channel.epoll.EpollEventLoopGroup; import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.epoll.EpollServerDomainSocketChannel; import io.netty.channel.epoll.EpollServerDomainSocketChannel;
import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.channel.unix.DomainSocketAddress; import io.netty.channel.unix.DomainSocketAddress;
import it.cavallium.rockserver.core.common.*; import it.cavallium.rockserver.core.common.*;
import it.cavallium.rockserver.core.common.ColumnSchema; import it.cavallium.rockserver.core.common.ColumnSchema;
@ -77,14 +79,14 @@ public class GrpcConnection extends BaseConnection implements RocksDBAPI {
.forAddress(socketAddress) .forAddress(socketAddress)
.directExecutor() .directExecutor()
.usePlaintext(); .usePlaintext();
if (socketAddress instanceof UnixDomainSocketAddress _) { if (socketAddress instanceof DomainSocketAddress _) {
channelBuilder channelBuilder
.eventLoopGroup(new EpollEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2)) .eventLoopGroup(new EpollEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2))
.channelType(EpollServerDomainSocketChannel.class); .channelType(EpollDomainSocketChannel.class);
} else { } else {
channelBuilder channelBuilder
.eventLoopGroup(new NioEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2)) .eventLoopGroup(new NioEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2))
.channelType(NioServerSocketChannel.class); .channelType(NioSocketChannel.class);
} }
this.channel = channelBuilder.build(); this.channel = channelBuilder.build();
this.blockingStub = RocksDBServiceGrpc.newBlockingStub(channel); this.blockingStub = RocksDBServiceGrpc.newBlockingStub(channel);