This is an automated email from the ASF dual-hosted git repository.

mblow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit 82319bc03d9da3edd11d7b4f8d2d4b6c50e4e1a4
Author: Michael Blow <[email protected]>
AuthorDate: Wed Feb 5 10:23:31 2020 -0500

    [NO ISSUE][*DB][API] Return 503 on executor shutdown
    
    Change-Id: I8efd7dc9a8f19972884e542dd97906d4701661b8
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/4944
    Tested-by: Jenkins <[email protected]>
    Integration-Tests: Jenkins <[email protected]>
    Reviewed-by: Till Westmann <[email protected]>
---
 .../apache/asterix/api/http/server/DiagnosticsApiServlet.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/DiagnosticsApiServlet.java
 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/DiagnosticsApiServlet.java
index e294510..9876eed 100644
--- 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/DiagnosticsApiServlet.java
+++ 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/DiagnosticsApiServlet.java
@@ -32,6 +32,7 @@ import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
+import java.util.concurrent.RejectedExecutionException;
 
 import org.apache.asterix.common.cluster.IClusterStateManager;
 import org.apache.asterix.common.dataflow.ICcApplicationContext;
@@ -75,10 +76,13 @@ public class DiagnosticsApiServlet extends 
NodeControllerDetailsApiServlet {
             response.setStatus(HttpResponseStatus.SERVICE_UNAVAILABLE);
         } catch (IllegalArgumentException e) { // NOSONAR - exception not 
logged or rethrown
             response.setStatus(HttpResponseStatus.NOT_FOUND);
+        } catch (RejectedExecutionException e) {
+            // we must be shutting down, return 503
+            LOGGER.info("RejectedExecutionException while servicing request; 
returning 503", e);
+            sendError(response, HttpResponseStatus.SERVICE_UNAVAILABLE, null);
         } catch (Exception e) {
-            LOGGER.log(Level.INFO, "exception thrown for " + request, e);
-            response.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
-            responseWriter.write(e.toString());
+            LOGGER.warn("exception while servicing request; returning 500", e);
+            sendError(response, HttpResponseStatus.INTERNAL_SERVER_ERROR, 
e.toString());
         }
         responseWriter.flush();
     }

Reply via email to