Repository: asterixdb
Updated Branches:
  refs/heads/master 51c145c44 -> 63c5e2f72


[NO ISSUE] Factor out common error handling code

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

Change-Id: I896d4242d39b72e7c322077ac5c99b0e63f0926c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2366
Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhub...@apache.org>


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

Branch: refs/heads/master
Commit: 63c5e2f726ea9455649f245288fdd0bfcc59a59c
Parents: 51c145c
Author: Till Westmann <t...@couchbase.com>
Authored: Tue Feb 6 16:28:02 2018 -0800
Committer: Till Westmann <ti...@apache.org>
Committed: Wed Feb 7 21:43:40 2018 -0800

----------------------------------------------------------------------
 .../am/lsm/common/impls/AbstractLSMIndex.java   | 46 ++++----------------
 1 file changed, 9 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/63c5e2f7/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
----------------------------------------------------------------------
diff --git 
a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
 
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
index 5a95af0..908a5c2 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
@@ -719,72 +719,44 @@ public abstract class AbstractLSMIndex implements 
ILSMIndex {
             FlushOperation flushOp = (FlushOperation) operation;
             LOGGER.log(Level.INFO, "Flushing component with id: " + 
flushOp.getFlushingComponent().getId());
         }
-        ILSMDiskComponent component = null;
         try {
-            component = doFlush(operation);
-            return component;
+            return doFlush(operation);
         } catch (Exception e) {
             LOGGER.error("Fail to execute flush " + this, e);
-            // clean up component
-            try {
-                cleanUpFiles(operation);
-            } catch (HyracksDataException e1) {
-                e.addSuppressed(e1);
-            }
+            cleanUpFiles(operation, e);
             throw HyracksDataException.create(e);
         }
-
     }
 
     @Override
     public final ILSMDiskComponent merge(ILSMIOOperation operation) throws 
HyracksDataException {
         ILSMIndexAccessor accessor = operation.getAccessor();
         ILSMIndexOperationContext opCtx = accessor.getOpContext();
-        ILSMDiskComponent component = null;
         try {
-            component = opCtx.getOperation() == 
IndexOperation.DELETE_DISK_COMPONENTS ? EmptyComponent.INSTANCE
+            return opCtx.getOperation() == 
IndexOperation.DELETE_DISK_COMPONENTS ? EmptyComponent.INSTANCE
                     : doMerge(operation);
-            return component;
         } catch (Exception e) {
             LOGGER.error("Fail to execute merge " + this, e);
-            // clean up component
-            try {
-                cleanUpFiles(operation);
-            } catch (HyracksDataException e1) {
-                e.addSuppressed(e1);
-            }
+            cleanUpFiles(operation, e);
             throw HyracksDataException.create(e);
         }
-
     }
 
-    protected void cleanUpFiles(ILSMIOOperation operation) throws 
HyracksDataException {
+    protected void cleanUpFiles(ILSMIOOperation operation, Exception e) {
         LSMComponentFileReferences componentFiles = 
operation.getComponentFiles();
         if (componentFiles == null) {
             return;
         }
         FileReference[] files = componentFiles.getFileReferences();
-        HyracksDataException exception = null;
         for (FileReference file : files) {
             try {
-                cleanUpFile(file);
-            } catch (HyracksDataException e) {
-                if (exception == null) {
-                    exception = e;
-                } else {
-                    exception.addSuppressed(e);
+                if (file != null) {
+                    diskBufferCache.deleteFile(file);
                 }
+            } catch (HyracksDataException hde) {
+                e.addSuppressed(hde);
             }
         }
-        if (exception != null) {
-            throw exception;
-        }
-    }
-
-    protected void cleanUpFile(FileReference file) throws HyracksDataException 
{
-        if (file != null) {
-            diskBufferCache.deleteFile(file);
-        }
     }
 
     protected abstract LSMComponentFileReferences 
getMergeFileReferences(ILSMDiskComponent firstComponent,

Reply via email to