use of org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder 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);
}
}
use of org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder in project nakadi by zalando.
the class NakadiConfigTest method setUp.
@Before
public void setUp() {
final CuratorFramework curatorFramework = Mockito.mock(CuratorFramework.class);
zooKeeperHolder = Mockito.mock(ZooKeeperHolder.class);
Mockito.when(zooKeeperHolder.get()).thenReturn(curatorFramework);
Mockito.when(curatorFramework.getData()).thenReturn(dataBuilder);
Mockito.when(environment.getProperty("nakadi.zookeeper.exhibitor.port", "0")).thenReturn("0");
}
use of org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder in project nakadi by zalando.
the class EventTypeCacheTest method testEventTypesPreloaded.
@Test
public void testEventTypesPreloaded() throws Exception {
final EventTypeRepository etRepo = Mockito.mock(EventTypeRepository.class);
final TimelineDbRepository timelineRepository = Mockito.mock(TimelineDbRepository.class);
final ZooKeeperHolder zkHolder = Mockito.mock(ZooKeeperHolder.class);
final TimelineSync timelineSync = Mockito.mock(TimelineSync.class);
final EventType et = TestUtils.buildDefaultEventType();
Mockito.when(etRepo.list()).thenReturn(Collections.singletonList(et));
final Timeline timeline = TestUtils.buildTimeline(et.getName());
final List<Timeline> timelines = Collections.singletonList(timeline);
Mockito.when(timelineRepository.listTimelinesOrdered()).thenReturn(timelines);
Mockito.when(timelineSync.registerTimelineChangeListener(Matchers.eq(et.getName()), Mockito.any())).thenReturn(() -> {
});
final EventTypeCache eventTypeCache = new EventTypeCache(etRepo, timelineRepository, zkHolder, null, timelineSync) {
@Override
public void created(final String name) throws Exception {
// ignore this call, because mocking is too complex
}
};
Assert.assertSame(et, eventTypeCache.getEventType(et.getName()));
Mockito.verify(etRepo, Mockito.times(0)).findByName(Mockito.any());
Mockito.verify(etRepo, Mockito.times(1)).list();
Assert.assertEquals(timelines, eventTypeCache.getTimelinesOrdered(et.getName()));
Mockito.verify(timelineRepository, Mockito.times(0)).listTimelinesOrdered(Mockito.any());
Mockito.verify(timelineRepository, Mockito.times(1)).listTimelinesOrdered();
}
Aggregations