Michael Blow has submitted this change and it was merged. Change subject: [NO ISSUE] HttpServer shutdown improvements ......................................................................
[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]> --- M hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java M hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/WebManager.java 2 files changed, 22 insertions(+), 5 deletions(-) Approvals: abdullah alamoudi: Looks good to me, approved Jenkins: Verified; ; Verified Objections: Jenkins: Violations found 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 @@ } protected void doStop() throws InterruptedException { - channel.close(); - channel.closeFuture().sync(); executor.shutdown(); try { executor.awaitTermination(1, TimeUnit.MINUTES); @@ -217,6 +215,8 @@ } 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) { 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 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) { -- To view, visit https://asterix-gerrit.ics.uci.edu/1984 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2251ae42927622d8fff68f7567b4aef265673da4 Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Michael Blow <[email protected]> Gerrit-Reviewer: Murtadha Hubail <[email protected]> Gerrit-Reviewer: abdullah alamoudi <[email protected]>
