use of org.zalando.nakadi.domain.Storage in project nakadi by zalando.
the class StorageDbRepositoryTest method testStorageOrdered.
@Test
public void testStorageOrdered() throws Exception {
final String namePrefix = randomValidStringOfLength(31);
final Storage storage2 = repository.createStorage(createStorage(namePrefix + "2", "exaddress", 8181, "address1", "path3"));
final Storage storage1 = repository.createStorage(createStorage(namePrefix + "1", "exaddress", 8181, "address2", "path2"));
final Storage storage3 = repository.createStorage(createStorage(namePrefix + "3", "exaddress", 8181, "address3", "path1"));
final List<Storage> storages = repository.listStorages().stream().filter(st -> st.getId() != null).filter(st -> st.getId().startsWith(namePrefix)).collect(Collectors.toList());
assertEquals(3, storages.size());
assertEquals(storage1, storages.get(0));
assertEquals(storage2, storages.get(1));
assertEquals(storage3, storages.get(2));
}
use of org.zalando.nakadi.domain.Storage in project nakadi by zalando.
the class NakadiConfig method defaultStorage.
@Bean
@Qualifier("default_storage")
public DefaultStorage defaultStorage(final StorageDbRepository storageDbRepository, final Environment environment, final ZooKeeperHolder zooKeeperHolder) throws InternalNakadiException {
final String storageId = getStorageId(zooKeeperHolder, environment);
final Optional<Storage> storageOpt = storageDbRepository.getStorage(storageId);
if (!storageOpt.isPresent()) {
LOGGER.info("Creating timelines storage `{}` from defaults", storageId);
final Storage storage = new Storage();
storage.setId(storageId);
storage.setType(Storage.Type.KAFKA);
storage.setConfiguration(new Storage.KafkaConfiguration(environment.getProperty("nakadi.zookeeper.exhibitor.brokers"), Integer.valueOf(environment.getProperty("nakadi.zookeeper.exhibitor.port", "0")), environment.getProperty("nakadi.zookeeper.brokers"), environment.getProperty("nakadi.zookeeper.kafkaNamespace", "")));
try {
storageDbRepository.createStorage(storage);
} catch (final DuplicatedStorageException e) {
LOGGER.info("Creation of default storage failed: {}", e.getMessage());
}
return new DefaultStorage(storage);
} else {
return new DefaultStorage(storageOpt.get());
}
}
use of org.zalando.nakadi.domain.Storage in project nakadi by zalando.
the class StorageDbRepositoryTest method testDeleteUsedStorage.
@Test(expected = StorageIsUsedException.class)
public void testDeleteUsedStorage() throws Exception {
final String name = randomUUID();
final Storage storage = repository.createStorage(createStorage(name, "exaddress", 8181, "address", "path"));
final EventType eventType = eventTypeDbRepository.saveEventType(TestUtils.buildDefaultEventType());
final Timeline timeline = TimelineDbRepositoryTest.createTimeline(storage, UUID.randomUUID(), 0, "topic", eventType.getName(), new Date(), new Date(), null, null);
timelineDbRepository.createTimeline(timeline);
repository.deleteStorage(storage.getId());
}
use of org.zalando.nakadi.domain.Storage in project nakadi by zalando.
the class StorageDbRepositoryTest method testStorageDeleted.
@Test
public void testStorageDeleted() throws Exception {
final String name = randomUUID();
final Storage storage = repository.createStorage(createStorage(name, "exaddress", 8181, "address2", "path2"));
assertEquals(storage, repository.getStorage(storage.getId()).get());
repository.deleteStorage(storage.getId());
assertFalse(repository.getStorage(storage.getId()).isPresent());
}
use of org.zalando.nakadi.domain.Storage in project nakadi by zalando.
the class StorageDbRepositoryTest method testStorageCreated.
@Test
public void testStorageCreated() throws Exception {
final String name = randomUUID();
final Storage storage = createStorage(name, "exaddress", 8181, "address", "path");
repository.createStorage(storage);
final Optional<Storage> createdCopy = repository.getStorage(storage.getId());
assertTrue(createdCopy.isPresent());
assertNotSame(createdCopy.get(), storage);
assertEquals(storage, createdCopy.get());
}
Aggregations