Repository: asterixdb
Updated Branches:
  refs/heads/master 0f84c2179 -> c05f01522


Handle error conditions in the /query/status API

Change-Id: I30176c5c70dcc5f7f6605ad79dd0e41967373d9c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1522
Tested-by: Jenkins <[email protected]>
Reviewed-by: Yingyi Bu <[email protected]>
Integration-Tests: Jenkins <[email protected]>


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

Branch: refs/heads/master
Commit: c05f01522638dc1141ec0e331a6c1fe66504aefb
Parents: 0f84c21
Author: Till Westmann <[email protected]>
Authored: Fri Feb 24 08:19:54 2017 -0800
Committer: Till Westmann <[email protected]>
Committed: Fri Feb 24 15:34:15 2017 -0800

----------------------------------------------------------------------
 .../api/http/server/QueryStatusApiServlet.java  | 42 +++++++--
 .../asterix/test/runtime/APIExecutionTest.java  | 64 +++++++++++++
 .../test/runtime/ClusterStateExecutionTest.java | 64 -------------
 .../src/test/resources/runtimets/api.xml        | 98 ++++++++++++++++++++
 .../src/test/resources/runtimets/only_api.xml   | 25 +++++
 .../runtimets/queries/api/APIQueries.xml        | 66 -------------
 .../query_status_1/query_status_1.1.get.http    | 25 +++++
 .../query_status_2/query_status_2.1.get.http    | 25 +++++
 .../query_status_3/query_status_3.1.get.http    | 25 +++++
 .../query_status_4/query_status_4.1.get.http    | 25 +++++
 .../src/test/resources/runtimets/testsuite.xml  |  2 -
 .../hyracks/api/exceptions/ErrorCode.java       |  1 +
 .../src/main/resources/errormsg/en.properties   |  1 +
 .../client/dataset/HyracksDatasetReader.java    | 13 ++-
 .../cc/dataset/DatasetDirectoryService.java     | 10 +-
 .../org/apache/hyracks/ipc/impl/IPCSystem.java  |  6 +-
 16 files changed, 338 insertions(+), 154 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryStatusApiServlet.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryStatusApiServlet.java
 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryStatusApiServlet.java
index 5a62eaa..1c3f4c7 100644
--- 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryStatusApiServlet.java
+++ 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryStatusApiServlet.java
@@ -29,6 +29,7 @@ import java.util.logging.Logger;
 
 import org.apache.asterix.app.result.ResultReader;
 import org.apache.hyracks.api.client.IHyracksClientConnection;
+import org.apache.hyracks.api.dataset.DatasetJobRecord;
 import org.apache.hyracks.api.dataset.IHyracksDataset;
 import org.apache.hyracks.api.dataset.ResultSetId;
 import org.apache.hyracks.api.job.JobId;
@@ -38,11 +39,11 @@ import org.apache.hyracks.http.api.IServletResponse;
 import org.apache.hyracks.http.server.AbstractServlet;
 import org.apache.hyracks.http.server.utils.HttpUtil;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 
