Distinguish between available and epollable
This commit is contained in:
@@ -102,10 +102,10 @@ public class DefaultGrpcServerFactory<T extends ServerBuilder<T>> implements Grp
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private T unixDomainServerBuilder(String path) {
|
||||
if (NettyServerFactoryHelper.isAvailable()) {
|
||||
if (NettyServerFactoryHelper.isEpollAvailable()) {
|
||||
return (T) NettyServerFactoryHelper.forUnixDomainSocket(path);
|
||||
}
|
||||
else if (ShadedNettyServerFactoryHelper.isAvailable()) {
|
||||
else if (ShadedNettyServerFactoryHelper.isEpollAvailable()) {
|
||||
return (T) ShadedNettyServerFactoryHelper.forUnixDomainSocket(path);
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
|
||||
@@ -30,13 +30,18 @@ import io.netty.channel.unix.DomainSocketAddress;
|
||||
|
||||
class NettyServerFactoryHelper {
|
||||
|
||||
private static final boolean AVAILABLE = ClassUtils.isPresent("io.netty.channel.epoll.Epoll", null)
|
||||
&& Epoll.isAvailable();
|
||||
private static final boolean AVAILABLE = ClassUtils.isPresent("io.netty.channel.epoll.Epoll", null);
|
||||
|
||||
private static final boolean EPOLL_AVAILABLE = AVAILABLE && Epoll.isAvailable();
|
||||
|
||||
public static boolean isAvailable() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
public static boolean isEpollAvailable() {
|
||||
return EPOLL_AVAILABLE;
|
||||
}
|
||||
|
||||
public static ServerBuilder<?> forUnixDomainSocket(String path) {
|
||||
return NettyServerBuilder.forAddress(new DomainSocketAddress(path))
|
||||
.channelType(EpollServerDomainSocketChannel.class)
|
||||
|
||||
@@ -31,12 +31,18 @@ import io.grpc.netty.shaded.io.netty.channel.unix.DomainSocketAddress;
|
||||
class ShadedNettyServerFactoryHelper {
|
||||
|
||||
private static final boolean AVAILABLE = ClassUtils.isPresent("io.grpc.netty.shaded.io.netty.channel.epoll.Epoll",
|
||||
null) && Epoll.isAvailable();
|
||||
null);
|
||||
|
||||
private static final boolean EPOLL_AVAILABLE = AVAILABLE && Epoll.isAvailable();
|
||||
|
||||
public static boolean isAvailable() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
public static boolean isEpollAvailable() {
|
||||
return EPOLL_AVAILABLE;
|
||||
}
|
||||
|
||||
public static ServerBuilder<?> forUnixDomainSocket(String path) {
|
||||
return NettyServerBuilder.forAddress(new DomainSocketAddress(path))
|
||||
.channelType(EpollServerDomainSocketChannel.class)
|
||||
|
||||
Reference in New Issue
Block a user