asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Blow (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: [NO ISSUE] HttpServer shutdown improvements
Date Thu, 31 Aug 2017 02:31:46 GMT
Michael Blow has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1984

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
---
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(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/84/1984/1

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: newchange
Gerrit-Change-Id: I2251ae42927622d8fff68f7567b4aef265673da4
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mblow@apache.org>

Mime
View raw message