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(throwables), + private synchronized RetriesExhaustedWithDetailsException makeException(boolean logDetails) { + if (logDetails) { + LOG.error("Exception occurred! Exception details: " + throwables + ";\nActions: " + + actions); + } + return new RetriesExhaustedWithDetailsException(new ArrayList(throwables), new ArrayList(actions), new ArrayList(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; }