You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2017/11/13 04:49:18 UTC
asterixdb-bad git commit: Ensure Job Destroyed on Channel Drop
Repository: asterixdb-bad
Updated Branches:
refs/heads/master 02d7c8c81 -> 1f36ec759
Ensure Job Destroyed on Channel Drop
Change-Id: I011f15906a4b53936a1191bf505fddea674093df
Project: http://git-wip-us.apache.org/repos/asf/asterixdb-bad/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb-bad/commit/1f36ec75
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb-bad/tree/1f36ec75
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb-bad/diff/1f36ec75
Branch: refs/heads/master
Commit: 1f36ec759df1a97156db05897962ead20a41a4aa
Parents: 02d7c8c
Author: Murtadha Hubail <mu...@couchbase.com>
Authored: Mon Nov 13 01:55:07 2017 +0300
Committer: Murtadha Hubail <mu...@couchbase.com>
Committed: Mon Nov 13 01:55:07 2017 +0300
----------------------------------------------------------------------
.../lang/statement/ChannelDropStatement.java | 18 +++++++++++++
.../room_occupants/room_occupants.9.ddl.sqlpp | 27 ++++++++++++++++++++
2 files changed, 45 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/1f36ec75/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelDropStatement.java
----------------------------------------------------------------------
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..f4ea2f3 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.IRequestParameters;
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 @@ public class ChannelDropStatement implements IExtensionStatement {
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,19 @@ public class ChannelDropStatement implements IExtensionStatement {
}
}
+ 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.getComponent().equals(ErrorCode.HYRACKS)
+ && hde.getErrorCode() == ErrorCode.JOB_HAS_BEEN_CLEARED_FROM_HISTORY) {
+ return;
+ }
+ }
+ throw e;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/1f36ec75/asterix-bad/src/test/resources/runtimets/queries/channel/room_occupants/room_occupants.9.ddl.sqlpp
----------------------------------------------------------------------
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;