Repository: hbase Updated Branches: refs/heads/branch-1 c51275091 -> 44fdfb3ba
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/44fdfb3b Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/44fdfb3b Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/44fdfb3b Branch: refs/heads/branch-1 Commit: 44fdfb3ba0bf1c7e5f1d8a153c4b05b6f41263ee Parents: c512750 Author: Yu Li <[email protected]> Authored: Fri Apr 29 10:14:27 2016 +0800 Committer: Yu Li <[email protected]> Committed: Fri Apr 29 10:16:01 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/44fdfb3b/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 fb46365..b2b6be5 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. @@ -223,6 +228,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 { @@ -244,9 +251,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)); } @@ -319,6 +329,7 @@ class AsyncProcess { this.rpcCallerFactory = rpcCaller; this.rpcFactory = rpcFactory; + this.logBatchErrorDetails = conf.getBoolean(LOG_DETAILS_FOR_BATCH_ERROR, false); } /** @@ -1690,7 +1701,7 @@ class AsyncProcess { @Override public RetriesExhaustedWithDetailsException getErrors() { - return errors.makeException(); + return errors.makeException(logBatchErrorDetails); } @Override @@ -1810,7 +1821,7 @@ class AsyncProcess { if (failedRows != null) { failedRows.addAll(globalErrors.actions); } - RetriesExhaustedWithDetailsException result = globalErrors.makeException(); + RetriesExhaustedWithDetailsException result = globalErrors.makeException(logBatchErrorDetails); globalErrors.clear(); return result; }
