asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wail Alkowaileet (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: Add Result Location API.
Date Fri, 12 May 2017 19:59:22 GMT
Wail Alkowaileet has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1742

Change subject: Add Result Location API.
......................................................................

Add Result Location API.

- Allows to retrieve result directly from the Distributed Result Framework.

Change-Id: I3c888bb11f90d119b01acc80576e127b84789ed8
---
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/IStatementExecutor.java
M asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/AbstractQueryApiServlet.java
A asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryResultLocationAPIServlet.java
M asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
M asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
M asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/AsyncDeferredQueries.xml
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_1/result_location_1.1.location.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_1/result_location_1.2.get.uri
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.1.ddl.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.2.update.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.3.location.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.4.get.uri
A asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_1/result_location_1.1.ignore
A asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_1/result_location_1.2.regexadm
A asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_2/result_location_1.1.ignore
A asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_2/result_location_1.2.regexadm
M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/Servlets.java
19 files changed, 377 insertions(+), 6 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/42/1742/1

diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/IStatementExecutor.java
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/IStatementExecutor.java
index 19f0dcc..1f8f98f 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/IStatementExecutor.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/IStatementExecutor.java
@@ -56,9 +56,13 @@
          */
         DEFERRED,
         /**
+         * Results are produced completely, but only a location handle is returned.
+         */
+        LOCATION,
+        /**
          * A result handle is returned before the resutlts are complete
          */
-        ASYNC
+        ASYNC;
     }
 
     class ResultMetadata implements Serializable {
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/AbstractQueryApiServlet.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/AbstractQueryApiServlet.java
index a4e72f7..a6d1bec 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/AbstractQueryApiServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/AbstractQueryApiServlet.java
@@ -46,7 +46,10 @@
         RESULTS("results"),
         HANDLE("handle"),
         ERRORS("errors"),
-        METRICS("metrics");
+        METRICS("metrics"),
+        RESULT_LOCATIONS("locations"),
+        ADDRESS("address"),
+        PORT("port");
 
         private final String str;
 
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryResultLocationAPIServlet.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryResultLocationAPIServlet.java
new file mode 100644
index 0000000..5d1eca4
--- /dev/null
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryResultLocationAPIServlet.java
@@ -0,0 +1,149 @@
+/*
+ * 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.api.http.server;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.concurrent.ConcurrentMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.asterix.app.result.ResultHandle;
+import org.apache.asterix.app.result.ResultReader;
+import org.apache.asterix.common.dataflow.ICcApplicationContext;
+import org.apache.hyracks.api.client.IHyracksClientConnection;
+import org.apache.hyracks.api.comm.NetworkAddress;
+import org.apache.hyracks.api.dataset.DatasetDirectoryRecord;
+import org.apache.hyracks.api.dataset.DatasetJobRecord;
+import org.apache.hyracks.api.dataset.IHyracksDataset;
+import org.apache.hyracks.api.dataset.IHyracksDatasetDirectoryServiceConnection;
+import org.apache.hyracks.client.dataset.HyracksDatasetDirectoryServiceConnection;
+import org.apache.hyracks.http.api.IServletRequest;
+import org.apache.hyracks.http.api.IServletResponse;
+import org.apache.hyracks.http.server.utils.HttpUtil;
+
+import io.netty.handler.codec.http.HttpResponseStatus;
+
+/**
+ * A servlet to get the result locations.
+ */
+public class QueryResultLocationAPIServlet extends AbstractQueryApiServlet {
+
+    private static final Logger LOGGER = Logger.getLogger(QueryResultApiServlet.class.getName());
+
+    public QueryResultLocationAPIServlet(ConcurrentMap<String, Object> ctx, String[]
paths,
+            ICcApplicationContext appCtx) {
+        super(appCtx, ctx, paths);
+    }
+
+    @Override
+    public void get(IServletRequest request, IServletResponse response) throws Exception
{
+        HttpUtil.setContentType(response, HttpUtil.ContentType.APPLICATION_JSON, HttpUtil.Encoding.UTF8);
+        PrintWriter out = response.writer();
+
+        final String strHandle = localPath(request);
+        final ResultHandle handle = ResultHandle.parse(strHandle);
+        if (handle == null) {
+            response.setStatus(HttpResponseStatus.BAD_REQUEST);
+            return;
+        }
+
+        IHyracksDataset hds = getHyracksDataset();
+        IHyracksClientConnection hcc = getHyracksClientConnection();
+        ResultReader resultReader = new ResultReader(hds, handle.getJobId(), handle.getResultSetId());
+
+        try {
+            DatasetJobRecord.Status status = resultReader.getStatus();
+
+            final HttpResponseStatus httpStatus;
+            if (status == null) {
+                httpStatus = HttpResponseStatus.NOT_FOUND;
+            } else {
+                switch (status.getState()) {
+                    case SUCCESS:
+                        httpStatus = HttpResponseStatus.OK;
+                        break;
+                    case RUNNING:
+                    case IDLE:
+                    case FAILED:
+                        httpStatus = HttpResponseStatus.NOT_FOUND;
+                        break;
+                    default:
+                        httpStatus = HttpResponseStatus.INTERNAL_SERVER_ERROR;
+                        break;
+                }
+            }
+            response.setStatus(httpStatus);
+            if (httpStatus != HttpResponseStatus.OK) {
+                return;
+            }
+
+            final StringWriter stringWriter = new StringWriter();
+            final PrintWriter resultWriter = new PrintWriter(stringWriter);
+
+            resultWriter.print("{\n");
+            getResultsLocations(hcc, handle, resultWriter);
+            resultWriter.print("}");
+
+            resultWriter.flush();
+            final String result = stringWriter.toString();
+            out.write(result);
+
+        } catch (Exception e) {
+            response.setStatus(HttpResponseStatus.BAD_REQUEST);
+            out.println(e.getMessage());
+            LOGGER.log(Level.WARNING, "Error retrieving result", e);
+        }
+    }
+
+    private void getResultsLocations(IHyracksClientConnection hcc, ResultHandle resultHandle,
PrintWriter resultWriter)
+            throws Exception {
+        final NetworkAddress ddsAddress = hcc.getDatasetDirectoryServiceInfo();
+        final IHyracksDatasetDirectoryServiceConnection ddsc =
+                new HyracksDatasetDirectoryServiceConnection(ddsAddress.getAddress(), ddsAddress.getPort());
+        final DatasetDirectoryRecord[] locations =
+                ddsc.getDatasetResultLocations(resultHandle.getJobId(), resultHandle.getResultSetId(),
null);
+
+        resultWriter.print("\t");
+        resultWriter.print("\"locations\": [\n");
+        printLocations(resultWriter, locations);
+        resultWriter.print("\t");
+        resultWriter.print("]\n");
+
+    }
+
+    private void printLocations(PrintWriter resultWriter, DatasetDirectoryRecord[] locations)
{
+
+        for (int i = 0; i < locations.length; i++) {
+            final String address = locations[i].getNetworkAddress().getAddress();
+            final long port = locations[i].getNetworkAddress().getPort();
+            resultWriter.print("\t\t");
+            resultWriter.print("{\n");
+
+            resultWriter.print("\t\t");
+            ResultUtil.printField(resultWriter, ResultFields.ADDRESS.str(), address);
+
+            resultWriter.print("\t\t");
+            ResultUtil.printField(resultWriter, ResultFields.PORT.str(), port, false);
+
+            resultWriter.print("\t\t");
+            resultWriter.print("}" + (i < locations.length - 1 ? "," : "") + "\n");
+        }
+    }
+}
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
index c45f24a..1ba2b51 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
@@ -183,6 +183,7 @@
         boolean pretty;
         String clientContextID;
         String mode;
+        boolean locations;
 
         @Override
         public String toString() {
@@ -350,6 +351,8 @@
             return ResultDelivery.ASYNC;
         } else if ("deferred".equals(mode)) {
             return ResultDelivery.DEFERRED;
+        } else if ("location".equals(mode)) {
+            return ResultDelivery.LOCATION;
         } else {
             return ResultDelivery.IMMEDIATE;
         }
@@ -361,6 +364,8 @@
                 return "/status/";
             case DEFERRED:
                 return "/result/";
+            case LOCATION:
+                return "/location/";
             case IMMEDIATE:
             default:
                 return "";
@@ -412,7 +417,8 @@
             }
             String statementsText = param.statement + ";";
             executeStatement(statementsText, sessionOutput, delivery, stats, param, handleUrl,
execStartEnd);
-            if (ResultDelivery.IMMEDIATE == delivery || ResultDelivery.DEFERRED == delivery)
{
+            if (ResultDelivery.IMMEDIATE == delivery || ResultDelivery.DEFERRED == delivery
+                    || ResultDelivery.LOCATION == delivery) {
                 ResultUtil.printStatus(sessionOutput, ResultStatus.SUCCESS);
             }
         } catch (AsterixException | TokenMgrError | org.apache.asterix.aqlplus.parser.TokenMgrError
pe) {
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
index 5047bc2..ff6fa03 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
@@ -362,7 +362,8 @@
                     case Statement.Kind.QUERY:
                         metadataProvider.setResultSetId(new ResultSetId(resultSetIdCounter++));
                         metadataProvider.setResultAsyncMode(
-                                resultDelivery == ResultDelivery.ASYNC || resultDelivery
== ResultDelivery.DEFERRED);
+                                resultDelivery == ResultDelivery.ASYNC || resultDelivery
== ResultDelivery.DEFERRED
+                                        || resultDelivery == ResultDelivery.LOCATION);
                         handleQuery(metadataProvider, (Query) stmt, hcc, hdc, resultDelivery,
outMetadata, stats,
                                 clientContextId, ctx);
                         break;
