use of org.apache.rya.streams.api.queries.QueryChange in project incubator-rya by apache.
the class KafkaQueryChangeLogIT method readFromPosition_positionStartsNotBegining.
@Test
public void readFromPosition_positionStartsNotBegining() throws Exception {
final List<QueryChange> expected = write10ChangesToChangeLog().subList(5, 10);
// 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(5L);
final List<QueryChange> actual = new ArrayList<>();
while (iter.hasNext()) {
final ChangeLogEntry<QueryChange> entry = iter.next();
actual.add(entry.getEntry());
}
assertEquals(expected, actual);
}
use of org.apache.rya.streams.api.queries.QueryChange in project incubator-rya by apache.
the class KafkaQueryChangeLogIT method testWrite.
@Test
public void testWrite() throws Exception {
final String sparql = "SOME QUERY HERE";
final UUID uuid = UUID.randomUUID();
final QueryChange newChange = QueryChange.create(uuid, sparql, true, false);
changeLog.write(newChange);
consumer.subscribe(Lists.newArrayList(topic));
final ConsumerRecords<?, QueryChange> records = consumer.poll(2000);
assertEquals(1, records.count());
final QueryChange record = records.iterator().next().value();
assertEquals(newChange, record);
}
use of org.apache.rya.streams.api.queries.QueryChange in project incubator-rya by apache.
the class KafkaQueryChangeLogIT method readFromBegining_positionStartsNotBegining.
@Test
public void readFromBegining_positionStartsNotBegining() throws Exception {
final List<QueryChange> expected = write10ChangesToChangeLog();
// set the position to some non-0 position
final TopicPartition partition = new TopicPartition(topic, 0);
consumer.assign(Lists.newArrayList(partition));
consumer.seek(partition, 5L);
final CloseableIteration<ChangeLogEntry<QueryChange>, QueryChangeLogException> iter = changeLog.readFromStart();
final List<QueryChange> actual = new ArrayList<>();
while (iter.hasNext()) {
final ChangeLogEntry<QueryChange> entry = iter.next();
actual.add(entry.getEntry());
}
assertEquals(expected, actual);
}
use of org.apache.rya.streams.api.queries.QueryChange in project incubator-rya by apache.
the class AddQueryCommandIT method setup.
@Before
public void setup() {
// Make sure the topic that the change log uses exists.
final String changeLogTopic = KafkaTopics.queryChangeLogTopic("" + ryaInstance);
kafka.createTopic(changeLogTopic);
// Setup the QueryRepository used by the test.
final Producer<?, QueryChange> queryProducer = KafkaTestUtil.makeProducer(kafka, StringSerializer.class, QueryChangeSerializer.class);
final Consumer<?, QueryChange> queryConsumer = KafkaTestUtil.fromStartConsumer(kafka, StringDeserializer.class, QueryChangeDeserializer.class);
final QueryChangeLog changeLog = new KafkaQueryChangeLog(queryProducer, queryConsumer, changeLogTopic);
queryRepo = new InMemoryQueryRepository(changeLog, Scheduler.newFixedRateSchedule(0L, 5, TimeUnit.SECONDS));
}
use of org.apache.rya.streams.api.queries.QueryChange in project incubator-rya by apache.
the class ListQueryCommandIT method setup.
@Before
public void setup() {
// Make sure the topic that the change log uses exists.
final String changeLogTopic = KafkaTopics.queryChangeLogTopic("" + ryaInstance);
kafka.createTopic(changeLogTopic);
// Setup the QueryRepository used by the test.
final Producer<?, QueryChange> queryProducer = KafkaTestUtil.makeProducer(kafka, StringSerializer.class, QueryChangeSerializer.class);
final Consumer<?, QueryChange> queryConsumer = KafkaTestUtil.fromStartConsumer(kafka, StringDeserializer.class, QueryChangeDeserializer.class);
final QueryChangeLog changeLog = new KafkaQueryChangeLog(queryProducer, queryConsumer, changeLogTopic);
queryRepo = new InMemoryQueryRepository(changeLog, Scheduler.newFixedRateSchedule(0L, 5, TimeUnit.SECONDS));
}
Aggregations