use of org.opendaylight.mdsal.binding.api.query.QueryResult in project mdsal by opendaylight.
the class QueryPerformanceTest method queryLessThanAlarm.
@Test
public void queryLessThanAlarm() throws InterruptedException, ExecutionException {
final String needle = "alias" + (SYSTEM_COUNT - 1);
final Stopwatch sw = Stopwatch.createStarted();
final QueryExpression<System> query = factory.querySubtree(InstanceIdentifier.create(Foo.class)).extractChild(System.class).matching().leaf(System::getAlias).valueEquals(needle).build();
LOG.info("Query built in {}", sw);
sw.reset().start();
final FluentFuture<QueryResult<@NonNull System>> future;
try (ReadTransaction rtx = getDataBroker().newReadOnlyTransaction()) {
assertThat(rtx, instanceOf(QueryReadTransaction.class));
future = ((QueryReadTransaction) rtx).execute(LogicalDatastoreType.CONFIGURATION, query);
}
final QueryResult<@NonNull System> result = future.get();
LOG.info("Query executed {} in {}", future, sw);
assertTrue(result.stream().findAny().isPresent());
LOG.info("Query result in {}", sw);
}
Aggregations