asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject asterixdb git commit: Output From ShutdownAPIServlet; status 405 on GET
Date Thu, 01 Sep 2016 15:49:41 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 9b5405a68 -> 4ba0bf3c5


Output From ShutdownAPIServlet; status 405 on GET

Change-Id: I3f1a7d707ebdcb2a6502bc06d35d7ed38121e472
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1136
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: 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/4ba0bf3c
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/4ba0bf3c
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/4ba0bf3c

Branch: refs/heads/master
Commit: 4ba0bf3c5be5a138387e8e850940ee9a1d86d56c
Parents: 9b5405a
Author: Michael Blow <mblow@apache.org>
Authored: Wed Aug 31 22:10:20 2016 -0400
Committer: Michael Blow <mblow@apache.org>
Committed: Thu Sep 1 08:49:16 2016 -0700

----------------------------------------------------------------------
 .../api/http/servlet/ShutdownAPIServlet.java    | 30 ++++++++++++++------
 1 file changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4ba0bf3c/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 6d8c444..dd2f799 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,6 +19,8 @@
 package org.apache.asterix.api.http.servlet;
 
 import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Date;
 import java.util.logging.Level;
 
 import javax.servlet.ServletContext;
@@ -28,7 +30,9 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.asterix.common.config.GlobalConfig;
+import org.apache.asterix.om.util.AsterixClusterProperties;
 import org.apache.hyracks.api.client.IHyracksClientConnection;
+import org.json.JSONObject;
 
 import static org.apache.asterix.api.http.servlet.ServletConstants.HYRACKS_CONNECTION_ATTR;
 
@@ -39,23 +43,31 @@ public class ShutdownAPIServlet extends HttpServlet {
     protected void doPost(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {
 
-        response.setContentType("application/json");
-        response.setCharacterEncoding("utf-8");
-
         ServletContext context = getServletContext();
         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);
+                GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, "Exception stopping cluster",
e);
             }
-        });
-        t.start();
+        }, "Shutdown Servlet Worker");
+
+        response.setContentType("application/json");
+        response.setCharacterEncoding("utf-8");
         response.setStatus(HttpServletResponse.SC_ACCEPTED);
-    }
+        JSONObject jsonObject = new JSONObject();
+        try {
+            jsonObject.put("status", "SHUTTING_DOWN");
+            jsonObject.put("date", new Date());
+            jsonObject.put("cluster" , AsterixClusterProperties.INSTANCE.getClusterStateDescription());
 
-    @Override
-    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException
{
+            final PrintWriter writer = response.getWriter();
+            writer.print(jsonObject.toString(4));
+            writer.close();
+        } catch (Exception e) {
+            GlobalConfig.ASTERIX_LOGGER.log(Level.INFO, "Exception writing response", e);
+        }
+        t.start();
     }
 }


Mime
View raw message