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();
}
}
}
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);
}
}
Aggregations