Search in sources :

Example 1 with ContinuousCqlRequestAsyncProcessor

use of com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestAsyncProcessor in project java-driver by datastax.

the class ContinuousCqlRequestReactiveProcessorTest method should_complete_single_page_result.

@Test
@UseDataProvider(value = "allDseProtocolVersions", location = DseTestDataProviders.class)
public void should_complete_single_page_result(DseProtocolVersion version) {
    try (RequestHandlerTestHarness harness = continuousHarnessBuilder().withProtocolVersion(version).withResponse(node1, defaultFrameOf(DseTestFixtures.singleDseRow())).build()) {
        DefaultSession session = harness.getSession();
        InternalDriverContext context = harness.getContext();
        ContinuousReactiveResultSet publisher = new ContinuousCqlRequestReactiveProcessor(new ContinuousCqlRequestAsyncProcessor()).process(UNDEFINED_IDEMPOTENCE_STATEMENT, session, context, "test");
        List<ReactiveRow> rows = Flowable.fromPublisher(publisher).toList().blockingGet();
        assertThat(rows).hasSize(1);
        ReactiveRow row = rows.get(0);
        assertThat(row.getString("message")).isEqualTo("hello, world");
        ExecutionInfo executionInfo = row.getExecutionInfo();
        assertThat(executionInfo.getCoordinator()).isEqualTo(node1);
        assertThat(executionInfo.getErrors()).isEmpty();
        assertThat(executionInfo.getIncomingPayload()).isEmpty();
        assertThat(executionInfo.getPagingState()).isNull();
        assertThat(executionInfo.getSpeculativeExecutionCount()).isEqualTo(0);
        assertThat(executionInfo.getSuccessfulExecutionIndex()).isEqualTo(0);
        assertThat(executionInfo.getWarnings()).isEmpty();
        Flowable<ExecutionInfo> execInfosFlowable = Flowable.fromPublisher(publisher.getExecutionInfos());
        assertThat(execInfosFlowable.toList().blockingGet()).containsExactly(executionInfo);
        Flowable<ColumnDefinitions> colDefsFlowable = Flowable.fromPublisher(publisher.getColumnDefinitions());
        assertThat(colDefsFlowable.toList().blockingGet()).containsExactly(row.getColumnDefinitions());
        Flowable<Boolean> wasAppliedFlowable = Flowable.fromPublisher(publisher.wasApplied());
        assertThat(wasAppliedFlowable.toList().blockingGet()).containsExactly(row.wasApplied());
    }
}
Also used : ContinuousCqlRequestAsyncProcessor(com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestAsyncProcessor) ColumnDefinitions(com.datastax.oss.driver.api.core.cql.ColumnDefinitions) RequestHandlerTestHarness(com.datastax.oss.driver.internal.core.cql.RequestHandlerTestHarness) ExecutionInfo(com.datastax.oss.driver.api.core.cql.ExecutionInfo) ReactiveRow(com.datastax.dse.driver.api.core.cql.reactive.ReactiveRow) ContinuousReactiveResultSet(com.datastax.dse.driver.api.core.cql.continuous.reactive.ContinuousReactiveResultSet) InternalDriverContext(com.datastax.oss.driver.internal.core.context.InternalDriverContext) DefaultSession(com.datastax.oss.driver.internal.core.session.DefaultSession) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 2 with ContinuousCqlRequestAsyncProcessor

use of com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestAsyncProcessor in project java-driver by datastax.

the class ContinuousCqlRequestReactiveProcessorTest method should_be_able_to_process_reactive_result_set.

@Test
public void should_be_able_to_process_reactive_result_set() {
    ContinuousCqlRequestReactiveProcessor processor = new ContinuousCqlRequestReactiveProcessor(new ContinuousCqlRequestAsyncProcessor());
    assertThat(processor.canProcess(UNDEFINED_IDEMPOTENCE_STATEMENT, ContinuousCqlRequestReactiveProcessor.CONTINUOUS_REACTIVE_RESULT_SET)).isTrue();
}
Also used : ContinuousCqlRequestAsyncProcessor(com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestAsyncProcessor) Test(org.junit.Test)

Example 3 with ContinuousCqlRequestAsyncProcessor

use of com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestAsyncProcessor in project java-driver by datastax.

the class ContinuousCqlRequestReactiveProcessorTest method should_complete_multi_page_result.

