com.datastax.driver.core.exceptions.TruncateException Java Examples
The following examples show how to use
com.datastax.driver.core.exceptions.TruncateException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ErrorResultIntegrationTest.java From simulacron with Apache License 2.0 | 5 votes |
@Test public void testShouldReturnTruncateError() throws Exception { String message = "This is a truncate error"; server.prime(when(query).then(truncateError(message))); thrown.expect(TruncateException.class); thrown.expectMessage(message); query(); }
Example #2
Source File: CassandraUtils.java From titus-control-plane with Apache License 2.0 | 5 votes |
private static boolean truncateTableInternal(CommandContext context, String table) { PreparedStatement truncateStatement = context.getTargetSession().prepare( "TRUNCATE \"" + table + "\"" ); try { context.getTargetCassandraExecutor().executeUpdate(truncateStatement.bind()).toBlocking().firstOrDefault(null); } catch (TruncateException e) { // Check if the table is empty logger.info("Couldn't complete the truncate operation. Checking if the table is empty: {}", table); Pair<Object, Object> value = readTwoColumnTable(context.getTargetSession(), table).take(1).toBlocking().firstOrDefault(null); if (value == null) { // Truncate failed, but the table is empty. It is ok to move on. logger.info("Truncate deemed as successful, as the table is empty: {}", table); return true; } if (e.getMessage().contains("Cannot achieve consistency level ALL")) { logger.warn("Recoverable truncate operations for table {}. Cause: {}", table, e.getMessage()); return false; } // Not recoverable error. Re-throw it. throw e; } logger.info("Truncated table {}.{}", truncateStatement.getQueryKeyspace(), table); return true; }
Example #3
Source File: CassandraCqlMapState.java From storm-cassandra-cql with Apache License 2.0 | 5 votes |
protected void checkCassandraException(Exception e) { _mexceptions.incr(); if (e instanceof AlreadyExistsException || e instanceof AuthenticationException || e instanceof DriverException || e instanceof DriverInternalError || e instanceof InvalidConfigurationInQueryException || e instanceof InvalidQueryException || e instanceof InvalidTypeException || e instanceof QueryExecutionException || e instanceof QueryValidationException || e instanceof ReadTimeoutException || e instanceof SyntaxError || e instanceof TraceRetrievalException || e instanceof TruncateException || e instanceof UnauthorizedException || e instanceof UnavailableException || e instanceof ReadTimeoutException || e instanceof WriteTimeoutException || e instanceof ReadFailureException || e instanceof WriteFailureException || e instanceof FunctionExecutionException) { throw new ReportedFailedException(e); } else { throw new RuntimeException(e); } }