@@ -2344,6 +2345,7 @@
                 }, clientContextId, ctx);
                 break;
             case DEFERRED:
+            case LOCATION:
                 createAndRunJob(hcc, null, compiler, locker, resultDelivery, id -> {
                     ResultUtil.printResultHandle(sessionOutput, new ResultHandle(id, resultSetId));
                     if (outMetadata != null) {
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
index 57cc340..8820bfd 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
@@ -43,6 +43,7 @@
 import org.apache.asterix.api.http.server.QueryApiServlet;
 import org.apache.asterix.api.http.server.QueryCancellationServlet;
 import org.apache.asterix.api.http.server.QueryResultApiServlet;
+import org.apache.asterix.api.http.server.QueryResultLocationAPIServlet;
 import org.apache.asterix.api.http.server.QueryServiceServlet;
 import org.apache.asterix.api.http.server.QueryStatusApiServlet;
 import org.apache.asterix.api.http.server.QueryWebInterfaceServlet;
@@ -221,6 +222,7 @@
         addServlet(jsonAPIServer, Servlets.QUERY_STATUS);
         addServlet(jsonAPIServer, Servlets.QUERY_RESULT);
         addServlet(jsonAPIServer, Servlets.QUERY_SERVICE);
+        addServlet(jsonAPIServer, Servlets.QUERY_RESULT_LOCATIONS);
         addServlet(jsonAPIServer, Servlets.RUNNING_REQUESTS);
         addServlet(jsonAPIServer, Servlets.CONNECTOR);
         addServlet(jsonAPIServer, Servlets.SHUTDOWN);
@@ -277,6 +279,8 @@
                 return new QueryStatusApiServlet(ctx, paths, appCtx);
             case Servlets.QUERY_RESULT:
                 return new QueryResultApiServlet(ctx, paths, appCtx);
+            case Servlets.QUERY_RESULT_LOCATIONS:
+                return new QueryResultLocationAPIServlet(ctx, paths, appCtx);
             case Servlets.QUERY_SERVICE:
                 return new QueryServiceServlet(ctx, paths, appCtx, SQLPP,
                         ccExtensionManager.getCompilationProvider(SQLPP), getStatementExecutorFactory(),
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
index 9913493..ce5df6f 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
@@ -112,6 +112,7 @@
 
     public static final String DELIVERY_ASYNC = "async";
     public static final String DELIVERY_DEFERRED = "deferred";
+    public static final String DELIVERY_LOCATION = "location";
     public static final String DELIVERY_IMMEDIATE = "immediate";
 
     private static Method managixExecuteMethod = null;
@@ -381,8 +382,8 @@
                 if (match && !negate || negate && !match) {
                     continue;
                 }
-                throw new Exception(
-                        "Result for " + scriptFile + ": expected pattern '" + expression
+ "' not found in result: "+actual);
+                throw new Exception("Result for " + scriptFile + ": expected pattern '" +
expression
+                        + "' not found in result: " + actual);
             }
         } catch (Exception e) {
             System.err.println("Actual results file: " + actualFile.toString());
@@ -803,6 +804,7 @@
             case "query":
             case "async":
             case "deferred":
+            case "location":
                 // isDmlRecoveryTest: insert Crash and Recovery
                 if (isDmlRecoveryTest) {
                     executeScript(pb, pb.environment().get("SCRIPT_HOME") + File.separator
+ "dml_recovery"
@@ -1058,6 +1060,8 @@
                 delivery = DELIVERY_ASYNC;
             } else if (reqType.equalsIgnoreCase("deferred")) {
                 delivery = DELIVERY_DEFERRED;
+            } else if (reqType.equalsIgnoreCase("location")) {
+                delivery = DELIVERY_LOCATION;
             }
             final URI uri = getEndpoint(Servlets.QUERY_SERVICE);
             if (DELIVERY_IMMEDIATE.equals(delivery)) {
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/AsyncDeferredQueries.xml
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/AsyncDeferredQueries.xml
index 9a2ad3c..6293eb9 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/AsyncDeferredQueries.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/AsyncDeferredQueries.xml
@@ -49,4 +49,14 @@
             <output-dir compare="Text">async-running</output-dir>
         </compilation-unit>
     </test-case>
+    <test-case FilePath="async-deferred">
+        <compilation-unit name="result_location1">
+            <output-dir compare="Text">result_location1</output-dir>
+        </compilation-unit>
+    </test-case>
+    <test-case FilePath="async-deferred">
+        <compilation-unit name="result_location2">
+            <output-dir compare="Text">result_location1</output-dir>
+        </compilation-unit>
+    </test-case>
 </test-group>
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_1/result_location_1.1.location.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_1/result_location_1.1.location.sqlpp
new file mode 100644
index 0000000..fa23ff4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_1/result_location_1.1.location.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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  : result_location_1
+ * Description     : Get result location for async query result
+ * Expected Result : Positive
+ * Date            : 20th September 2016
+ */
+#handlevariable=handle
+
+select i, i * i as i2 from range(1, 10) i;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_1/result_location_1.2.get.uri
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_1/result_location_1.2.get.uri
new file mode 100644
index 0000000..90403d0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_1/result_location_1.2.get.uri
@@ -0,0 +1,26 @@
+/*
+ * 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  : result_location_2
+ * Description     : Get result location for async query result
+ * Expected Result : Positive
+ * Date            : 20th September 2016
+ */
+ 
+$handle
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.1.ddl.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.1.ddl.sqlpp
new file mode 100644
index 0000000..b42f0f9
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.1.ddl.sqlpp
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+drop dataverse tpch if exists;
+create dataverse tpch;
+
+use tpch;
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : integer,
+  l_partkey : integer,
+  l_suppkey : integer,
+  l_linenumber : integer,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create  dataset LineItem(LineItemType) primary key l_orderkey,l_linenumber;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.2.update.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.2.update.sqlpp
new file mode 100644
index 0000000..8a78296
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.2.update.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+use tpch;
+
+load  dataset LineItem using localfs ((`path`=`asterix_nc1://data/tpch0.001/lineitem.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`))
pre-sorted;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.3.location.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.3.location.sqlpp
new file mode 100644
index 0000000..40251e2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.3.location.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+#handlevariable=handle
+USE tpch;
+
+SELECT
+       l.l_returnflag AS l_returnflag,
+       l.l_linestatus AS l_linestatus,
+       l.l_shipmode AS l_shipmode
+FROM  LineItem AS l
+;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.4.get.uri
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.4.get.uri
new file mode 100644
index 0000000..370981c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/result_location_2/result_location_2.4.get.uri
@@ -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  : result_location_2
+ * Description     : Get result location for async query result
+ * Expected Result : Positive
+ * Date            : 20th September 2016
+ */
+$handle
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_1/result_location_1.1.ignore
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_1/result_location_1.1.ignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_1/result_location_1.1.ignore
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_1/result_location_1.2.regexadm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_1/result_location_1.2.regexadm
new file mode 100644
index 0000000..90f75bb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_1/result_location_1.2.regexadm
@@ -0,0 +1,8 @@
+\{
+	"locations": \[
+		(\{
+			"address": "(?:[0-9]{1,3}\.){3}[0-9]{1,3}",
+			"port": [0-9]*
+		\})
+	\]
+\}
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_2/result_location_1.1.ignore
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_2/result_location_1.1.ignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_2/result_location_1.1.ignore
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_2/result_location_1.2.regexadm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_2/result_location_1.2.regexadm
new file mode 100644
index 0000000..8bacf25
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred/result_location_2/result_location_1.2.regexadm
@@ -0,0 +1,8 @@
+\{
+	"locations": \[
+		(\{
+			"address": "(?:[0-9]{1,3}\.){3}[0-9]{1,3}",
+			"port": [0-9]+
+		\}(,)?(\n)?(\t)*)+
+	\]
+\}
\ No newline at end of file
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/Servlets.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/Servlets.java
index 3047ef5..ca8e244 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/Servlets.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/Servlets.java
@@ -31,6 +31,7 @@
     public static final String QUERY_STATUS = "/query/service/status/*";
     public static final String QUERY_RESULT = "/query/service/result/*";
     public static final String QUERY_SERVICE = "/query/service";
+    public static final String QUERY_RESULT_LOCATIONS = "/query/service/location/*";
     public static final String CONNECTOR = "/connector";
     public static final String SHUTDOWN = "/admin/shutdown";
     public static final String VERSION = "/admin/version";

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1742
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3c888bb11f90d119b01acc80576e127b84789ed8
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Wail Alkowaileet <wael.y.k@gmail.com>

Mime
View raw message