asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murtadha Hubail (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb-bad[master]: Ensure Job Destroyed on Channel Drop
Date Sun, 12 Nov 2017 21:20:38 GMT
Murtadha Hubail has uploaded a new change for review.

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

Change subject: Ensure Job Destroyed on Channel Drop
......................................................................

Ensure Job Destroyed on Channel Drop

Change-Id: I011f15906a4b53936a1191bf505fddea674093df
---
M asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelDropStatement.java
A asterix-bad/src/test/resources/runtimets/queries/channel/room_occupants/room_occupants.9.ddl.sqlpp
2 files changed, 44 insertions(+), 0 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb-bad refs/changes/46/2146/1

diff --git a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelDropStatement.java
b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelDropStatement.java
index fb71770..5294520 100644
--- a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelDropStatement.java
+++ b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelDropStatement.java
@@ -38,6 +38,7 @@
 import org.apache.asterix.translator.IStatementExecutor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.api.client.IHyracksClientConnection;
+import org.apache.hyracks.api.exceptions.ErrorCode;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.job.JobId;
 
@@ -114,6 +115,8 @@
             activeEventHandler.unregisterListener(listener);
             if (hyracksJobId != null) {
                 hcc.destroyJob(hyracksJobId);
+                // wait for job completion to release any resources to be dropped
+                ensureJobDestroyed(hcc, hyracksJobId);
             }
 
             //Create a metadata provider to use in nested jobs.
@@ -144,4 +147,18 @@
         }
     }
 
+    private void ensureJobDestroyed(IHyracksClientConnection hcc, JobId hyracksJobId) throws
Exception {
+        try {
+            hcc.waitForCompletion(hyracksJobId);
+        } catch (Exception e) {
+            // if the job has already been destroyed, it is safe to complete
+            if (e instanceof HyracksDataException) {
+                HyracksDataException hde = (HyracksDataException) e;
+                if (hde.getErrorCode() == ErrorCode.JOB_HAS_BEEN_CLEARED_FROM_HISTORY) {
+                    return;
+                }
+            }
+            throw e;
+        }
+    }
 }
\ No newline at end of file
diff --git a/asterix-bad/src/test/resources/runtimets/queries/channel/room_occupants/room_occupants.9.ddl.sqlpp
b/asterix-bad/src/test/resources/runtimets/queries/channel/room_occupants/room_occupants.9.ddl.sqlpp
new file mode 100644
index 0000000..0fc703f
--- /dev/null
+++ b/asterix-bad/src/test/resources/runtimets/queries/channel/room_occupants/room_occupants.9.ddl.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.
+ */
+/*
+* Description  : Room Occupants Test
+* Expected Res : Success
+* Date         : Nov 2017
+*/
+
+use channels;
+
+drop channel roomRecords;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I011f15906a4b53936a1191bf505fddea674093df
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb-bad
Gerrit-Branch: master
Gerrit-Owner: Murtadha Hubail <mhubail@apache.org>

Mime
View raw message