@Test
@UseDataProvider(value = "allDseProtocolVersions", location = DseTestDataProviders.class)
public void should_complete_multi_page_result(DseProtocolVersion version) {
    RequestHandlerTestHarness.Builder builder = continuousHarnessBuilder().withProtocolVersion(version);
    PoolBehavior node1Behavior = builder.customBehavior(node1);
    try (RequestHandlerTestHarness harness = builder.build()) {
        DefaultSession session = harness.getSession();
        InternalDriverContext context = harness.getContext();
        ContinuousReactiveResultSet publisher = new ContinuousCqlRequestReactiveProcessor(new ContinuousCqlRequestAsyncProcessor()).process(UNDEFINED_IDEMPOTENCE_STATEMENT, session, context, "test");
        Flowable<ReactiveRow> rowsPublisher = Flowable.fromPublisher(publisher).cache();
        rowsPublisher.subscribe();
        node1Behavior.setResponseSuccess(defaultFrameOf(DseTestFixtures.tenDseRows(1, false)));
        node1Behavior.setResponseSuccess(defaultFrameOf(DseTestFixtures.tenDseRows(2, true)));
        List<ReactiveRow> rows = rowsPublisher.toList().blockingGet();
        assertThat(rows).hasSize(20);
        ReactiveRow first = rows.get(0);
        ExecutionInfo firstExecutionInfo = first.getExecutionInfo();
        assertThat(firstExecutionInfo.getCoordinator()).isEqualTo(node1);
        assertThat(firstExecutionInfo.getErrors()).isEmpty();
        assertThat(firstExecutionInfo.getIncomingPayload()).isEmpty();
        assertThat(firstExecutionInfo.getPagingState()).isNotNull();
        assertThat(firstExecutionInfo.getSpeculativeExecutionCount()).isEqualTo(0);
        assertThat(firstExecutionInfo.getSuccessfulExecutionIndex()).isEqualTo(0);
        assertThat(firstExecutionInfo.getWarnings()).isEmpty();
        ReactiveRow inSecondPage = rows.get(10);
        ExecutionInfo secondExecutionInfo = inSecondPage.getExecutionInfo();
        assertThat(secondExecutionInfo.getCoordinator()).isEqualTo(node1);
        assertThat(secondExecutionInfo.getErrors()).isEmpty();
        assertThat(secondExecutionInfo.getIncomingPayload()).isEmpty();
        assertThat(secondExecutionInfo.getPagingState()).isNull();
        assertThat(secondExecutionInfo.getSpeculativeExecutionCount()).isEqualTo(0);
        assertThat(secondExecutionInfo.getSuccessfulExecutionIndex()).isEqualTo(0);
        assertThat(secondExecutionInfo.getWarnings()).isEmpty();
        Flowable<ExecutionInfo> execInfosFlowable = Flowable.fromPublisher(publisher.getExecutionInfos());
        assertThat(execInfosFlowable.toList().blockingGet()).containsExactly(firstExecutionInfo, secondExecutionInfo);
        Flowable<ColumnDefinitions> colDefsFlowable = Flowable.fromPublisher(publisher.getColumnDefinitions());
        assertThat(colDefsFlowable.toList().blockingGet()).containsExactly(first.getColumnDefinitions());
        Flowable<Boolean> wasAppliedFlowable = Flowable.fromPublisher(publisher.wasApplied());
        assertThat(wasAppliedFlowable.toList().blockingGet()).containsExactly(first.wasApplied());
    }
}
Also used : ContinuousCqlRequestAsyncProcessor(com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestAsyncProcessor) ColumnDefinitions(com.datastax.oss.driver.api.core.cql.ColumnDefinitions) PoolBehavior(com.datastax.oss.driver.internal.core.cql.PoolBehavior) RequestHandlerTestHarness(com.datastax.oss.driver.internal.core.cql.RequestHandlerTestHarness) ExecutionInfo(com.datastax.oss.driver.api.core.cql.ExecutionInfo) ReactiveRow(com.datastax.dse.driver.api.core.cql.reactive.ReactiveRow) ContinuousReactiveResultSet(com.datastax.dse.driver.api.core.cql.continuous.reactive.ContinuousReactiveResultSet) InternalDriverContext(com.datastax.oss.driver.internal.core.context.InternalDriverContext) DefaultSession(com.datastax.oss.driver.internal.core.session.DefaultSession) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 4 with ContinuousCqlRequestAsyncProcessor

use of com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestAsyncProcessor in project java-driver by datastax.

