com.datastax.driver.core.exceptions.ReadTimeoutException Java Examples
The following examples show how to use
com.datastax.driver.core.exceptions.ReadTimeoutException.
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: QueryCassandraTest.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test public void testProcessorNoInputFlowFileAndExceptions() { setUpStandardProcessorConfig(); // Test no input flowfile testRunner.setIncomingConnection(false); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_SUCCESS, 1); testRunner.clearTransferState(); // Test exceptions processor.setExceptionToThrow(new NoHostAvailableException(new HashMap<InetSocketAddress, Throwable>())); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_RETRY, 1); testRunner.clearTransferState(); processor.setExceptionToThrow( new ReadTimeoutException(new InetSocketAddress("localhost", 9042), ConsistencyLevel.ANY, 0, 1, false)); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_RETRY, 1); testRunner.clearTransferState(); processor.setExceptionToThrow( new InvalidQueryException(new InetSocketAddress("localhost", 9042), "invalid query")); testRunner.run(1, true, true); // No files transferred to failure if there was no incoming connection testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_FAILURE, 0); testRunner.clearTransferState(); processor.setExceptionToThrow(new ProcessException()); testRunner.run(1, true, true); // No files transferred to failure if there was no incoming connection testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_FAILURE, 0); testRunner.clearTransferState(); processor.setExceptionToThrow(null); }
Example #2
Source File: QueryCassandraTest.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test public void testProcessorEmptyFlowFileAndExceptions() { setUpStandardProcessorConfig(); // Run with empty flowfile testRunner.setIncomingConnection(true); processor.setExceptionToThrow(null); testRunner.enqueue("".getBytes()); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_SUCCESS, 1); testRunner.clearTransferState(); // Test exceptions processor.setExceptionToThrow(new NoHostAvailableException(new HashMap<InetSocketAddress, Throwable>())); testRunner.enqueue("".getBytes()); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_RETRY, 1); testRunner.clearTransferState(); processor.setExceptionToThrow( new ReadTimeoutException(new InetSocketAddress("localhost", 9042), ConsistencyLevel.ANY, 0, 1, false)); testRunner.enqueue("".getBytes()); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_RETRY, 1); testRunner.clearTransferState(); processor.setExceptionToThrow( new InvalidQueryException(new InetSocketAddress("localhost", 9042), "invalid query")); testRunner.enqueue("".getBytes()); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_FAILURE, 1); testRunner.clearTransferState(); processor.setExceptionToThrow(new ProcessException()); testRunner.enqueue("".getBytes()); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_FAILURE, 1); }
Example #3
Source File: ErrorResultIntegrationTest.java From simulacron with Apache License 2.0 | 5 votes |
@Test public void testShouldReturnReadTimeout() throws Exception { server.prime(when(query).then(readTimeout(ConsistencyLevel.TWO, 1, 2, false))); thrown.expect(ReadTimeoutException.class); thrown.expect( match( (ReadTimeoutException rte) -> rte.getRequiredAcknowledgements() == 2 && rte.getReceivedAcknowledgements() == 1 && !rte.wasDataRetrieved() && rte.getConsistencyLevel() == com.datastax.driver.core.ConsistencyLevel.TWO)); query(); }
Example #4
Source File: CassandraHelper.java From ignite with Apache License 2.0 | 5 votes |
/** * Checks if Cassandra host availability error occur, thus host became unavailable. * * @param e Exception to check. * @return {@code true} in case of host not available error. */ public static boolean isHostsAvailabilityError(Throwable e) { while (e != null) { if (e instanceof NoHostAvailableException || e instanceof ReadTimeoutException) return true; e = e.getCause(); } return false; }
Example #5
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); } }
Example #6
Source File: QueryCassandraTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testProcessorNoInputFlowFileAndExceptions() { setUpStandardProcessorConfig(); // Test no input flowfile testRunner.setIncomingConnection(false); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_SUCCESS, 1); testRunner.clearTransferState(); // Test exceptions processor.setExceptionToThrow(new NoHostAvailableException(new HashMap<InetSocketAddress, Throwable>())); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_RETRY, 1); testRunner.clearTransferState(); processor.setExceptionToThrow( new ReadTimeoutException(new InetSocketAddress("localhost", 9042), ConsistencyLevel.ANY, 0, 1, false)); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_RETRY, 1); testRunner.clearTransferState(); processor.setExceptionToThrow( new InvalidQueryException(new InetSocketAddress("localhost", 9042), "invalid query")); testRunner.run(1, true, true); // No files transferred to failure if there was no incoming connection testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_FAILURE, 0); testRunner.clearTransferState(); processor.setExceptionToThrow(new ProcessException()); testRunner.run(1, true, true); // No files transferred to failure if there was no incoming connection testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_FAILURE, 0); testRunner.clearTransferState(); processor.setExceptionToThrow(null); }
Example #7
Source File: QueryCassandraTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testProcessorEmptyFlowFileAndExceptions() { setUpStandardProcessorConfig(); // Run with empty flowfile testRunner.setIncomingConnection(true); processor.setExceptionToThrow(null); testRunner.enqueue("".getBytes()); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_SUCCESS, 1); testRunner.clearTransferState(); // Test exceptions processor.setExceptionToThrow(new NoHostAvailableException(new HashMap<InetSocketAddress, Throwable>())); testRunner.enqueue("".getBytes()); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_RETRY, 1); testRunner.clearTransferState(); processor.setExceptionToThrow( new ReadTimeoutException(new InetSocketAddress("localhost", 9042), ConsistencyLevel.ANY, 0, 1, false)); testRunner.enqueue("".getBytes()); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_RETRY, 1); testRunner.clearTransferState(); processor.setExceptionToThrow( new InvalidQueryException(new InetSocketAddress("localhost", 9042), "invalid query")); testRunner.enqueue("".getBytes()); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_FAILURE, 1); testRunner.clearTransferState(); processor.setExceptionToThrow(new ProcessException()); testRunner.enqueue("".getBytes()); testRunner.run(1, true, true); testRunner.assertAllFlowFilesTransferred(QueryCassandra.REL_FAILURE, 1); }