use of org.apache.rya.streams.api.queries.QueryChangeLog.QueryChangeLogException in project incubator-rya by apache.
the class KafkaQueryChangeLogIT method readFromPosition_positionStartsEnd.
@Test
public void readFromPosition_positionStartsEnd() throws Exception {
write10ChangesToChangeLog();
// set the position to some non-0 position
final TopicPartition partition = new TopicPartition(topic, 0);
consumer.assign(Lists.newArrayList(partition));
consumer.seekToEnd(Lists.newArrayList(partition));
final CloseableIteration<ChangeLogEntry<QueryChange>, QueryChangeLogException> iter = changeLog.readFromPosition(10L);
int count = 0;
while (iter.hasNext()) {
// should be empty
iter.next();
count++;
}
assertEquals(0, count);
}
use of org.apache.rya.streams.api.queries.QueryChangeLog.QueryChangeLogException in project incubator-rya by apache.
the class InMemoryQueryRepository method add.
@Override
public StreamsQuery add(final String query, final boolean isActive, final boolean isInsert) throws QueryRepositoryException, IllegalStateException {
requireNonNull(query);
lock.lock();
try {
checkState();
// First record the change to the log.
final UUID queryId = UUID.randomUUID();
final QueryChange change = QueryChange.create(queryId, query, isActive, isInsert);
changeLog.write(change);
// Update the cache to represent what is currently in the log.
updateCache();
// Return the StreamsQuery that represents the just added query.
return queriesCache.get(queryId);
} catch (final QueryChangeLogException e) {
throw new QueryRepositoryException("Could not create a Rya Streams query for the SPARQL string: " + query, e);
} finally {
lock.unlock();
}
}
Aggregations