Repository: asterixdb Updated Branches: refs/heads/master 0797e4c90 -> 67920c4d9
[NO ISSUE] HttpServer shutdown improvements - Don't close the connection until the outstanding requests have been serviced - Shutdown the servers in parallel Change-Id: I2251ae42927622d8fff68f7567b4aef265673da4 Reviewed-on: https://asterix-gerrit.ics.uci.edu/1984 Tested-by: Jenkins <[email protected]> Contrib: Jenkins <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: abdullah alamoudi <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/67920c4d Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/67920c4d Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/67920c4d Branch: refs/heads/master Commit: 67920c4d9b29340a29ec9f3a8ad9923d7393dba2 Parents: 0797e4c Author: Michael Blow <[email protected]> Authored: Wed Aug 30 22:31:06 2017 -0400 Committer: Michael Blow <[email protected]> Committed: Wed Aug 30 22:57:16 2017 -0700 ---------------------------------------------------------------------- .../apache/hyracks/http/server/HttpServer.java | 4 ++-- .../apache/hyracks/http/server/WebManager.java | 23 +++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/67920c4d/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java index 45634ad..56f454f 100644 --- a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java +++ b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java @@ -206,8 +206,6 @@ public class HttpServer { } protected void doStop() throws InterruptedException { - channel.close(); - channel.closeFuture().sync(); executor.shutdown(); try { executor.awaitTermination(1, TimeUnit.MINUTES); @@ -217,6 +215,8 @@ public class HttpServer { } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error while shutting down http server executor", e); } + channel.close(); + channel.closeFuture().sync(); } public IServlet getServlet(FullHttpRequest request) { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/67920c4d/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/WebManager.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/WebManager.java b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/WebManager.java index 235e1ea..4a09f78 100644 --- a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/WebManager.java +++ b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/WebManager.java @@ -19,6 +19,7 @@ package org.apache.hyracks.http.server; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import io.netty.channel.EventLoopGroup; @@ -54,11 +55,27 @@ public class WebManager { } public void stop() throws Exception { - for (HttpServer server : servers) { - server.stop(); - } + List<Exception> stopExceptions = Collections.synchronizedList(new ArrayList<>()); + servers.parallelStream().forEach(server -> { + try { + server.stop(); + } catch (Exception e) { + stopExceptions.add(e); + } + }); workers.shutdownGracefully().sync(); bosses.shutdownGracefully().sync(); + if (!stopExceptions.isEmpty()) { + Exception ex = null; + for (Exception stopException : stopExceptions) { + if (ex == null) { + ex = stopException; + } else { + ex.addSuppressed(stopException); + } + } + throw ex; + } } public void add(HttpServer server) {
