use of org.zalando.nakadi.repository.kafka.KafkaTopicRepository in project nakadi by zalando.
the class CursorOperationsServiceTest method mockTimeline.
private Timeline mockTimeline(final int order, @Nullable final Long latestOffset) {
final Timeline timeline = mock(Timeline.class);
when(timeline.getOrder()).thenReturn(order);
final Storage storage = new Storage();
storage.setType(Storage.Type.KAFKA);
when(timeline.getStorage()).thenReturn(storage);
if (latestOffset == null) {
when(timeline.isActive()).thenReturn(false);
when(timeline.getLatestPosition()).thenReturn(null);
} else {
when(timeline.isActive()).thenReturn(true);
when(timeline.getLatestPosition()).thenReturn(new Timeline.KafkaStoragePosition(Collections.singletonList(latestOffset)));
}
when(timeline.isActive()).thenReturn(null == latestOffset);
final TopicRepository repository = new KafkaTopicRepository(mock(ZooKeeperHolder.class), mock(KafkaFactory.class), mock(NakadiSettings.class), mock(KafkaSettings.class), mock(ZookeeperSettings.class), mock(UUIDGenerator.class));
when(timelineService.getTopicRepository(timeline)).thenReturn(repository);
return timeline;
}
use of org.zalando.nakadi.repository.kafka.KafkaTopicRepository in project nakadi by zalando.
the class KafkaRepositoryCreator method createTopicRepository.
@Override
public TopicRepository createTopicRepository(final Storage storage) throws TopicRepositoryException {
try {
final Storage.KafkaConfiguration kafkaConfiguration = storage.getKafkaConfiguration();
final ZooKeeperHolder zooKeeperHolder = new ZooKeeperHolder(kafkaConfiguration.getZkAddress(), kafkaConfiguration.getZkPath(), kafkaConfiguration.getExhibitorAddress(), kafkaConfiguration.getExhibitorPort());
final KafkaFactory kafkaFactory = new KafkaFactory(new KafkaLocationManager(zooKeeperHolder, kafkaSettings), metricRegistry);
final KafkaTopicRepository kafkaTopicRepository = new KafkaTopicRepository(zooKeeperHolder, kafkaFactory, nakadiSettings, kafkaSettings, zookeeperSettings, uuidGenerator);
// check that it does work
kafkaTopicRepository.listTopics();
return kafkaTopicRepository;
} catch (final Exception e) {
throw new TopicRepositoryException("Could not create topic repository", e);
}
}
Aggregations