You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2017/12/13 01:06:30 UTC

[GitHub] keith-turner closed pull request #334: ACCUMULO-4758 throw correct exception when meta block absent

keith-turner closed pull request #334: ACCUMULO-4758 throw correct exception when meta block absent
URL: https://github.com/apache/accumulo/pull/334
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 d5ab62c144..0f684203b7 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.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 Reader(FileSystem fs, Path dataFile, Configuration conf, BlockCache data,
     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 bf9319dd05..a4b7e4471b 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 @@
   MetaBlockDoesNotExist(String s) {
     super(s);
   }
+
+  public MetaBlockDoesNotExist(UncheckedIOException uioe) {
+    super(uioe);
+  }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services