use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class GraphPagingIT method synchronous_paging_with_options.
@UseDataProvider(location = ContinuousPagingITBase.class, value = "pagingOptions")
@Test
public void synchronous_paging_with_options(Options options) {
// given
DriverExecutionProfile profile = enableGraphPaging(options, PagingEnabledOptions.ENABLED);
if (options.sizeInBytes) {
// Page sizes in bytes are not supported with graph queries
return;
}
// when
GraphResultSet result = SESSION_RULE.session().execute(ScriptGraphStatement.newInstance("g.V().hasLabel('person').values('name')").setGraphName(SESSION_RULE.getGraphName()).setTraversalSource("g").setExecutionProfile(profile));
// then
List<GraphNode> nodes = result.all();
assertThat(((CountingIterator) result.iterator()).remaining()).isZero();
assertThat(nodes).hasSize(options.expectedRows);
for (int i = 1; i <= nodes.size(); i++) {
GraphNode node = nodes.get(i - 1);
assertThat(node.asString()).isEqualTo("user" + i);
}
assertThat(result.getRequestExecutionInfo()).isNotNull();
assertThat(result.getRequestExecutionInfo().getCoordinator().getEndPoint().resolve()).isEqualTo(firstCcmNode());
assertIfMultiPage(result, options.expectedPages);
validateMetrics(SESSION_RULE.session());
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class GraphPagingIT method asynchronous_options_with_paging_disabled_should_fallback_to_single_page.
@UseDataProvider(location = ContinuousPagingITBase.class, value = "pagingOptions")
@Test
public void asynchronous_options_with_paging_disabled_should_fallback_to_single_page(Options options) throws ExecutionException, InterruptedException {
// given
DriverExecutionProfile profile = enableGraphPaging(options, PagingEnabledOptions.DISABLED);
if (options.sizeInBytes) {
// Page sizes in bytes are not supported with graph queries
return;
}
// when
CompletionStage<AsyncGraphResultSet> result = SESSION_RULE.session().executeAsync(ScriptGraphStatement.newInstance("g.V().hasLabel('person').values('name')").setGraphName(SESSION_RULE.getGraphName()).setTraversalSource("g").setExecutionProfile(profile));
// then
AsyncGraphResultSet asyncGraphResultSet = result.toCompletableFuture().get();
for (int i = 1; i <= 100; i++, asyncGraphResultSet.remaining()) {
GraphNode node = asyncGraphResultSet.one();
assertThat(node.asString()).isEqualTo("user" + i);
}
assertThat(asyncGraphResultSet.remaining()).isEqualTo(0);
validateMetrics(SESSION_RULE.session());
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class GraphPagingIT method should_cancel_result_set.
@Test
public void should_cancel_result_set() {
// given
DriverExecutionProfile profile = enableGraphPaging().withInt(DseDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_ENQUEUED_PAGES, 1).withInt(DseDriverOption.GRAPH_CONTINUOUS_PAGING_PAGE_SIZE, 10);
// when
GraphStatement statement = ScriptGraphStatement.newInstance("g.V().hasLabel('person').values('name')").setGraphName(SESSION_RULE.getGraphName()).setTraversalSource("g").setExecutionProfile(profile);
MultiPageGraphResultSet results = (MultiPageGraphResultSet) SESSION_RULE.session().execute(statement);
assertThat(((MultiPageGraphResultSet.RowIterator) results.iterator()).isCancelled()).isFalse();
assertThat(((CountingIterator) results.iterator()).remaining()).isEqualTo(10);
results.cancel();
assertThat(((MultiPageGraphResultSet.RowIterator) results.iterator()).isCancelled()).isTrue();
assertThat(((CountingIterator) results.iterator()).remaining()).isEqualTo(10);
for (int i = 0; i < 10; i++) {
results.one();
}
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class GraphPagingIT method asynchronous_paging_with_options_when_auto.
@UseDataProvider(location = ContinuousPagingITBase.class, value = "pagingOptions")
@Test
public void asynchronous_paging_with_options_when_auto(Options options) throws ExecutionException, InterruptedException {
// given
DriverExecutionProfile profile = enableGraphPaging(options, PagingEnabledOptions.AUTO);
if (options.sizeInBytes) {
// Page sizes in bytes are not supported with graph queries
return;
}
// when
CompletionStage<AsyncGraphResultSet> result = SESSION_RULE.session().executeAsync(ScriptGraphStatement.newInstance("g.V().hasLabel('person').values('name')").setGraphName(SESSION_RULE.getGraphName()).setTraversalSource("g").setExecutionProfile(profile));
// then
checkAsyncResult(result, options, 0, 1, new ArrayList<>());
validateMetrics(SESSION_RULE.session());
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class GraphPagingIT method should_trigger_global_timeout_sync_from_config.
@Test
public void should_trigger_global_timeout_sync_from_config() {
// given
Duration timeout = Duration.ofMillis(100);
DriverExecutionProfile profile = enableGraphPaging().withDuration(DseDriverOption.GRAPH_TIMEOUT, timeout);
// when
try {
CCM_RULE.getCcmBridge().pause(1);
try {
SESSION_RULE.session().execute(ScriptGraphStatement.newInstance("g.V().hasLabel('person').values('name')").setGraphName(SESSION_RULE.getGraphName()).setTraversalSource("g").setExecutionProfile(profile));
fail("Expecting DriverTimeoutException");
} catch (DriverTimeoutException e) {
assertThat(e).hasMessage("Query timed out after " + timeout);
}
} finally {
CCM_RULE.getCcmBridge().resume(1);
}
}
Aggregations