package io.scalecube.services.transport.rsocket;

import io.scalecube.services.codec.HeadersCodec;
import io.scalecube.services.codec.ServiceMessageCodec;
import io.scalecube.services.transport.ServiceTransport;
import io.scalecube.services.transport.client.api.ClientTransport;
import io.scalecube.services.transport.rsocket.client.RSocketClientTransport;
import io.scalecube.services.transport.rsocket.server.RSocketServerTransport;
import io.scalecube.services.transport.server.api.ServerTransport;

import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.NettyRuntime;
import io.netty.util.concurrent.DefaultThreadFactory;
import io.netty.util.internal.PlatformDependent;

import java.util.concurrent.ThreadFactory;

public class RSocketServiceTransport implements ServiceTransport {

  private static final String DEFAULT_HEADERS_FORMAT = "application/json";
  private static final String THREAD_FACTORY_POOL_NAME = "scalecube-rsocket";

  private EventLoopGroup eventLoopGroup;

  public RSocketServiceTransport() {
    int nThreads = NettyRuntime.availableProcessors();
    ThreadFactory threadFactory = new DefaultThreadFactory(THREAD_FACTORY_POOL_NAME, true);

    eventLoopGroup = PlatformDependent.isWindows() ? new NioEventLoopGroup(nThreads, threadFactory)
        : new EpollEventLoopGroup(nThreads, threadFactory);
  }

  @Override
  public ClientTransport getClientTransport() {
    HeadersCodec headersCodec = HeadersCodec.getInstance(DEFAULT_HEADERS_FORMAT);
    return new RSocketClientTransport(new ServiceMessageCodec(headersCodec), eventLoopGroup);
  }

  @Override
  public ServerTransport getServerTransport() {
    HeadersCodec headersCodec = HeadersCodec.getInstance(DEFAULT_HEADERS_FORMAT);
    return new RSocketServerTransport(new ServiceMessageCodec(headersCodec), eventLoopGroup);
  }

  @Override
  public EventLoopGroup getExecutorService() {
    return eventLoopGroup;
  }

}

@@ -528,32 +528,69 @@
 EventLoopGroup;%0A
+import io.netty.channel.epoll.Epoll;%0A
 import io.netty.
@@ -616,32 +616,32 @@
 EventLoopGroup;%0A
-
 import io.netty.
@@ -806,24 +806,82 @@
 Dependent;%0A%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A
 import java.
@@ -980,16 +980,112 @@
 port %7B%0A%0A
+  private static final Logger LOGGER = LoggerFactory.getLogger(RSocketServiceTransport.class);%0A%0A
   privat
@@ -1230,16 +1230,512 @@
 cket%22;%0A%0A
+  private static boolean isEpollSupported = false;%0A%0A  static %7B%0A    if (PlatformDependent.isWindows()) %7B%0A      LOGGER.warn(%22Epoll is not supported by this environment, NIO will be used%22);%0A    %7D else %7B%0A      try %7B%0A        Class.forName(%22io.netty.channel.epoll.Epoll%22);%0A        isEpollSupported = Epoll.isAvailable();%0A      %7D catch (ClassNotFoundException e) %7B%0A        LOGGER.warn(%22Cannot load Epoll, NIO will be used%22, e);%0A      %7D%0A    %7D%0A    LOGGER.debug(%22Epoll support: %22 + isEpollSupported);%0A  %7D%0A%0A
   privat
@@ -1978,47 +1978,36 @@
 p = 
-PlatformDependent.isWindows()
+isEpollSupported
  ? new 
-Nio
+Epoll
 Even
@@ -2052,29 +2052,27 @@
       : new 
-Epoll
+Nio
 EventLoopGro

Add check for Epoll support