/** * 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); } }
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); } }
fail("Where is the exception? We put the malformed cells!!!"); } catch (RetriesExhaustedWithDetailsException e) { for (Throwable throwable : e.getCauses()) { assertNotNull(throwable);
fail("Expected NoSuchColumnFamilyException"); } catch(RetriesExhaustedWithDetailsException e) { for(Throwable rootCause: e.getCauses()){ if(rootCause instanceof NoSuchColumnFamilyException){ return;
for(Throwable ex : ((RetriesExhaustedWithDetailsException) e).getCauses()) { if (ex instanceof AccessDeniedException) { isAccessDeniedException = true;
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());
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); } }
@Override public <T extends Exception> T handle(@Nonnull T exception) throws T { if (exception instanceof TableNotFoundException) { tableDescriptors.remove(tableId); } else if (exception instanceof RetriesExhaustedWithDetailsException) { for (Throwable cause : ((RetriesExhaustedWithDetailsException) exception).getCauses()) { if (cause instanceof TableNotFoundException) { tableDescriptors.remove(tableId); break; } } } throw exception; }
@Override public <T extends Exception> T handle(@Nonnull T exception) throws T { if (exception instanceof TableNotFoundException) { tableDescriptors.remove(tableId); } else if (exception instanceof RetriesExhaustedWithDetailsException) { for (Throwable cause : ((RetriesExhaustedWithDetailsException) exception).getCauses()) { if (cause instanceof TableNotFoundException) { tableDescriptors.remove(tableId); break; } } } throw exception; }
protected static void rethrowException(RetriesExhaustedWithDetailsException exception) throws Exception { if (exception.getCauses().size() == 1) { throw (Exception) exception.getCause(0); } else { throw exception; } }
protected static void rethrowException(RetriesExhaustedWithDetailsException exception) throws Exception { if (exception.getCauses().size() == 1) { throw (Exception) exception.getCause(0); } else { throw exception; } }
protected static void rethrowException(RetriesExhaustedWithDetailsException exception) throws Exception { if (exception.getCauses().size() == 1) { throw (Exception) exception.getCause(0); } else { throw exception; } }
private static Map<String, Integer> getFurtherInfo( RetriesExhaustedWithDetailsException exception) { Map<String, Integer> furtherInfo = new TreeMap<>(); try { List<Throwable> causes = exception.getCauses(); for (Throwable throwable : causes) { String message = throwable.getClass().getName() + ": " + throwable.getMessage(); Integer count = furtherInfo.get(message); if (count == null) { furtherInfo.put(message, 1); } else { furtherInfo.put(message, 1 + count); } } } catch (Throwable t) { // Don't fail just because information gathering failed. } return furtherInfo; }
private static Map<String, Integer> getFurtherInfo( RetriesExhaustedWithDetailsException exception) { Map<String, Integer> furtherInfo = new TreeMap<>(); try { List<Throwable> causes = exception.getCauses(); for (Throwable throwable : causes) { String message = throwable.getClass().getName() + ": " + throwable.getMessage(); Integer count = furtherInfo.get(message); if (count == null) { furtherInfo.put(message, 1); } else { furtherInfo.put(message, 1 + count); } } } catch (Throwable t) { // Don't fail just because information gathering failed. } return furtherInfo; }
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()); } } } }
/** Closes the {@link BufferedMutator} and {@link Connection}. */ @FinishBundle public synchronized void finishBundle(@SuppressWarnings("unused") FinishBundleContext context) throws Exception { try { if (mutator != null) { mutator.close(); mutator = null; } } catch (RetriesExhaustedWithDetailsException exception) { exceptionsCounter.inc(exception.getCauses().size()); logExceptions(null, exception); rethrowException(exception); } } }
/** Closes the {@link BufferedMutator} and {@link Connection}. */ @FinishBundle public synchronized void finishBundle(@SuppressWarnings("unused") FinishBundleContext context) throws Exception { try { if (mutator != null) { mutator.close(); mutator = null; } } catch (RetriesExhaustedWithDetailsException exception) { exceptionsCounter.inc(exception.getCauses().size()); logExceptions(null, exception); rethrowException(exception); } } }
/** * Closes the {@link BufferedMutator} and {@link Connection}. */ @Override public synchronized void finishBundle(Context context) throws Exception { try { if (mutator != null) { mutator.close(); mutator = null; } } catch (RetriesExhaustedWithDetailsException exception) { exceptionsCounter.addValue((long) exception.getCauses().size()); logExceptions(context, exception); rethrowException(exception); } finally { // Close the connection to clean up resources. super.finishBundle(context); } } }
fail("Where is the exception? We put the malformed cells!!!"); } catch (RetriesExhaustedWithDetailsException e) { for (Throwable throwable : e.getCauses()) { assertNotNull(throwable);
fail("Expected NoSuchColumnFamilyException"); } catch(RetriesExhaustedWithDetailsException e) { for(Throwable rootCause: e.getCauses()){ if(rootCause instanceof NoSuchColumnFamilyException){ return;