asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amo...@apache.org
Subject asterixdb git commit: [NO ISSUE][OTH] Cancel queries on abrupt close of user connection
Date Fri, 16 Mar 2018 16:38:51 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master e45528725 -> 8798c324a


[NO ISSUE][OTH] Cancel queries on abrupt close of user connection

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Since there is no point of processing user queries when the user
  disconnects before getting the response of their requests, the
  QueryServiceServlet now cancels the user request when that happens.

Change-Id: I902b52322153d114f7ca5f0f06e0af9c5ead8f2a
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2490
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>


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

Branch: refs/heads/master
Commit: 8798c324aa7e99a92356df2a8567be35fcbd9efe
Parents: e455287
Author: Abdullah Alamoudi <bamousaa@gmail.com>
Authored: Thu Mar 15 23:06:22 2018 -0700
Committer: abdullah alamoudi <bamousaa@gmail.com>
Committed: Fri Mar 16 09:38:25 2018 -0700

----------------------------------------------------------------------
 .../api/http/server/NCQueryServiceServlet.java  |  8 +++++
 .../http/server/InterruptOnCloseHandler.java    | 37 ++++++++++++++++++++
 .../hyracks/http/test/HttpServerTest.java       |  3 +-
 3 files changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8798c324/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCQueryServiceServlet.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCQueryServiceServlet.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCQueryServiceServlet.java
index 5cbac64..3564736 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCQueryServiceServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCQueryServiceServlet.java
@@ -47,7 +47,10 @@ import org.apache.commons.lang3.tuple.Triple;
 import org.apache.hyracks.api.application.INCServiceContext;
 import org.apache.hyracks.api.dataset.ResultSetId;
 import org.apache.hyracks.api.job.JobId;
+import org.apache.hyracks.http.api.IChannelClosedHandler;
 import org.apache.hyracks.http.api.IServletRequest;
+import org.apache.hyracks.http.server.HttpServer;
+import org.apache.hyracks.http.server.InterruptOnCloseHandler;
 import org.apache.hyracks.ipc.exceptions.IPCException;
 import org.apache.logging.log4j.Level;
 
@@ -160,4 +163,9 @@ public class NCQueryServiceServlet extends QueryServiceServlet {
             super.handleExecuteStatementException(t, execution);
         }
     }
+
+    @Override
+    public IChannelClosedHandler getChannelClosedHandler(HttpServer server) {
+        return InterruptOnCloseHandler.INSTANCE;
+    }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8798c324/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/InterruptOnCloseHandler.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/InterruptOnCloseHandler.java
b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/InterruptOnCloseHandler.java
new file mode 100644
index 0000000..84b802f
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/InterruptOnCloseHandler.java
@@ -0,0 +1,37 @@
+/*
+ * 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.hyracks.http.server;
+
+import java.util.concurrent.Future;
+
+import org.apache.hyracks.http.api.IChannelClosedHandler;
+import org.apache.hyracks.http.api.IServlet;
+
+public class InterruptOnCloseHandler implements IChannelClosedHandler {
+    public static final InterruptOnCloseHandler INSTANCE = new InterruptOnCloseHandler();
+
+    private InterruptOnCloseHandler() {
+    }
+
+    @Override
+    public void channelClosed(HttpServer server, IServlet servlet, Future<Void> task)
{
+        task.cancel(true);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8798c324/hyracks-fullstack/hyracks/hyracks-http/src/test/java/org/apache/hyracks/http/test/HttpServerTest.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-http/src/test/java/org/apache/hyracks/http/test/HttpServerTest.java
b/hyracks-fullstack/hyracks/hyracks-http/src/test/java/org/apache/hyracks/http/test/HttpServerTest.java
index 7e6ccf4..71e84e5 100644
--- a/hyracks-fullstack/hyracks/hyracks-http/src/test/java/org/apache/hyracks/http/test/HttpServerTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-http/src/test/java/org/apache/hyracks/http/test/HttpServerTest.java
@@ -33,6 +33,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.hyracks.http.server.HttpServer;
+import org.apache.hyracks.http.server.InterruptOnCloseHandler;
 import org.apache.hyracks.http.server.WebManager;
 import org.apache.hyracks.http.server.utils.HttpUtil;
 import org.apache.hyracks.http.servlet.ChattyServlet;
@@ -301,7 +302,7 @@ public class HttpServerTest {
         int numExecutors = 1;
         int queueSize = 1;
         HttpServer server = new HttpServer(webMgr.getBosses(), webMgr.getWorkers(), PORT,
numExecutors, queueSize,
-                (reqServer, reqServlet, reqTask) -> reqTask.cancel(true));
+                InterruptOnCloseHandler.INSTANCE);
         SleepyServlet servlet = new SleepyServlet(server.ctx(), new String[] { PATH });
         server.addServlet(servlet);
         webMgr.add(server);


Mime
View raw message