drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From par...@apache.org
Subject [1/3] drill git commit: DRILL-2583, DRILL-3428: Catch exceptions, and throw UserException#dataReadError with more context. This closes #161
Date Mon, 28 Sep 2015 18:36:20 GMT
Repository: drill
Updated Branches:
  refs/heads/master b9afcf8fa -> c30a2687a


DRILL-2583, DRILL-3428: Catch exceptions, and throw UserException#dataReadError with more
context. This closes #161

+ Added convenient method to UserException for String.format(...)


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

Branch: refs/heads/master
Commit: c30a2687a653b6da9d590a8bc786cc52d518fd99
Parents: 51179b9
Author: Sudheesh Katkam <skatkam@maprtech.com>
Authored: Thu Sep 17 16:48:31 2015 -0700
Committer: Parth Chandra <parthc@apache.org>
Committed: Mon Sep 28 11:35:28 2015 -0700

----------------------------------------------------------------------
 .../org/apache/drill/common/exceptions/UserException.java | 10 ++++++++++
 .../apache/drill/exec/store/hbase/DrillHBaseTable.java    |  8 ++++++--
 .../easy/text/compliant/CompliantTextRecordReader.java    |  8 ++++++--
 3 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/c30a2687/common/src/main/java/org/apache/drill/common/exceptions/UserException.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/exceptions/UserException.java b/common/src/main/java/org/apache/drill/common/exceptions/UserException.java
index b006fe3..4473ee5 100644
--- a/common/src/main/java/org/apache/drill/common/exceptions/UserException.java
+++ b/common/src/main/java/org/apache/drill/common/exceptions/UserException.java
@@ -420,6 +420,16 @@ public class UserException extends DrillRuntimeException {
     }
 
     /**
+     * add a string line to the bottom of the context
+     * @param value string line
+     * @return this builder
+     */
+    public Builder addContext(final String value, Object... args) {
+      context.add(String.format(value, args));
+      return this;
+    }
+
+    /**
      * add a string value to the bottom of the context
      *
      * @param name context name

http://git-wip-us.apache.org/repos/asf/drill/blob/c30a2687/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/DrillHBaseTable.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/DrillHBaseTable.java
b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/DrillHBaseTable.java
index ffa18e7..e98aed2 100644
--- a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/DrillHBaseTable.java
+++ b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/DrillHBaseTable.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Set;
 
+import org.apache.drill.common.exceptions.UserException;
 import org.apache.drill.exec.planner.logical.DrillTable;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
@@ -30,7 +31,7 @@ import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.sql.type.SqlTypeName;
 
 public class DrillHBaseTable extends DrillTable implements DrillHBaseConstants {
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillHBaseTable.class);
+  private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillHBaseTable.class);
 
   private HTableDescriptor table;
 
@@ -39,7 +40,10 @@ public class DrillHBaseTable extends DrillTable implements DrillHBaseConstants
{
     try(HBaseAdmin admin = new HBaseAdmin(plugin.getConfig().getHBaseConf())) {
       table = admin.getTableDescriptor(HBaseUtils.getBytes(scanSpec.getTableName()));
     } catch (IOException e) {
-      logger.warn("Failure while loading table names for database '{}'.", storageEngineName,
e);
+      throw UserException.dataReadError()
+          .message("Failure while loading table %s in database %s.", scanSpec.getTableName(),
storageEngineName)
+          .addContext("Message: ", e.getMessage())
+          .build(logger);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/c30a2687/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java
index ad65a94..465a971 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java
@@ -17,6 +17,7 @@
  */
 package org.apache.drill.exec.store.easy.text.compliant;
 
+import com.univocity.parsers.common.TextParsingException;
 import io.netty.buffer.DrillBuf;
 
 import java.io.IOException;
@@ -134,8 +135,11 @@ public class CompliantTextRecordReader extends AbstractRecordReader {
       }
       reader.finishBatch();
       return cnt;
-    }catch(IOException e){
-      throw new DrillRuntimeException(String.format("Failure while setting up text reader
for file %s.  Happened at or shortly before byte position %d.", split.getPath(), reader.getPos()),
e);
+    } catch (IOException | TextParsingException e) {
+      throw UserException.dataReadError(e)
+          .addContext("Failure while reading file %s. Happened at or shortly before byte
position %d.",
+            split.getPath(), reader.getPos())
+          .build(logger);
     }
   }
 


Mime
View raw message