private void appendError(StringBuilder message, Throwable exception) { if(exception != null) { message.append(exception); if(exception.getCause() != null) { message.append(';'); appendError(message, exception.getCause()); } } }
/** * Attempts a flush operation, handling failed documents based on configured error listeners. * @throws EsHadoopException in the event that the bulk operation fails, is aborted, or its errors could not be handled. */ public void flush() { BulkResponse bulk = tryFlush(); if (!bulk.getDocumentErrors().isEmpty()) { int maxErrors = 5; String header = String.format("Could not write all entries for bulk operation [%s/%s]. Error " + "sample (first [%s] error messages):\n", bulk.getDocumentErrors().size(), bulk.getTotalDocs(), maxErrors); StringBuilder message = new StringBuilder(header); int i = 0; for (BulkResponse.BulkError errors : bulk.getDocumentErrors()) { if (i >=maxErrors ) { break; } message.append("\t"); appendError(message, errors.getError()); message.append("\n"); message.append("\t") .append(errors.getDocument().toString()) .append("\n"); i++; } message.append("Bailing out..."); throw new EsHadoopException(message.toString()); } }
private void appendError(StringBuilder message, Throwable exception) { if(exception != null) { message.append(exception); if(exception.getCause() != null) { message.append(';'); appendError(message, exception.getCause()); } } }
private void appendError(StringBuilder message, Throwable exception) { if(exception != null) { message.append(exception); if(exception.getCause() != null) { message.append(';'); appendError(message, exception.getCause()); } } }
private void appendError(StringBuilder message, Throwable exception) { if(exception != null) { message.append(exception); if(exception.getCause() != null) { message.append(';'); appendError(message, exception.getCause()); } } }
/** * Attempts a flush operation, handling failed documents based on configured error listeners. * @throws EsHadoopException in the event that the bulk operation fails, is aborted, or its errors could not be handled. */ public void flush() { BulkResponse bulk = tryFlush(); if (!bulk.getDocumentErrors().isEmpty()) { int maxErrors = 5; String header = String.format("Could not write all entries for bulk operation [%s/%s]. Error " + "sample (first [%s] error messages):\n", bulk.getDocumentErrors().size(), bulk.getTotalDocs(), maxErrors); StringBuilder message = new StringBuilder(header); int i = 0; for (BulkResponse.BulkError errors : bulk.getDocumentErrors()) { if (i >=maxErrors ) { break; } message.append("\t"); appendError(message, errors.getError()); message.append("\n"); message.append("\t") .append(errors.getDocument().toString()) .append("\n"); i++; } message.append("Bailing out..."); throw new EsHadoopException(message.toString()); } }
/** * Attempts a flush operation, handling failed documents based on configured error listeners. * @throws EsHadoopException in the event that the bulk operation fails, is aborted, or its errors could not be handled. */ public void flush() { BulkResponse bulk = tryFlush(); if (!bulk.getDocumentErrors().isEmpty()) { int maxErrors = 5; String header = String.format("Could not write all entries for bulk operation [%s/%s]. Error " + "sample (first [%s] error messages):\n", bulk.getDocumentErrors().size(), bulk.getTotalDocs(), maxErrors); StringBuilder message = new StringBuilder(header); int i = 0; for (BulkResponse.BulkError errors : bulk.getDocumentErrors()) { if (i >=maxErrors ) { break; } message.append("\t"); appendError(message, errors.getError()); message.append("\n"); message.append("\t") .append(errors.getDocument().toString()) .append("\n"); i++; } message.append("Bailing out..."); throw new EsHadoopException(message.toString()); } }
/** * Attempts a flush operation, handling failed documents based on configured error listeners. * @throws EsHadoopException in the event that the bulk operation fails, is aborted, or its errors could not be handled. */ public void flush() { BulkResponse bulk = tryFlush(); if (!bulk.getDocumentErrors().isEmpty()) { int maxErrors = 5; String header = String.format("Could not write all entries for bulk operation [%s/%s]. Error " + "sample (first [%s] error messages):\n", bulk.getDocumentErrors().size(), bulk.getTotalDocs(), maxErrors); StringBuilder message = new StringBuilder(header); int i = 0; for (BulkResponse.BulkError errors : bulk.getDocumentErrors()) { if (i >=maxErrors ) { break; } message.append("\t"); appendError(message, errors.getError()); message.append("\n"); message.append("\t") .append(errors.getDocument().toString()) .append("\n"); i++; } message.append("Bailing out..."); throw new EsHadoopException(message.toString()); } }