asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject asterixdb git commit: ASTERIXDB-1551: Shutdown Servlet Delays Shutdown
Date Wed, 27 Jul 2016 23:16:56 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 79ccdac8a -> 6448824af


ASTERIXDB-1551: Shutdown Servlet Delays Shutdown

Change-Id: I80d74b13dc3aa8df9aedf49cb766751e4c091198
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1026
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/6448824a
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/6448824a
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/6448824a

Branch: refs/heads/master
Commit: 6448824afa714c65c319250988b8dc26fc9181c1
Parents: 79ccdac
Author: Michael Blow <mblow@apache.org>
Authored: Wed Jul 27 09:24:42 2016 -0400
Committer: Michael Blow <mblow@apache.org>
Committed: Wed Jul 27 16:16:30 2016 -0700

----------------------------------------------------------------------
 .../api/http/servlet/ShutdownAPIServlet.java    | 27 ++++++--------------
 1 file changed, 8 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6448824a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java
index e2e7c90..6d8c444 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java
@@ -19,9 +19,6 @@
 package org.apache.asterix.api.http.servlet;
 
 import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.nio.charset.StandardCharsets;
 import java.util.logging.Level;
 
 import javax.servlet.ServletContext;
@@ -31,8 +28,6 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.asterix.common.config.GlobalConfig;
-import org.apache.asterix.result.ResultUtils;
-import org.apache.commons.io.IOUtils;
 import org.apache.hyracks.api.client.IHyracksClientConnection;
 
 import static org.apache.asterix.api.http.servlet.ServletConstants.HYRACKS_CONNECTION_ATTR;
@@ -47,23 +42,17 @@ public class ShutdownAPIServlet extends HttpServlet {
         response.setContentType("application/json");
         response.setCharacterEncoding("utf-8");
 
-        PrintWriter out = response.getWriter();
-        StringWriter sw = new StringWriter();
-        IOUtils.copy(request.getInputStream(), sw, StandardCharsets.UTF_8.name());
-
         ServletContext context = getServletContext();
-        IHyracksClientConnection hcc;
-        try {
-            synchronized (context) {
-                hcc = (IHyracksClientConnection) context.getAttribute(HYRACKS_CONNECTION_ATTR);
-                response.setStatus(HttpServletResponse.SC_ACCEPTED);
+        IHyracksClientConnection hcc = (IHyracksClientConnection) context.getAttribute(HYRACKS_CONNECTION_ATTR);
+        Thread t = new Thread(() -> {
+            try {
                 hcc.stopCluster();
+            } catch (Exception e) {
+                GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, e.getMessage(), e);
             }
-        } catch (Exception e) {
-            GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, e.getMessage(), e);
-            ResultUtils.apiErrorHandler(out, e);
-            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-        }
+        });
+        t.start();
+        response.setStatus(HttpServletResponse.SC_ACCEPTED);
     }
 
     @Override


Mime
View raw message