com.datastax.driver.core.exceptions.WriteTimeoutException Java Examples
The following examples show how to use
com.datastax.driver.core.exceptions.WriteTimeoutException.
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: InsertStatementHandlerTest.java From scalardb with Apache License 2.0 | 6 votes |
@Test public void handle_WTEWithCasThrown_ShouldThrowProperExecutionException() throws ExecutionException { // Arrange put = preparePutWithClusteringKey(); put.withCondition(new PutIfNotExists()); spy = prepareSpiedInsertStatementHandler(); WriteTimeoutException toThrow = mock(WriteTimeoutException.class); when(toThrow.getWriteType()).thenReturn(WriteType.CAS); doThrow(toThrow).when(spy).handleInternal(put); // Act Assert assertThatThrownBy( () -> { spy.handle(put); }) .isInstanceOf(RetriableExecutionException.class) .hasCause(toThrow); }
Example #2
Source File: InsertStatementHandlerTest.java From scalardb with Apache License 2.0 | 6 votes |
@Test public void handle_PutWithConditionGivenAndWTEWithSimpleThrown_ShouldThrowProperExecutionException() throws ExecutionException { // Arrange put = preparePutWithClusteringKey(); put.withCondition(new PutIfNotExists()); spy = prepareSpiedInsertStatementHandler(); WriteTimeoutException toThrow = mock(WriteTimeoutException.class); when(toThrow.getWriteType()).thenReturn(WriteType.SIMPLE); doThrow(toThrow).when(spy).handleInternal(put); // Act Assert assertThatThrownBy( () -> { spy.handle(put); }) .isInstanceOf(ReadRepairableExecutionException.class) .hasCause(toThrow); }
Example #3
Source File: InsertStatementHandlerTest.java From scalardb with Apache License 2.0 | 6 votes |
@Test public void handle_PutWithoutConditionGivenAndWTEWithSimpleThrown_ShouldThrowProperExecutionException() throws ExecutionException { // Arrange put = preparePutWithClusteringKey(); spy = prepareSpiedInsertStatementHandler(); WriteTimeoutException toThrow = mock(WriteTimeoutException.class); when(toThrow.getWriteType()).thenReturn(WriteType.SIMPLE); doThrow(toThrow).when(spy).handleInternal(put); // Act Assert assertThatThrownBy( () -> { spy.handle(put); }) .isInstanceOf(RetriableExecutionException.class) .hasCause(toThrow); }
Example #4
Source File: BatchHandlerTest.java From scalardb with Apache License 2.0 | 6 votes |
@Test public void handle_WTEThrownInLoggingInBatchExecution_ShouldThrowRetriableExecutionException() { // Arrange configureBehavior(); mutations = prepareConditionalPuts(); WriteTimeoutException e = mock(WriteTimeoutException.class); when(e.getWriteType()).thenReturn(WriteType.BATCH_LOG); when(session.execute(any(Statement.class))).thenThrow(e); // Act Assert assertThatThrownBy( () -> { batch.handle(mutations); }) .isInstanceOf(RetriableExecutionException.class) .hasCause(e); }
Example #5
Source File: BatchHandlerTest.java From scalardb with Apache License 2.0 | 6 votes |
@Test public void handle_WTEThrownInMutationInBatchExecution_ShouldExecuteProperly() { // Arrange configureBehavior(); mutations = prepareConditionalPuts(); WriteTimeoutException e = mock(WriteTimeoutException.class); when(e.getWriteType()).thenReturn(WriteType.BATCH); when(session.execute(any(Statement.class))).thenThrow(e); // Act Assert assertThatCode( () -> { batch.handle(mutations); }) .doesNotThrowAnyException(); }
Example #6
Source File: BatchHandlerTest.java From scalardb with Apache License 2.0 | 6 votes |
@Test public void handle_WTEThrownInCasInBatchExecution_ShouldThrowRetriableExecutionException() { // Arrange configureBehavior(); mutations = prepareConditionalPuts(); WriteTimeoutException e = mock(WriteTimeoutException.class); when(e.getWriteType()).thenReturn(WriteType.CAS); when(session.execute(any(Statement.class))).thenThrow(e); // Act Assert assertThatThrownBy( () -> { batch.handle(mutations); }) .isInstanceOf(RetriableExecutionException.class) .hasCause(e); }
Example #7
Source File: BatchHandlerTest.java From scalardb with Apache License 2.0 | 6 votes |
@Test public void handle_WTEThrownInSimpleWriteInBatchExecution_ShouldThrowRetriableExecutionException() { // Arrange configureBehavior(); mutations = prepareConditionalPuts(); WriteTimeoutException e = mock(WriteTimeoutException.class); when(e.getWriteType()).thenReturn(WriteType.SIMPLE); when(session.execute(any(Statement.class))).thenThrow(e); // Act Assert assertThatThrownBy( () -> { batch.handle(mutations); }) .isInstanceOf(RetriableExecutionException.class) .hasCause(e); }
Example #8
Source File: ErrorResultIntegrationTest.java From simulacron with Apache License 2.0 | 5 votes |
@Test public void testShouldReturnWriteTimeout() throws Exception { server.prime(when(query).then(writeTimeout(ConsistencyLevel.QUORUM, 3, 1, WriteType.BATCH))); thrown.expect(WriteTimeoutException.class); thrown.expect( match( (WriteTimeoutException wte) -> wte.getRequiredAcknowledgements() == 1 && wte.getReceivedAcknowledgements() == 3 && wte.getConsistencyLevel() == com.datastax.driver.core.ConsistencyLevel.QUORUM && wte.getWriteType() == com.datastax.driver.core.WriteType.BATCH)); query(); }
Example #9
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); } }