-import io.netty.handler.codec.http.HttpMethod;
 import io.netty.handler.codec.http.HttpResponseStatus;
 
 public class QueryStatusApiServlet extends AbstractServlet {
@@ -56,7 +57,7 @@ public class QueryStatusApiServlet extends AbstractServlet {
     protected void get(IServletRequest request, IServletResponse response) {
         response.setStatus(HttpResponseStatus.OK);
         try {
-            HttpUtil.setContentType(response, HttpUtil.ContentType.TEXT_HTML, 
HttpUtil.Encoding.UTF8);
+            HttpUtil.setContentType(response, HttpUtil.ContentType.TEXT_PLAIN, 
HttpUtil.Encoding.UTF8);
         } catch (IOException e) {
             LOGGER.log(Level.WARNING, "Failure setting content type", e);
             response.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
@@ -65,6 +66,15 @@ public class QueryStatusApiServlet extends AbstractServlet {
         String strHandle = request.getParameter("handle");
         PrintWriter out = response.writer();
         try {
+            ObjectMapper om = new ObjectMapper();
+            JsonNode handle = parseHandle(om, strHandle, LOGGER);
+            if (handle == null) {
+                response.setStatus(HttpResponseStatus.BAD_REQUEST);
+                return;
+            }
+            JobId jobId = new JobId(handle.get(0).asLong());
+            ResultSetId rsId = new ResultSetId(handle.get(1).asLong());
+
             IHyracksDataset hds = (IHyracksDataset) 
ctx.get(HYRACKS_DATASET_ATTR);
             if (hds == null) {
                 synchronized (ctx) {
@@ -76,12 +86,6 @@ public class QueryStatusApiServlet extends AbstractServlet {
                     }
                 }
             }
-            ObjectMapper om = new ObjectMapper();
-            JsonNode handleObj = om.readTree(strHandle);
-            JsonNode handle = handleObj.get("handle");
-            JobId jobId = new JobId(handle.get(0).asLong());
-            ResultSetId rsId = new ResultSetId(handle.get(1).asLong());
-
             /* TODO(madhusudancs): We need to find a way to LOSSLESS_JSON 
serialize default format obtained from
              * metadataProvider in the AQLTranslator and store it as part of 
the result handle.
              */
@@ -89,14 +93,32 @@ public class QueryStatusApiServlet extends AbstractServlet {
             resultReader.open(jobId, rsId);
 
             ObjectNode jsonResponse = om.createObjectNode();
-            jsonResponse.put("status", resultReader.getStatus().name());
+            final DatasetJobRecord.Status status = resultReader.getStatus();
+            if (status == null) {
+                LOGGER.log(Level.INFO, "No results for: \"" + strHandle + 
"\"");
+                response.setStatus(HttpResponseStatus.NOT_FOUND);
+                return;
+            }
+            jsonResponse.put("status", status.name());
             out.write(jsonResponse.toString());
 
         } catch (Exception e) {
             LOGGER.log(Level.SEVERE, "Failure handling a request", e);
             out.println(e.getMessage());
-            e.printStackTrace(out);
         }
     }
 
+    static JsonNode parseHandle(ObjectMapper om, String strHandle, Logger 
logger) throws IOException {
+        if (strHandle == null) {
+            logger.log(Level.WARNING, "No handle provided");
+        } else {
+            try {
+                JsonNode handleObj = om.readTree(strHandle);
+                return handleObj.get("handle");
+            } catch (JsonProcessingException e) {
+                logger.log(Level.WARNING, "Invalid handle: \"" + strHandle + 
"\"");
+            }
+        }
+        return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/APIExecutionTest.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/APIExecutionTest.java
 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/APIExecutionTest.java
new file mode 100644
index 0000000..82f90ec
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/APIExecutionTest.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.test.runtime;
+
+import java.util.Collection;
+
+import org.apache.asterix.testframework.context.TestCaseContext;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Runs the cluster state runtime tests with the storage parallelism.
+ */
+@RunWith(Parameterized.class)
+public class APIExecutionTest {
+    protected static final String TEST_CONFIG_FILE_NAME = 
"asterix-build-configuration.xml";
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        LangExecutionUtil.setUp(TEST_CONFIG_FILE_NAME);
+    }
+
+    @AfterClass
+    public static void tearDown() throws Exception {
+        LangExecutionUtil.tearDown();
+    }
+
+    @Parameters(name = "APIExecutionTest {index}: {0}")
+    public static Collection<Object[]> tests() throws Exception {
+        return LangExecutionUtil.tests("only_api.xml", "api.xml");
+    }
+
+    protected TestCaseContext tcCtx;
+
+    public APIExecutionTest(TestCaseContext tcCtx) {
+        this.tcCtx = tcCtx;
+    }
+
+    @Test
+    public void test() throws Exception {
+        LangExecutionUtil.test(tcCtx);
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ClusterStateExecutionTest.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ClusterStateExecutionTest.java
 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ClusterStateExecutionTest.java
deleted file mode 100644
index 4d19cbf..0000000
--- 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ClusterStateExecutionTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.asterix.test.runtime;
-
-import java.util.Collection;
-
-import org.apache.asterix.testframework.context.TestCaseContext;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * Runs the cluster state runtime tests with the storage parallelism.
- */
-@RunWith(Parameterized.class)
-public class ClusterStateExecutionTest {
-    protected static final String TEST_CONFIG_FILE_NAME = 
"asterix-build-configuration.xml";
-
-    @BeforeClass
-    public static void setUp() throws Exception {
-        LangExecutionUtil.setUp(TEST_CONFIG_FILE_NAME);
-    }
-
-    @AfterClass
-    public static void tearDown() throws Exception {
-        LangExecutionUtil.tearDown();
-    }
-
-    @Parameters(name = "ClusterStateExecutionTest {index}: {0}")
-    public static Collection<Object[]> tests() throws Exception {
-        return LangExecutionUtil.tests("only_cluster_state.xml", 
"cluster_state.xml");
-    }
-
-    protected TestCaseContext tcCtx;
-
-    public ClusterStateExecutionTest(TestCaseContext tcCtx) {
-        this.tcCtx = tcCtx;
-    }
-
-    @Test
-    public void test() throws Exception {
-        LangExecutionUtil.test(tcCtx);
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/asterixdb/asterix-app/src/test/resources/runtimets/api.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/api.xml 
b/asterixdb/asterix-app/src/test/resources/runtimets/api.xml
new file mode 100644
index 0000000..6e97c0e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/api.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership.  The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License.  You may obtain a copy of the License at
+ !
+ !   http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+<test-suite xmlns="urn:xml.testframework.asterix.apache.org" 
ResultOffsetPath="results" QueryOffsetPath="queries">
+  <test-group name="api">
+    <test-case FilePath="api">
+      <compilation-unit name="cluster_state_1">
+        <output-dir compare="Text">cluster_state_1</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="cluster_state_2">
+        <output-dir compare="Text">cluster_state_2</output-dir>
+        <expected-error>HTTP/1.1 404 Not Found</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="cluster_state_3">
+        <output-dir compare="Text">cluster_state_3</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="cluster_state_4">
+        <output-dir compare="Text">cluster_state_4</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="cluster_state_cc_1">
+        <output-dir compare="Text">cluster_state_cc_1</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="cluster_state_cc_stats_1">
+        <output-dir compare="Text">cluster_state_cc_stats_1</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="cluster_state_nc_threaddump_1">
+        <output-dir compare="Text">cluster_state_nc_threaddump_1</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="version_1">
+        <output-dir compare="Text">version_1</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="diagnostics_1">
+        <output-dir compare="Text">diagnostics_1</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="replication">
+        <output-dir compare="Text">replication</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="query_status_1">
+        <output-dir compare="Text">query_status_1</output-dir>
+        <expected-error>HTTP/1.1 404 Not Found</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="query_status_2">
+        <output-dir compare="Text">query_status_2</output-dir>
+        <expected-error>HTTP/1.1 400 Bad Request</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="query_status_3">
+        <output-dir compare="Text">query_status_3</output-dir>
+        <expected-error>HTTP/1.1 400 Bad Request</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="api">
+      <compilation-unit name="query_status_4">
+        <output-dir compare="Text">query_status_4</output-dir>
+        <expected-error>HTTP/1.1 400 Bad Request</expected-error>
+      </compilation-unit>
+    </test-case>
+  </test-group>
+</test-suite>

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/asterixdb/asterix-app/src/test/resources/runtimets/only_api.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/only_api.xml 
b/asterixdb/asterix-app/src/test/resources/runtimets/only_api.xml
new file mode 100644
index 0000000..eea32a7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/only_api.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+  ~ /*
+  ~  * Licensed to the Apache Software Foundation (ASF) under one
+  ~  * or more contributor license agreements.  See the NOTICE file
+  ~  * distributed with this work for additional information
+  ~  * regarding copyright ownership.  The ASF licenses this file
+  ~  * to you under the Apache License, Version 2.0 (the
+  ~  * "License"); you may not use this file except in compliance
+  ~  * with the License.  You may obtain a copy of the License at
+  ~  *
+  ~  *   http://www.apache.org/licenses/LICENSE-2.0
+  ~  *
+  ~  * Unless required by applicable law or agreed to in writing,
+  ~  * software distributed under the License is distributed on an
+  ~  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  * KIND, either express or implied.  See the License for the
+  ~  * specific language governing permissions and limitations
+  ~  * under the License.
+  ~  */
+  -->
+<test-suite xmlns="urn:xml.testframework.asterix.apache.org" 
ResultOffsetPath="results" QueryOffsetPath="queries">
+  <test-group name="failed">
+  </test-group>
+</test-suite>

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/APIQueries.xml
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/APIQueries.xml 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/APIQueries.xml
deleted file mode 100644
index eb505f1..0000000
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/APIQueries.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<!--
- ! Licensed to the Apache Software Foundation (ASF) under one
- ! or more contributor license agreements.  See the NOTICE file
- ! distributed with this work for additional information
- ! regarding copyright ownership.  The ASF licenses this file
- ! to you under the Apache License, Version 2.0 (the
- ! "License"); you may not use this file except in compliance
- ! with the License.  You may obtain a copy of the License at
- !
- !   http://www.apache.org/licenses/LICENSE-2.0
- !
- ! Unless required by applicable law or agreed to in writing,
- ! software distributed under the License is distributed on an
- ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ! KIND, either express or implied.  See the License for the
- ! specific language governing permissions and limitations
- ! under the License.
- !-->
-<test-group name="api">
-  <test-case FilePath="api">
-    <compilation-unit name="cluster_state_2">
-      <output-dir compare="Text">cluster_state_2</output-dir>
-      <expected-error>HTTP/1.1 404 Not Found</expected-error>
-    </compilation-unit>
-  </test-case>
-  <test-case FilePath="api">
-    <compilation-unit name="cluster_state_3">
-      <output-dir compare="Text">cluster_state_3</output-dir>
-    </compilation-unit>
-  </test-case>
-  <test-case FilePath="api">
-    <compilation-unit name="cluster_state_4">
-      <output-dir compare="Text">cluster_state_4</output-dir>
-    </compilation-unit>
-  </test-case>
-  <test-case FilePath="api">
-    <compilation-unit name="cluster_state_cc_1">
-      <output-dir compare="Text">cluster_state_cc_1</output-dir>
-    </compilation-unit>
-  </test-case>
-  <test-case FilePath="api">
-    <compilation-unit name="cluster_state_cc_stats_1">
-      <output-dir compare="Text">cluster_state_cc_stats_1</output-dir>
-    </compilation-unit>
-  </test-case>
-  <test-case FilePath="api">
-    <compilation-unit name="cluster_state_nc_threaddump_1">
-      <output-dir compare="Text">cluster_state_nc_threaddump_1</output-dir>
-    </compilation-unit>
-  </test-case>
-  <test-case FilePath="api">
-    <compilation-unit name="version_1">
-      <output-dir compare="Text">version_1</output-dir>
-    </compilation-unit>
-  </test-case>
-  <test-case FilePath="api">
-    <compilation-unit name="diagnostics_1">
-      <output-dir compare="Text">diagnostics_1</output-dir>
-    </compilation-unit>
-  </test-case>
-  <test-case FilePath="api">
-    <compilation-unit name="replication">
-      <output-dir compare="Text">replication</output-dir>
-    </compilation-unit>
-  </test-case>
-</test-group>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_1/query_status_1.1.get.http
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_1/query_status_1.1.get.http
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_1/query_status_1.1.get.http
new file mode 100644
index 0000000..c18a55b
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_1/query_status_1.1.get.http
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : query_status_1
+ * Description     : test query status for non-existent result
+ * Expected Result : Negative
+ * Date            : 7th September 2016
+ */
+/query/status?handle={"handle":[18,0]}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_2/query_status_2.1.get.http
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_2/query_status_2.1.get.http
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_2/query_status_2.1.get.http
new file mode 100644
index 0000000..d7ece4c
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_2/query_status_2.1.get.http
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : query_status_2
+ * Description     : test query status for incorrect handle
+ * Expected Result : Negative
+ * Date            : 7th September 2016
+ */
+/query/status?handle={"handle":[18,0]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_3/query_status_3.1.get.http
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_3/query_status_3.1.get.http
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_3/query_status_3.1.get.http
new file mode 100644
index 0000000..a7ff551
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_3/query_status_3.1.get.http
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : query_status_3
+ * Description     : test query status for empty handle
+ * Expected Result : Negative
+ * Date            : 7th September 2016
+ */
+/query/status?handle

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_4/query_status_4.1.get.http
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_4/query_status_4.1.get.http
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_4/query_status_4.1.get.http
new file mode 100644
index 0000000..5831686
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/query_status_4/query_status_4.1.get.http
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : query_status_4
+ * Description     : test query status for non-existent handle
+ * Expected Result : Negative
+ * Date            : 7th September 2016
+ */
+/query/status?handl={"handle":[18,0]}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml 
b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
index f9242f6..a4bd36f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -19,7 +19,6 @@
 <!-- Keep test-suite list in Alphabetical order. -->
 <!DOCTYPE test-suite [
 
-             <!ENTITY APIQueries SYSTEM "queries/api/APIQueries.xml">
              <!ENTITY ComparisonQueries SYSTEM 
"queries/comparison/ComparisonQueries.xml">
              <!ENTITY DeepEqualQueries SYSTEM 
"queries/comparison/deep_equal/DeepEqualQueries.xml">
              <!ENTITY RecordsQueries SYSTEM 
"queries/objects/ObjectsQueries.xml">
@@ -32,7 +31,6 @@
              ResultOffsetPath="results"
              QueryOffsetPath="queries"
              QueryFileExtension=".aql">
-  &APIQueries;
   <test-group name="external-library">
     <test-case FilePath="external-library">
       <compilation-unit name="typed_adapter">

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
----------------------------------------------------------------------
diff --git 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
index b5bd1a9..1b97a60 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
@@ -58,6 +58,7 @@ public class ErrorCode {
     public static final int ERROR_FINDING_DISTRIBUTED_JOB = 21;
     public static final int DUPLICATE_DISTRIBUTED_JOB = 22;
     public static final int DISTRIBUTED_JOB_FAILURE = 23;
+    public static final int NO_RESULTSET = 24;
 
     // Compilation error codes.
     public static final int RULECOLLECTION_NOT_INSTANCE_OF_LIST = 10001;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
----------------------------------------------------------------------
diff --git 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
index f536d3e..3711e48 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
+++ 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
@@ -42,5 +42,6 @@
 21 = The distributed job %1$s was not found
 22 = The distributed job %1$s already exists
 23 = The distributed work failed for %1$s at %2$s
+24 = No result set %1$s for job %2$s
 
 10000 = The given rule collection %1$s is not an instance of the List class.

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/hyracks-fullstack/hyracks/hyracks-client/src/main/java/org/apache/hyracks/client/dataset/HyracksDatasetReader.java
----------------------------------------------------------------------
diff --git 
a/hyracks-fullstack/hyracks/hyracks-client/src/main/java/org/apache/hyracks/client/dataset/HyracksDatasetReader.java
 
b/hyracks-fullstack/hyracks/hyracks-client/src/main/java/org/apache/hyracks/client/dataset/HyracksDatasetReader.java
index f6f05d2..e47d822 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-client/src/main/java/org/apache/hyracks/client/dataset/HyracksDatasetReader.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-client/src/main/java/org/apache/hyracks/client/dataset/HyracksDatasetReader.java
@@ -25,6 +25,7 @@ import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.apache.hyracks.api.channels.IInputChannel;
@@ -37,6 +38,7 @@ import 
org.apache.hyracks.api.dataset.IDatasetInputChannelMonitor;
 import 
org.apache.hyracks.api.dataset.IHyracksDatasetDirectoryServiceConnection;
 import org.apache.hyracks.api.dataset.IHyracksDatasetReader;
 import org.apache.hyracks.api.dataset.ResultSetId;
+import org.apache.hyracks.api.exceptions.ErrorCode;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.exceptions.HyracksException;
 import org.apache.hyracks.api.job.JobId;
@@ -87,13 +89,16 @@ public class HyracksDatasetReader implements 
IHyracksDatasetReader {
 
     @Override
     public Status getResultStatus() {
-        Status status = null;
         try {
-            status = 
datasetDirectoryServiceConnection.getDatasetResultStatus(jobId, resultSetId);
+            return 
datasetDirectoryServiceConnection.getDatasetResultStatus(jobId, resultSetId);
+        } catch (HyracksDataException e) {
+            if (e.getErrorCode() != ErrorCode.NO_RESULTSET) {
+                LOGGER.log(Level.WARNING, "Exception retrieving result set for 
job " + jobId, e);
+            }
         } catch (Exception e) {
-            // TODO(madhusudancs): Decide what to do in case of error
+            LOGGER.log(Level.WARNING, "Exception retrieving result set for job 
" + jobId, e);
         }
-        return status;
+        return null;
     }
 
     private DatasetDirectoryRecord getRecord(int partition) throws Exception {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/dataset/DatasetDirectoryService.java
----------------------------------------------------------------------
diff --git 
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/dataset/DatasetDirectoryService.java
 
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/dataset/DatasetDirectoryService.java
index c4cf38d..ceeb9fa 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/dataset/DatasetDirectoryService.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/dataset/DatasetDirectoryService.java
@@ -162,13 +162,9 @@ public class DatasetDirectoryService implements 
IDatasetDirectoryService {
 
     @Override
     public synchronized Status getResultStatus(JobId jobId, ResultSetId rsId) 
throws HyracksDataException {
-        DatasetJobRecord djr;
-        while ((djr = getDatasetJobRecord(jobId)) == null) {
-            try {
-                wait();
-            } catch (InterruptedException e) {
-                throw new HyracksDataException(e);
-            }
+        DatasetJobRecord djr = getDatasetJobRecord(jobId);
+        if (djr == null) {
+            throw HyracksDataException.create(ErrorCode.NO_RESULTSET, rsId, 
jobId);
         }
         return djr.getStatus();
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c05f0152/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/impl/IPCSystem.java
----------------------------------------------------------------------
diff --git 
a/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/impl/IPCSystem.java
 
b/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/impl/IPCSystem.java
index 62be1b0..0997e57 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/impl/IPCSystem.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/impl/IPCSystem.java
@@ -21,6 +21,8 @@ package org.apache.hyracks.ipc.impl;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.apache.hyracks.ipc.api.IIPCHandle;
 import org.apache.hyracks.ipc.api.IIPCI;
@@ -29,6 +31,8 @@ import 
org.apache.hyracks.ipc.api.IPayloadSerializerDeserializer;
 import org.apache.hyracks.ipc.exceptions.IPCException;
 
 public class IPCSystem {
+    private static final Logger LOGGER = 
Logger.getLogger(IPCSystem.class.getName());
+
     private final IPCConnectionManager cMgr;
 
     private final IIPCI ipci;
@@ -88,7 +92,7 @@ public class IPCSystem {
         Exception exception = null;
         if (message.getFlag() == Message.ERROR) {
             exception = (Exception) message.getPayload();
-            exception.printStackTrace();
+            LOGGER.log(Level.INFO, "Exception in message " + 
message.toString());
         } else {
             payload = message.getPayload();
         }

Reply via email to