Skip to content
Permalink
Browse files
Ensure Job Destroyed on Channel Drop
Change-Id: I011f15906a4b53936a1191bf505fddea674093df
  • Loading branch information
mhubail committed Nov 12, 2017
1 parent 02d7c8c commit 1f36ec759df1a97156db05897962ead20a41a4aa
Showing 2 changed files with 45 additions and 0 deletions.
@@ -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 @@ public void handle(IHyracksClientConnection hcc, IStatementExecutor statementExe
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 void handle(IHyracksClientConnection hcc, IStatementExecutor statementExe
}
}

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;
}
}
}
@@ -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;

0 comments on commit 1f36ec7

Please sign in to comment.