the class ContinuousCqlRequestReactiveProcessorTest method should_create_request_handler.

@Test
public void should_create_request_handler() {
    RequestHandlerTestHarness.Builder builder = continuousHarnessBuilder().withProtocolVersion(DSE_V1);
    try (RequestHandlerTestHarness harness = builder.build()) {
        ContinuousCqlRequestReactiveProcessor processor = new ContinuousCqlRequestReactiveProcessor(new ContinuousCqlRequestAsyncProcessor());
        assertThat(processor.process(UNDEFINED_IDEMPOTENCE_STATEMENT, harness.getSession(), harness.getContext(), "test")).isInstanceOf(DefaultContinuousReactiveResultSet.class);
    }
}
Also used : ContinuousCqlRequestAsyncProcessor(com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestAsyncProcessor) RequestHandlerTestHarness(com.datastax.oss.driver.internal.core.cql.RequestHandlerTestHarness) Test(org.junit.Test)

Example 5 with ContinuousCqlRequestAsyncProcessor

use of com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestAsyncProcessor in project java-driver by datastax.

the class BuiltInRequestProcessors method addReactiveProcessors.

public static void addReactiveProcessors(List<RequestProcessor<?, ?>> processors) {
    CqlRequestReactiveProcessor cqlRequestReactiveProcessor = new CqlRequestReactiveProcessor(new CqlRequestAsyncProcessor());
    ContinuousCqlRequestReactiveProcessor continuousCqlRequestReactiveProcessor = new ContinuousCqlRequestReactiveProcessor(new ContinuousCqlRequestAsyncProcessor());
    processors.add(cqlRequestReactiveProcessor);
    processors.add(continuousCqlRequestReactiveProcessor);
}
Also used : ContinuousCqlRequestAsyncProcessor(com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestAsyncProcessor) ContinuousCqlRequestReactiveProcessor(com.datastax.dse.driver.internal.core.cql.continuous.reactive.ContinuousCqlRequestReactiveProcessor) ContinuousCqlRequestReactiveProcessor(com.datastax.dse.driver.internal.core.cql.continuous.reactive.ContinuousCqlRequestReactiveProcessor) CqlRequestReactiveProcessor(com.datastax.dse.driver.internal.core.cql.reactive.CqlRequestReactiveProcessor) CqlRequestAsyncProcessor(com.datastax.oss.driver.internal.core.cql.CqlRequestAsyncProcessor) ContinuousCqlRequestAsyncProcessor(com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestAsyncProcessor)

Aggregations

ContinuousCqlRequestAsyncProcessor (com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestAsyncProcessor)6 Test (org.junit.Test)4 RequestHandlerTestHarness (com.datastax.oss.driver.internal.core.cql.RequestHandlerTestHarness)3 ContinuousReactiveResultSet (com.datastax.dse.driver.api.core.cql.continuous.reactive.ContinuousReactiveResultSet)2 ReactiveRow (com.datastax.dse.driver.api.core.cql.reactive.ReactiveRow)2 ColumnDefinitions (com.datastax.oss.driver.api.core.cql.ColumnDefinitions)2 ExecutionInfo (com.datastax.oss.driver.api.core.cql.ExecutionInfo)2 InternalDriverContext (com.datastax.oss.driver.internal.core.context.InternalDriverContext)2 CqlRequestAsyncProcessor (com.datastax.oss.driver.internal.core.cql.CqlRequestAsyncProcessor)2 DefaultSession (com.datastax.oss.driver.internal.core.session.DefaultSession)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 ContinuousCqlRequestSyncProcessor (com.datastax.dse.driver.internal.core.cql.continuous.ContinuousCqlRequestSyncProcessor)1 ContinuousCqlRequestReactiveProcessor (com.datastax.dse.driver.internal.core.cql.continuous.reactive.ContinuousCqlRequestReactiveProcessor)1 CqlRequestReactiveProcessor (com.datastax.dse.driver.internal.core.cql.reactive.CqlRequestReactiveProcessor)1 CqlPrepareAsyncProcessor (com.datastax.oss.driver.internal.core.cql.CqlPrepareAsyncProcessor)1 CqlPrepareSyncProcessor (com.datastax.oss.driver.internal.core.cql.CqlPrepareSyncProcessor)1 CqlRequestSyncProcessor (com.datastax.oss.driver.internal.core.cql.CqlRequestSyncProcessor)1 PoolBehavior (com.datastax.oss.driver.internal.core.cql.PoolBehavior)1