@Test public void testShutdown() throws Exception { WebServer webServer = WebServer.create( routing((bareRequest, bareResponse) -> { })); long startNanos = System.nanoTime(); webServer.start().toCompletableFuture().get(10, TimeUnit.SECONDS); long shutdownStartNanos = System.nanoTime(); webServer.shutdown().toCompletableFuture().get(10, TimeUnit.SECONDS); long endNanos = System.nanoTime(); System.out.println("Start took: " + TimeUnit.MILLISECONDS.convert(shutdownStartNanos - startNanos, TimeUnit.NANOSECONDS) + " ms."); System.out.println("Shutdown took: " + TimeUnit.MILLISECONDS.convert(endNanos - shutdownStartNanos, TimeUnit.NANOSECONDS) + " ms."); }
private void shutdown(Throwable cause) { shutdownThreadGroups() .whenComplete((webServer, throwable) -> { if (cause == null && throwable == null) { shutdownFuture.complete(this); } else if (cause != null) { if (throwable != null) { LOGGER.log(Level.WARNING, "Netty Thread Groups were unable to shutdown.", throwable); } shutdownFuture.completeExceptionally( new IllegalStateException("WebServer was unable to stop.", cause)); } else { shutdownFuture.completeExceptionally( new IllegalStateException("WebServer was unable to stop.", throwable)); } }); }
NettyWebServer implements WebServer { private void shutdown(Throwable cause) { shutdownThreadGroups() .whenComplete((webServer, throwable) -> { if (cause == null && throwable == null) { shutdownFuture.complete(this); } else if (cause != null) { if (throwable != null) { LOGGER.log(Level.WARNING, "Netty Thread Groups were unable to shutdown.", throwable); } shutdownFuture.completeExceptionally( new IllegalStateException("WebServer was unable to stop.", cause)); } else { shutdownFuture.completeExceptionally( new IllegalStateException("WebServer was unable to stop.", throwable)); } }); } }
NettyWebServer implements WebServer { private void shutdown(Throwable cause) { shutdownThreadGroups() .whenComplete((webServer, throwable) -> { if (cause == null && throwable == null) { shutdownFuture.complete(this); } else if (cause != null) { if (throwable != null) { LOGGER.log(Level.WARNING, "Netty Thread Groups were unable to shutdown.", throwable); } shutdownFuture.completeExceptionally( new IllegalStateException("WebServer was unable to stop.", cause)); } else { shutdownFuture.completeExceptionally( new IllegalStateException("WebServer was unable to stop.", throwable)); } }); } NettyWebServer(ServerConfiguration config,
                   Routing routing,
                   Map<String, Routing> namedRoutings,
                   MessageBodyWriterContext writerContext,
                   MessageBodyReaderContext readerContext); }
NettyWebServer implements WebServer { private void shutdown(Throwable cause) { shutdownThreadGroups() .whenComplete((webServer, throwable) -> { if (cause == null && throwable == null) { shutdownFuture.complete(this); } else if (cause != null) { if (throwable != null) { LOGGER.log(Level.WARNING, "Netty Thread Groups were unable to shutdown.", throwable); } shutdownFuture.completeExceptionally( new IllegalStateException("WebServer was unable to stop.", cause)); } else { shutdownFuture.completeExceptionally( new IllegalStateException("WebServer was unable to stop.", throwable)); } }); } NettyWebServer(ServerConfiguration config,
                   Routing routing,
                   Map<String, Routing> namedRoutings,
                   MessageBodyWriterContext writerContext,
                   MessageBodyReaderContext readerContext); @Override ServerConfiguration configuration(); @Override MessageBodyReaderContext readerContext(); @Override MessageBodyWriterContext writerContext(); @Override synchronized Single<WebServer> start(); @Override Single<WebServer> shutdown(); @Override Single<WebServer> whenShutdown(); @Override boolean isRunning(); @Override Context context(); @Override int port(String name); }
NettyWebServer implements WebServer { private void shutdown(Throwable cause) { shutdownThreadGroups() .whenComplete((webServer, throwable) -> { if (cause == null && throwable == null) { shutdownFuture.complete(this); } else if (cause != null) { if (throwable != null) { LOGGER.log(Level.WARNING, "Netty Thread Groups were unable to shutdown.", throwable); } shutdownFuture.completeExceptionally( new IllegalStateException("WebServer was unable to stop.", cause)); } else { shutdownFuture.completeExceptionally( new IllegalStateException("WebServer was unable to stop.", throwable)); } }); } NettyWebServer(ServerConfiguration config,
                   Routing routing,
                   Map<String, Routing> namedRoutings,
                   MessageBodyWriterContext writerContext,
                   MessageBodyReaderContext readerContext); @Override ServerConfiguration configuration(); @Override MessageBodyReaderContext readerContext(); @Override MessageBodyWriterContext writerContext(); @Override synchronized Single<WebServer> start(); @Override Single<WebServer> shutdown(); @Override Single<WebServer> whenShutdown(); @Override boolean isRunning(); @Override Context context(); @Override int port(String name);  }