@Override public void onException(RetriesExhaustedWithDetailsException e, BufferedMutator mutator) { for (int i = 0; i < e.getNumExceptions(); i++) { LOG.info("Failed to sent put " + e.getRow(i) + "."); } } };
fail("Where is the exception? We put the malformed cells!!!"); } catch (RetriesExhaustedWithDetailsException e) { assertEquals(2, e.getNumExceptions()); for (int i = 0; i != e.getNumExceptions(); ++i) { assertNotNull(e.getCause(i)); assertEquals(DoNotRetryIOException.class, e.getCause(i).getClass()); assertEquals("fail", Bytes.toString(e.getRow(i).getRow()));
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)); }
public RetriesExhaustedWithDetailsException(List<Throwable> exceptions, List<Row> actions, List<String> hostnameAndPort) { super("Failed " + exceptions.size() + " action" + pluralize(exceptions) + ": " + getDesc(exceptions, actions, hostnameAndPort)); this.exceptions = exceptions; this.actions = actions; this.hostnameAndPort = hostnameAndPort; }
public static String getDesc(List<Throwable> exceptions, List<? extends Row> actions, List<String> hostnamePort) { String s = getDesc(classifyExs(exceptions)); StringBuilder addrs = new StringBuilder(s); addrs.append("servers with issues: "); Set<String> uniqAddr = new HashSet<>(hostnamePort); for (String addr : uniqAddr) { addrs.append(addr).append(", "); } return uniqAddr.isEmpty() ? addrs.toString() : addrs.substring(0, addrs.length() - 2); }
public static void logRetriesExhaustedWithDetailsException( Logger log, String context, RetriesExhaustedWithDetailsException exception) { if (log.isDebugEnabled()) { log.error("For context {}: exception occured during a bulk operation: {}", context, exception.getExhaustiveDescription()); } if (exception.getNumExceptions() == 0) { log.error( "For context {}: Got a RetriesExhaustedWithDetailsException without any details.", exception); return; } log.error( String.format( "For context %s: %d exceptions occured during a bulk operation:\n\t%s.\n" + "The stack trace is a sample exception, of the first exception.\n" + "Breakdown of exceptions {type - count}: %s", context, exception.getNumExceptions(), exception.getMessage(), getFurtherInfo(exception)), exception.getCause(0)); }
int numErrors = e.getNumExceptions(); // co PutListErrorExample3-2-Error Handle failed operations. System.out.println("Number of exceptions: " + numErrors); for (int n = 0; n < numErrors; n++) { System.out.println("Cause[" + n + "]: " + e.getCause(n)); System.out.println("Hostname[" + n + "]: " + e.getHostnamePort(n)); System.out.println("Row[" + n + "]: " + e.getRow(n)); // co PutListErrorExample3-3-ErrorPut Gain access to the failed operation. System.out.println("Cluster issues: " + e.mayHaveClusterIssues()); System.out.println("Description: " + e.getExhaustiveDescription());
} catch (RetriesExhaustedWithDetailsException e) { LOG.info("Put done, exception caught: " + e.getClass()); Assert.assertEquals(1, e.getNumExceptions()); Assert.assertEquals(1, e.getCauses().size()); Assert.assertArrayEquals(ROW, e.getRow(0).getRow()); Throwable cause = ClientExceptionsUtil.findException(e.getCause(0)); Assert.assertNotNull(cause); Assert.assertTrue(cause instanceof RegionMovedException);
fail("Where is the exception? We put the malformed cells!!!"); } catch (RetriesExhaustedWithDetailsException e) { for (Throwable throwable : e.getCauses()) { assertNotNull(throwable); assertEquals(1, e.getNumExceptions()); exceptionByCaught = e.getCause(0);
/** * Do the changes and handle the pool * @param tableName table to insert into * @param allRows list of actions * @throws IOException */ private void batch(TableName tableName, Collection<List<Row>> allRows) throws IOException { if (allRows.isEmpty()) { return; } Connection connection = getConnection(); try (Table table = connection.getTable(tableName)) { for (List<Row> rows : allRows) { table.batch(rows, null); } } catch (RetriesExhaustedWithDetailsException rewde) { for (Throwable ex : rewde.getCauses()) { if (ex instanceof TableNotFoundException) { throw new TableNotFoundException("'" + tableName + "'"); } } throw rewde; } catch (InterruptedException ix) { throw (InterruptedIOException) new InterruptedIOException().initCause(ix); } }
RetriesExhaustedWithDetailsException retryException = (RetriesExhaustedWithDetailsException) exp; processException(retryException.getCause(0));
private void recordFailure(final Table table, final Put put, final long keyBase, final long start, IOException e) { failedKeySet.add(keyBase); String exceptionInfo; if (e instanceof RetriesExhaustedWithDetailsException) { RetriesExhaustedWithDetailsException aggEx = (RetriesExhaustedWithDetailsException) e; exceptionInfo = aggEx.getExhaustiveDescription(); } else { StringWriter stackWriter = new StringWriter(); PrintWriter pw = new PrintWriter(stackWriter); e.printStackTrace(pw); pw.flush(); exceptionInfo = StringUtils.stringifyException(e); } LOG.error("Failed to insert: " + keyBase + " after " + (System.currentTimeMillis() - start) + "ms; region information: " + getRegionDebugInfoSafe(table, put.getRow()) + "; errors: " + exceptionInfo); } }
private static void logExceptions(RetriesExhaustedWithDetailsException e) { System.out.println(e.getExhaustiveDescription()); Set<String> codes = new TreeSet<>(); Set<String> messages = new TreeSet<>(); for (Throwable e1 : e.getCauses()) { if (e1 instanceof StatusException) { StatusException statusException = (StatusException) e1; codes.add(statusException.getStatus().getCode().name()); messages.add(statusException.getMessage()); } } } }
public static String pluralize(Collection<?> c) { return pluralize(c.size()); }
public static void logRetriesExhaustedWithDetailsException( Logger log, String context, RetriesExhaustedWithDetailsException exception) { if (log.isDebugEnabled()) { log.error("For context {}: exception occured during a bulk operation: {}", context, exception.getExhaustiveDescription()); } if (exception.getNumExceptions() == 0) { log.error( "For context {}: Got a RetriesExhaustedWithDetailsException without any details.", exception); return; } log.error( String.format( "For context %s: %d exceptions occured during a bulk operation:\n\t%s.\n" + "The stack trace is a sample exception, of the first exception.\n" + "Breakdown of exceptions {type - count}: %s", context, exception.getNumExceptions(), exception.getMessage(), getFurtherInfo(exception)), exception.getCause(0)); }
fail("Where is the exception? We put the malformed cells!!!"); } catch (RetriesExhaustedWithDetailsException e) { for (Throwable throwable : e.getCauses()) { assertNotNull(throwable); assertEquals(1, e.getNumExceptions()); exceptionByCaught = e.getCause(0);
private static void assertError(AsyncRequestFuture arf, int expectedCountOfFailure) { assertTrue(arf.hasError()); RetriesExhaustedWithDetailsException e = arf.getErrors(); List<Throwable> errors = e.getCauses(); assertEquals(expectedCountOfFailure, errors.size()); for (Throwable t : errors) { assertTrue(t instanceof IOException); } }
public RetriesExhaustedWithDetailsException(List<Throwable> exceptions, List<Row> actions, List<String> hostnameAndPort) { super("Failed " + exceptions.size() + " action" + pluralize(exceptions) + ": " + getDesc(exceptions, actions, hostnameAndPort)); this.exceptions = exceptions; this.actions = actions; this.hostnameAndPort = hostnameAndPort; }