return pipeline;
}
});
staleConnectionTrackingHandler = new StaleConnectionTrackingHandler(staleConnectionTimeout, executor);
ScheduledExecutorService staleCheckExecutor = Executors.newSingleThreadScheduledExecutor(new NamingThreadFactory("WEBBIT-STALE-CONNECTION-CHECK-THREAD"));
staleCheckExecutor.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
staleConnectionTrackingHandler.closeStaleConnections();
}
}, staleConnectionTimeout / 2, staleConnectionTimeout / 2, TimeUnit.MILLISECONDS);
executorServices.add(staleCheckExecutor);
connectionTrackingHandler = new ConnectionTrackingHandler();
ExecutorService bossExecutor = Executors.newSingleThreadExecutor(new NamingThreadFactory("WEBBIT-BOSS-THREAD"));
executorServices.add(bossExecutor);
ExecutorService workerExecutor = Executors.newSingleThreadExecutor(new NamingThreadFactory("WEBBIT-WORKER-THREAD"));
executorServices.add(workerExecutor);
bootstrap.setFactory(new NioServerSocketChannelFactory(bossExecutor, workerExecutor, 1));
channel = bootstrap.bind(socketAddress);
return NettyWebServer.this;
}