com.datastax.driver.core.exceptions.UnavailableException Java Examples

The following examples show how to use com.datastax.driver.core.exceptions.UnavailableException. 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: PutCassandraQLTest.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessorUnavailableException() {
    setUpStandardTestConfig();

    processor.setExceptionToThrow(
            new UnavailableException(new InetSocketAddress("localhost", 9042), ConsistencyLevel.ALL, 5, 2));
    testRunner.enqueue("UPDATE users SET cities = [ 'New York', 'Los Angeles' ] WHERE user_id = 'coast2coast';");
    testRunner.run(1, true, true);
    testRunner.assertAllFlowFilesTransferred(PutCassandraQL.REL_RETRY, 1);
}
 
Example #2
Source File: ErrorResultIntegrationTest.java    From simulacron with Apache License 2.0 5 votes vote down vote up
@Test
public void testShouldReturnUnavailable() throws Exception {
  server.prime(when(query).then(unavailable(ConsistencyLevel.ALL, 5, 1)));

  thrown.expect(UnavailableException.class);
  thrown.expect(
      match(
          (UnavailableException uae) ->
              uae.getAliveReplicas() == 1
                  && uae.getRequiredReplicas() == 5
                  && uae.getConsistencyLevel() == com.datastax.driver.core.ConsistencyLevel.ALL));
  query();
}
 
Example #3
Source File: CassandraCqlMapState.java    From storm-cassandra-cql with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #4
Source File: PutCassandraQLTest.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessorUnavailableException() {
    setUpStandardTestConfig();

    processor.setExceptionToThrow(
            new UnavailableException(new InetSocketAddress("localhost", 9042), ConsistencyLevel.ALL, 5, 2));
    testRunner.enqueue("UPDATE users SET cities = [ 'New York', 'Los Angeles' ] WHERE user_id = 'coast2coast';");
    testRunner.run(1, true, true);
    testRunner.assertAllFlowFilesTransferred(PutCassandraQL.REL_RETRY, 1);
}