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

This commit is contained in:
Yu Li 2016-04-29 10:14:27 +08:00
parent 91291e3780
commit d8e032279f
1 changed files with 16 additions and 5 deletions

View File

@ -114,6 +114,11 @@ class AsyncProcess {
"hbase.client.start.log.errors.counter";
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),
@ -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;
}