Repository: hbase
Updated Branches:
  refs/heads/master 91291e378 -> d8e032279


HBASE-15711 Add client side property to allow logging details for batch errors


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

Branch: refs/heads/master
Commit: d8e032279f4dc9a8c3b45fe4a4fa68b3de145350
Parents: 91291e3
Author: Yu Li <[email protected]>
Authored: Fri Apr 29 10:14:27 2016 +0800
Committer: Yu Li <[email protected]>
Committed: Fri Apr 29 10:14:27 2016 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/client/AsyncProcess.java       | 21 +++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/d8e03227/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
----------------------------------------------------------------------
diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
index 142e2a0..b2c758d 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
@@ -115,6 +115,11 @@ class AsyncProcess {
   public static final int DEFAULT_START_LOG_ERRORS_AFTER_COUNT = 9;
 
   /**
+   * Configuration to decide whether to log details for batch error
+   */
+  public static final String LOG_DETAILS_FOR_BATCH_ERROR = 
"hbase.client.log.batcherrors.details";
+
+  /**
    * The context used to wait for results from one submit call.
    * 1) If AsyncProcess is set to track errors globally, and not per call (for 
HTable puts),
    *    then errors and failed operations in this object will reflect global 
errors.
@@ -222,6 +227,8 @@ class AsyncProcess {
   protected int serverTrackerTimeout;
   protected int timeout;
   protected long primaryCallTimeoutMicroseconds;
+  /** Whether to log details for batch errors */
+  private final boolean logBatchErrorDetails;
   // End configuration settings.
 
   protected static class BatchErrors {
@@ -243,9 +250,12 @@ class AsyncProcess {
       return !throwables.isEmpty();
     }
 
-    private synchronized RetriesExhaustedWithDetailsException makeException() {
-      return new RetriesExhaustedWithDetailsException(
-          new ArrayList<Throwable>(throwables),
+    private synchronized RetriesExhaustedWithDetailsException 
makeException(boolean logDetails) {
+      if (logDetails) {
+        LOG.error("Exception occurred! Exception details: " + throwables + 
";\nActions: "
+            + actions);
+      }
+      return new RetriesExhaustedWithDetailsException(new 
ArrayList<Throwable>(throwables),
           new ArrayList<Row>(actions), new ArrayList<String>(addresses));
     }
 
@@ -320,6 +330,7 @@ class AsyncProcess {
 
     this.rpcCallerFactory = rpcCaller;
     this.rpcFactory = rpcFactory;
+    this.logBatchErrorDetails = conf.getBoolean(LOG_DETAILS_FOR_BATCH_ERROR, 
false);
   }
 
   /**
@@ -1688,7 +1699,7 @@ class AsyncProcess {
 
     @Override
     public RetriesExhaustedWithDetailsException getErrors() {
-      return errors.makeException();
+      return errors.makeException(logBatchErrorDetails);
     }
 
     @Override
@@ -1808,7 +1819,7 @@ class AsyncProcess {
     if (failedRows != null) {
       failedRows.addAll(globalErrors.actions);
     }
-    RetriesExhaustedWithDetailsException result = globalErrors.makeException();
+    RetriesExhaustedWithDetailsException result = 
globalErrors.makeException(logBatchErrorDetails);
     globalErrors.clear();
     return result;
   }

Reply via email to