asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject asterixdb git commit: QueryServiceServlet fixes
Date Wed, 28 Sep 2016 18:14:32 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master ec893ca97 -> 6277d155a


QueryServiceServlet fixes

- abort requests if the cluster state is not ACTIVE
- execution time is 0 if an error happens before execution starts

Change-Id: Ifff417a0a07771a264f8496f228fda1b10146c6e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1216
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: Michael Blow <mblow@apache.org>


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

Branch: refs/heads/master
Commit: 6277d155af2e443ea1ea650fcdd78f1b4a3f7f2e
Parents: ec893ca
Author: Till Westmann <tillw@apache.org>
Authored: Mon Sep 26 22:13:47 2016 -0700
Committer: Till Westmann <tillw@apache.org>
Committed: Wed Sep 28 11:14:05 2016 -0700

----------------------------------------------------------------------
 .../asterix/api/http/servlet/QueryServiceServlet.java  | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6277d155/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
index 856aa40..3a22302 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
@@ -39,6 +39,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.asterix.app.result.ResultReader;
 import org.apache.asterix.app.result.ResultUtil;
 import org.apache.asterix.app.translator.QueryTranslator;
+import org.apache.asterix.common.api.IClusterManagementWork;
 import org.apache.asterix.common.app.SessionConfig;
 import org.apache.asterix.common.config.GlobalConfig;
 import org.apache.asterix.common.exceptions.AsterixException;
@@ -48,6 +49,7 @@ import org.apache.asterix.lang.aql.parser.TokenMgrError;
 import org.apache.asterix.lang.common.base.IParser;
 import org.apache.asterix.lang.common.base.Statement;
 import org.apache.asterix.metadata.MetadataManager;
+import org.apache.asterix.runtime.util.ClusterStateManager;
 import org.apache.asterix.translator.IStatementExecutor;
 import org.apache.asterix.translator.IStatementExecutor.Stats;
 import org.apache.asterix.translator.IStatementExecutorFactory;
@@ -434,7 +436,7 @@ public class QueryServiceServlet extends HttpServlet {
 
         int respCode = HttpServletResponse.SC_OK;
         Stats stats = new Stats();
-        long execStart = 0;
+        long execStart = -1;
         long execEnd = -1;
 
         resultWriter.print("{\n");
@@ -443,6 +445,11 @@ public class QueryServiceServlet extends HttpServlet {
         printSignature(resultWriter);
         printType(resultWriter, sessionConfig);
         try {
+            final IClusterManagementWork.ClusterState clusterState = ClusterStateManager.INSTANCE.getState();
+            if (clusterState != IClusterManagementWork.ClusterState.ACTIVE) {
+                // using a plain IllegalStateException here to get into the right catch clause
for a 500
+                throw new IllegalStateException("Cannot execute request, cluster is " + clusterState);
+            }
             if (param.statement == null || param.statement.isEmpty()) {
                 throw new AsterixException("Empty request, no statement provided");
             }
@@ -477,7 +484,9 @@ public class QueryServiceServlet extends HttpServlet {
             printStatus(resultWriter, ResultStatus.FATAL);
             respCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
         } finally {
-            if (execEnd == -1) {
+            if (execStart == -1) {
+                execEnd = -1;
+            } else if (execEnd == -1) {
                 execEnd = System.nanoTime();
             }
         }


Mime
View raw message