asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject [17/34] asterixdb git commit: [NO ISSUE][RT] Inherit Closeable in IFrameOperationCallback
Date Mon, 09 Apr 2018 21:26:35 GMT
[NO ISSUE][RT] Inherit Closeable in IFrameOperationCallback

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

Details:
- Primary upsert operator uses an IFrameOperationCallback
  to perform per frame operations. In this change,
  IFrameOperationCallback extends Closeable and allow the
  callback to release resources on the close of the pipeline.

Change-Id: Iaacd6538c27d5498868256616a793e0ebcec3729
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2536
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/bf41e4cb
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/bf41e4cb
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/bf41e4cb

Branch: refs/heads/release-0.9.4-pre-rc
Commit: bf41e4cb3cfd659f6b00e783532d470ce2b7281e
Parents: 6453ecf
Author: Abdullah Alamoudi <bamousaa@gmail.com>
Authored: Mon Mar 26 21:10:08 2018 -0700
Committer: abdullah alamoudi <bamousaa@gmail.com>
Committed: Wed Mar 28 12:31:01 2018 -0700

----------------------------------------------------------------------
 .../common/context/BaseOperationTracker.java    |  4 ++++
 .../NoOpFrameOperationCallbackFactory.java      |  7 +++++++
 .../LSMPrimaryUpsertOperatorNodePushable.java   | 22 +++++++++++---------
 .../am/common/api/IIndexDataflowHelper.java     |  5 ++++-
 .../lsm/common/api/IFrameOperationCallback.java |  5 +++--
 5 files changed, 30 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bf41e4cb/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/BaseOperationTracker.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/BaseOperationTracker.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/BaseOperationTracker.java
index 9ec13ef..b7af0b6 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/BaseOperationTracker.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/BaseOperationTracker.java
@@ -74,4 +74,8 @@ public class BaseOperationTracker implements ITransactionOperationTracker
{
         dsInfo.untouch();
         dsInfo.getIndexes().get(resourceId).untouch();
     }
+
+    public DatasetInfo getDatasetInfo() {
+        return dsInfo;
+    }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bf41e4cb/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/NoOpFrameOperationCallbackFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/NoOpFrameOperationCallbackFactory.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/NoOpFrameOperationCallbackFactory.java
index 5e3879f..8f28752 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/NoOpFrameOperationCallbackFactory.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/NoOpFrameOperationCallbackFactory.java
@@ -18,6 +18,8 @@
  */
 package org.apache.asterix.common.dataflow;
 
+import java.io.IOException;
+
 import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.storage.am.lsm.common.api.IFrameOperationCallback;
@@ -43,5 +45,10 @@ public class NoOpFrameOperationCallbackFactory implements IFrameOperationCallbac
         public void frameCompleted() throws HyracksDataException {
             // No Op
         }
+
+        @Override
+        public void close() throws IOException {
+            // No Op
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bf41e4cb/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java
index e58a7db..68053d3 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java
@@ -40,6 +40,7 @@ import org.apache.hyracks.api.dataflow.value.IMissingWriter;
 import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
 import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.util.CleanupUtils;
 import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
 import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference;
 import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
@@ -243,6 +244,11 @@ public class LSMPrimaryUpsertOperatorNodePushable extends LSMIndexInsertUpdateDe
                     callback.frameCompleted();
                     appender.write(writer, true);
                 }
+
+                @Override
+                public void close() throws IOException {
+                    callback.close();
+                }
             };
         } catch (Throwable e) { // NOSONAR: Re-thrown
             throw HyracksDataException.create(e);
@@ -360,16 +366,12 @@ public class LSMPrimaryUpsertOperatorNodePushable extends LSMIndexInsertUpdateDe
 
     @Override
     public void close() throws HyracksDataException {
-        try {
-            try {
-                if (cursor != null) {
-                    cursor.destroy();
-                }
-            } finally {
-                writer.close();
-            }
-        } finally {
-            indexHelper.close();
+        Throwable failure = CleanupUtils.close(frameOpCallback, null);
+        failure = CleanupUtils.destroy(failure, cursor);
+        failure = CleanupUtils.close(writer, failure);
+        failure = CleanupUtils.close(indexHelper, failure);
+        if (failure != null) {
+            throw HyracksDataException.create(failure);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bf41e4cb/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IIndexDataflowHelper.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IIndexDataflowHelper.java
b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IIndexDataflowHelper.java
index be10b27..9e65eb2 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IIndexDataflowHelper.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/api/IIndexDataflowHelper.java
@@ -18,11 +18,13 @@
  */
 package org.apache.hyracks.storage.am.common.api;
 
+import java.io.Closeable;
+
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.storage.common.IIndex;
 import org.apache.hyracks.storage.common.LocalResource;
 
-public interface IIndexDataflowHelper {
+public interface IIndexDataflowHelper extends Closeable {
 
     /**
      * If open throws an exception, it means that the index was not opened successfully.
@@ -36,6 +38,7 @@ public interface IIndexDataflowHelper {
      *
      * @throws HyracksDataException
      */
+    @Override
     void close() throws HyracksDataException;
 
     /**

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/bf41e4cb/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/api/IFrameOperationCallback.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/api/IFrameOperationCallback.java
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/api/IFrameOperationCallback.java
index 96eb559..df78c53 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/api/IFrameOperationCallback.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/api/IFrameOperationCallback.java
@@ -18,13 +18,14 @@
  */
 package org.apache.hyracks.storage.am.lsm.common.api;
 
+import java.io.Closeable;
+
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 /**
  * An interface that is used to enable frame level operation on indexes
  */
-@FunctionalInterface
-public interface IFrameOperationCallback {
+public interface IFrameOperationCallback extends Closeable {
     /**
      * Called once processing the frame is done before calling nextFrame on the next IFrameWriter
in
      * the pipeline


Mime
View raw message