use of org.zalando.nakadi.domain.Storage in project nakadi by zalando.
the class BaseAT method createDefaultStorage.
@BeforeClass
public static void createDefaultStorage() {
final Storage storage = new Storage();
storage.setId("default");
storage.setType(Storage.Type.KAFKA);
storage.setConfiguration(new Storage.KafkaConfiguration(null, null, ZOOKEEPER_URL, ""));
try {
STORAGE_DB_REPOSITORY.createStorage(storage);
} catch (final DuplicatedStorageException ignore) {
}
}
use of org.zalando.nakadi.domain.Storage 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.domain.Storage in project nakadi by zalando.
the class PartitionsControllerTest method mockCursorLag.
private List<NakadiCursorLag> mockCursorLag() {
final Timeline timeline = mock(Timeline.class);
when(timeline.getStorage()).thenReturn(new Storage("ccc", Storage.Type.KAFKA));
final NakadiCursorLag lag = mock(NakadiCursorLag.class);
final NakadiCursor firstCursor = NakadiCursor.of(timeline, "0", "0");
final NakadiCursor lastCursor = NakadiCursor.of(timeline, "0", "1");
when(lag.getLag()).thenReturn(42L);
when(lag.getPartition()).thenReturn("0");
when(lag.getFirstCursor()).thenReturn(firstCursor);
when(lag.getLastCursor()).thenReturn(lastCursor);
return Lists.newArrayList(lag);
}
use of org.zalando.nakadi.domain.Storage in project nakadi by zalando.
the class TimelinesControllerTest method whenGetTimelinesThenOk.
@Test
public void whenGetTimelinesThenOk() throws Exception {
final Storage kafkaStorage = StoragesControllerTest.createKafkaStorage("deafult");
final ImmutableList<Timeline> timelines = ImmutableList.of(Timeline.createTimeline("event_type", 0, kafkaStorage, "topic", new Date()), Timeline.createTimeline("event_type_1", 1, kafkaStorage, "topic_1", new Date()));
Mockito.when(timelineService.getTimelines(Mockito.any())).thenReturn(timelines);
final List<TimelineView> timelineViews = timelines.stream().map(TimelineView::new).collect(Collectors.toList());
mockMvc.perform(MockMvcRequestBuilders.get("/event-types/event_type/timelines").contentType(MediaType.APPLICATION_JSON).principal(PrincipalMockFactory.mockPrincipal("nakadi"))).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().json(TestUtils.OBJECT_MAPPER.writeValueAsString(timelineViews)));
}
use of org.zalando.nakadi.domain.Storage in project nakadi by zalando.
the class NakadiConfigTest method shouldTakeStorageById.
@Test
public void shouldTakeStorageById() throws Exception {
Mockito.when(dataBuilder.forPath(StorageService.ZK_TIMELINES_DEFAULT_STORAGE)).thenReturn("new-storage".getBytes());
final Storage storage = new Storage();
storage.setId("new-storage");
Mockito.when(storageDbRepository.getStorage("new-storage")).thenReturn(Optional.of(storage));
final DefaultStorage defaultStorage = new NakadiConfig().defaultStorage(storageDbRepository, environment, zooKeeperHolder);
Assert.assertEquals("new-storage", defaultStorage.getStorage().getId());
}
Aggregations