Search in sources :

Example 1 with DuplicatedTimelineException

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

the class TimelineService method createDefaultTimeline.

public Timeline createDefaultTimeline(final String eventTypeName, final int partitionsCount, final long retentionTime) throws TopicCreationException, InconsistentStateException, RepositoryProblemException, DuplicatedTimelineException, TimelineException, DbWriteOperationsBlockedException {
    if (featureToggleService.isFeatureEnabled(FeatureToggleService.Feature.DISABLE_DB_WRITE_OPERATIONS)) {
        throw new DbWriteOperationsBlockedException("Cannot create default timeline: write operations on DB " + "are blocked by feature flag.");
    }
    final TopicRepository repository = topicRepositoryHolder.getTopicRepository(defaultStorage.getStorage());
    final String topic = repository.createTopic(partitionsCount, retentionTime);
    try {
        final Timeline timeline = Timeline.createTimeline(eventTypeName, 1, defaultStorage.getStorage(), topic, new Date());
        timeline.setSwitchedAt(new Date());
        timelineDbRepository.createTimeline(timeline);
        eventTypeCache.updated(eventTypeName);
        return timeline;
    } catch (final InconsistentStateException | RepositoryProblemException | DuplicatedTimelineException e) {
        rollbackTopic(repository, topic);
        throw e;
    } catch (final Exception e) {
        rollbackTopic(repository, topic);
        throw new TimelineException("Failed to update event type cache, while creating timeline", e);
    }
}
Also used : DuplicatedTimelineException(org.zalando.nakadi.exceptions.runtime.DuplicatedTimelineException) Timeline(org.zalando.nakadi.domain.Timeline) TopicRepository(org.zalando.nakadi.repository.TopicRepository) RepositoryProblemException(org.zalando.nakadi.exceptions.runtime.RepositoryProblemException) DbWriteOperationsBlockedException(org.zalando.nakadi.exceptions.runtime.DbWriteOperationsBlockedException) InconsistentStateException(org.zalando.nakadi.exceptions.runtime.InconsistentStateException) Date(java.util.Date) NakadiException(org.zalando.nakadi.exceptions.NakadiException) NoSuchEventTypeException(org.zalando.nakadi.exceptions.NoSuchEventTypeException) TopicRepositoryException(org.zalando.nakadi.exceptions.runtime.TopicRepositoryException) ServiceUnavailableException(org.zalando.nakadi.exceptions.ServiceUnavailableException) ConflictException(org.zalando.nakadi.exceptions.ConflictException) DbWriteOperationsBlockedException(org.zalando.nakadi.exceptions.runtime.DbWriteOperationsBlockedException) TimelineException(org.zalando.nakadi.exceptions.TimelineException) InvalidCursorException(org.zalando.nakadi.exceptions.InvalidCursorException) TopicDeletionException(org.zalando.nakadi.exceptions.TopicDeletionException) InconsistentStateException(org.zalando.nakadi.exceptions.runtime.InconsistentStateException) NotFoundException(org.zalando.nakadi.exceptions.NotFoundException) TopicCreationException(org.zalando.nakadi.exceptions.TopicCreationException) UnableProcessException(org.zalando.nakadi.exceptions.UnableProcessException) DuplicatedTimelineException(org.zalando.nakadi.exceptions.runtime.DuplicatedTimelineException) AccessDeniedException(org.zalando.nakadi.exceptions.runtime.AccessDeniedException) TransactionException(org.springframework.transaction.TransactionException) InternalNakadiException(org.zalando.nakadi.exceptions.InternalNakadiException) RepositoryProblemException(org.zalando.nakadi.exceptions.runtime.RepositoryProblemException) TimelineException(org.zalando.nakadi.exceptions.TimelineException) DuplicatedTimelineException(org.zalando.nakadi.exceptions.runtime.DuplicatedTimelineException)

Aggregations

Date (java.util.Date)1 TransactionException (org.springframework.transaction.TransactionException)1 Timeline (org.zalando.nakadi.domain.Timeline)1 ConflictException (org.zalando.nakadi.exceptions.ConflictException)1 InternalNakadiException (org.zalando.nakadi.exceptions.InternalNakadiException)1 InvalidCursorException (org.zalando.nakadi.exceptions.InvalidCursorException)1 NakadiException (org.zalando.nakadi.exceptions.NakadiException)1 NoSuchEventTypeException (org.zalando.nakadi.exceptions.NoSuchEventTypeException)1 NotFoundException (org.zalando.nakadi.exceptions.NotFoundException)1 ServiceUnavailableException (org.zalando.nakadi.exceptions.ServiceUnavailableException)1 TimelineException (org.zalando.nakadi.exceptions.TimelineException)1 TopicCreationException (org.zalando.nakadi.exceptions.TopicCreationException)1 TopicDeletionException (org.zalando.nakadi.exceptions.TopicDeletionException)1 UnableProcessException (org.zalando.nakadi.exceptions.UnableProcessException)1 AccessDeniedException (org.zalando.nakadi.exceptions.runtime.AccessDeniedException)1 DbWriteOperationsBlockedException (org.zalando.nakadi.exceptions.runtime.DbWriteOperationsBlockedException)1 DuplicatedTimelineException (org.zalando.nakadi.exceptions.runtime.DuplicatedTimelineException)1 InconsistentStateException (org.zalando.nakadi.exceptions.runtime.InconsistentStateException)1 RepositoryProblemException (org.zalando.nakadi.exceptions.runtime.RepositoryProblemException)1 TopicRepositoryException (org.zalando.nakadi.exceptions.runtime.TopicRepositoryException)1