Search in sources :

Example 6 with QueryChangeLogException

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);
}
Also used : QueryChangeLogException(org.apache.rya.streams.api.queries.QueryChangeLog.QueryChangeLogException) TopicPartition(org.apache.kafka.common.TopicPartition) ChangeLogEntry(org.apache.rya.streams.api.queries.ChangeLogEntry) Test(org.junit.Test)

Example 7 with QueryChangeLogException

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();
    }
}
Also used : QueryChangeLogException(org.apache.rya.streams.api.queries.QueryChangeLog.QueryChangeLogException) UUID(java.util.UUID)

Aggregations

QueryChangeLogException (org.apache.rya.streams.api.queries.QueryChangeLog.QueryChangeLogException)7 Test (org.junit.Test)5 TopicPartition (org.apache.kafka.common.TopicPartition)4 ChangeLogEntry (org.apache.rya.streams.api.queries.ChangeLogEntry)4 ArrayList (java.util.ArrayList)3 QueryChange (org.apache.rya.streams.api.queries.QueryChange)3 UUID (java.util.UUID)2 CloseableIteration (info.aduna.iteration.CloseableIteration)1 StreamsQuery (org.apache.rya.streams.api.entity.StreamsQuery)1