Search in sources :

Example 1 with KafkaTopicRepository

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;
}
Also used : Timeline(org.zalando.nakadi.domain.Timeline) KafkaFactory(org.zalando.nakadi.repository.kafka.KafkaFactory) Storage(org.zalando.nakadi.domain.Storage) KafkaTopicRepository(org.zalando.nakadi.repository.kafka.KafkaTopicRepository) KafkaSettings(org.zalando.nakadi.repository.kafka.KafkaSettings) UUIDGenerator(org.zalando.nakadi.util.UUIDGenerator) TopicRepository(org.zalando.nakadi.repository.TopicRepository) KafkaTopicRepository(org.zalando.nakadi.repository.kafka.KafkaTopicRepository) ZookeeperSettings(org.zalando.nakadi.repository.zookeeper.ZookeeperSettings) ZooKeeperHolder(org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder) NakadiSettings(org.zalando.nakadi.config.NakadiSettings)

Example 2 with KafkaTopicRepository

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);
    }
}
Also used : KafkaFactory(org.zalando.nakadi.repository.kafka.KafkaFactory) Storage(org.zalando.nakadi.domain.Storage) KafkaTopicRepository(org.zalando.nakadi.repository.kafka.KafkaTopicRepository) KafkaLocationManager(org.zalando.nakadi.repository.kafka.KafkaLocationManager) ZooKeeperHolder(org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder) NakadiRuntimeException(org.zalando.nakadi.exceptions.NakadiRuntimeException) TopicRepositoryException(org.zalando.nakadi.exceptions.runtime.TopicRepositoryException) TopicRepositoryException(org.zalando.nakadi.exceptions.runtime.TopicRepositoryException)

Aggregations

Storage (org.zalando.nakadi.domain.Storage)2 KafkaFactory (org.zalando.nakadi.repository.kafka.KafkaFactory)2 KafkaTopicRepository (org.zalando.nakadi.repository.kafka.KafkaTopicRepository)2 ZooKeeperHolder (org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder)2 NakadiSettings (org.zalando.nakadi.config.NakadiSettings)1 Timeline (org.zalando.nakadi.domain.Timeline)1 NakadiRuntimeException (org.zalando.nakadi.exceptions.NakadiRuntimeException)1 TopicRepositoryException (org.zalando.nakadi.exceptions.runtime.TopicRepositoryException)1 TopicRepository (org.zalando.nakadi.repository.TopicRepository)1 KafkaLocationManager (org.zalando.nakadi.repository.kafka.KafkaLocationManager)1 KafkaSettings (org.zalando.nakadi.repository.kafka.KafkaSettings)1 ZookeeperSettings (org.zalando.nakadi.repository.zookeeper.ZookeeperSettings)1 UUIDGenerator (org.zalando.nakadi.util.UUIDGenerator)1