You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2017/12/13 01:06:29 UTC

[accumulo] branch master updated: ACCUMULO-4758 throw correct exception when meta block absent (#334)

This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new 815c269  ACCUMULO-4758 throw correct exception when meta block absent (#334)
815c269 is described below

commit 815c2692a048be0dcbc67b8d05a4e4bc36312f57
Author: Keith Turner <ke...@deenlo.com>
AuthorDate: Tue Dec 12 20:06:26 2017 -0500

    ACCUMULO-4758 throw correct exception when meta block absent (#334)
---
 .../core/file/blockfile/impl/CachableBlockFile.java      | 16 +++++++++++++---
 .../core/file/rfile/bcfile/MetaBlockDoesNotExist.java    |  5 +++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
index d5ab62c..0f68420 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
@@ -39,6 +39,7 @@ import org.apache.accumulo.core.file.blockfile.cache.CacheEntry.Weighbable;
 import org.apache.accumulo.core.file.rfile.bcfile.BCFile;
 import org.apache.accumulo.core.file.rfile.bcfile.BCFile.Reader.BlockReader;
 import org.apache.accumulo.core.file.rfile.bcfile.BCFile.Writer.BlockAppender;
+import org.apache.accumulo.core.file.rfile.bcfile.MetaBlockDoesNotExist;
 import org.apache.accumulo.core.file.streams.PositionedOutput;
 import org.apache.accumulo.core.file.streams.RateLimitedInputStream;
 import org.apache.accumulo.core.file.streams.RateLimitedOutputStream;
@@ -395,9 +396,18 @@ public class CachableBlockFile {
     public BlockRead getMetaBlock(String blockName) throws IOException {
       if (_iCache != null) {
         String _lookup = this.cacheId + "M" + blockName;
-        CacheEntry ce = _iCache.getBlock(_lookup, new MetaBlockLoader(blockName));
-        if (ce != null) {
-          return new CachedBlockRead(ce, ce.getBuffer());
+        try {
+          CacheEntry ce = _iCache.getBlock(_lookup, new MetaBlockLoader(blockName));
+          if (ce != null) {
+            return new CachedBlockRead(ce, ce.getBuffer());
+          }
+        } catch (UncheckedIOException uioe) {
+          if (uioe.getCause() instanceof MetaBlockDoesNotExist) {
+            // When a block does not exists, its expected that MetaBlockDoesNotExist is thrown. However do not want to throw cause, because stack trace info
+            // would be lost. So rewrap and throw ino rder to preserve full stack trace.
+            throw new MetaBlockDoesNotExist(uioe);
+          }
+          throw uioe;
         }
       }
 
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/MetaBlockDoesNotExist.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/MetaBlockDoesNotExist.java
index bf9319d..a4b7e44 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/MetaBlockDoesNotExist.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/MetaBlockDoesNotExist.java
@@ -18,6 +18,7 @@
 package org.apache.accumulo.core.file.rfile.bcfile;
 
 import java.io.IOException;
+import java.io.UncheckedIOException;
 
 /**
  * Exception - No such Meta Block with the given name.
@@ -33,4 +34,8 @@ public class MetaBlockDoesNotExist extends IOException {
   MetaBlockDoesNotExist(String s) {
     super(s);
   }
+
+  public MetaBlockDoesNotExist(UncheckedIOException uioe) {
+    super(uioe);
+  }
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@accumulo.apache.org" <co...@accumulo.apache.org>'].