Search in sources :

Example 1 with TopicRepositoryException

use of org.zalando.nakadi.exceptions.runtime.TopicRepositoryException in project nakadi by zalando.

the class TopicRepositoryHolder method getTopicRepository.

public TopicRepository getTopicRepository(final Storage storage) throws TopicRepositoryException {
    lock.lock();
    try {
        TopicRepository topicRepository = storageTopicRepository.get(storage);
        if (topicRepository != null) {
            return topicRepository;
        }
        while (storagesBeingLoaded.contains(storage)) {
            loadingListChanged.await();
        }
        topicRepository = storageTopicRepository.get(storage);
        if (null != topicRepository) {
            return topicRepository;
        }
        storagesBeingLoaded.add(storage);
    } catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
        throw new TopicRepositoryException("Interrupted while waiting for topic repository creation", ex);
    } finally {
        lock.unlock();
    }
    TopicRepository created = null;
    try {
        created = getTopicRepositoryCreator(storage.getType()).createTopicRepository(storage);
        return created;
    } finally {
        lock.lock();
        try {
            if (null != created) {
                storageTopicRepository.put(storage, created);
            }
            storagesBeingLoaded.remove(storage);
            loadingListChanged.signalAll();
        } finally {
            lock.unlock();
        }
    }
}
Also used : TopicRepositoryException(org.zalando.nakadi.exceptions.runtime.TopicRepositoryException)

Example 2 with TopicRepositoryException

use of org.zalando.nakadi.exceptions.runtime.TopicRepositoryException 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

TopicRepositoryException (org.zalando.nakadi.exceptions.runtime.TopicRepositoryException)2 Storage (org.zalando.nakadi.domain.Storage)1 NakadiRuntimeException (org.zalando.nakadi.exceptions.NakadiRuntimeException)1 KafkaFactory (org.zalando.nakadi.repository.kafka.KafkaFactory)1 KafkaLocationManager (org.zalando.nakadi.repository.kafka.KafkaLocationManager)1 KafkaTopicRepository (org.zalando.nakadi.repository.kafka.KafkaTopicRepository)1 ZooKeeperHolder (org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder)1