Search in sources :

Example 16 with NoSuchEventTypeException

use of org.zalando.nakadi.exceptions.NoSuchEventTypeException in project nakadi by zalando.

the class SubscriptionService method createSubscriptionStat.

private List<SubscriptionEventTypeStats> createSubscriptionStat(final Subscription subscription) throws InconsistentStateException, ServiceTemporarilyUnavailableException {
    final List<EventType> eventTypes = subscription.getEventTypes().stream().map(Try.wrap(eventTypeRepository::findByName)).map(Try::getOrThrow).sorted(Comparator.comparing(EventType::getName)).collect(Collectors.toList());
    final List<PartitionEndStatistics> topicPartitions;
    try {
        topicPartitions = loadPartitionEndStatistics(eventTypes);
    } catch (final ServiceUnavailableException ex) {
        throw new ServiceTemporarilyUnavailableException(ex);
    }
    final ZkSubscriptionClient subscriptionClient;
    try {
        subscriptionClient = subscriptionClientFactory.createClient(subscription, "subscription." + subscription.getId() + ".stats");
    } catch (final InternalNakadiException | NoSuchEventTypeException e) {
        throw new ServiceTemporarilyUnavailableException(e);
    }
    final Optional<ZkSubscriptionNode> zkSubscriptionNode = subscriptionClient.getZkSubscriptionNodeLocked();
    return loadStats(eventTypes, zkSubscriptionNode, subscriptionClient, topicPartitions);
}
Also used : ServiceTemporarilyUnavailableException(org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException) InternalNakadiException(org.zalando.nakadi.exceptions.InternalNakadiException) EventType(org.zalando.nakadi.domain.EventType) ZkSubscriptionClient(org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient) ServiceUnavailableException(org.zalando.nakadi.exceptions.ServiceUnavailableException) PartitionEndStatistics(org.zalando.nakadi.domain.PartitionEndStatistics) Try(org.zalando.nakadi.exceptions.Try) ZkSubscriptionNode(org.zalando.nakadi.service.subscription.zk.ZkSubscriptionNode) NoSuchEventTypeException(org.zalando.nakadi.exceptions.NoSuchEventTypeException)

Example 17 with NoSuchEventTypeException

use of org.zalando.nakadi.exceptions.NoSuchEventTypeException in project nakadi by zalando.

the class CachingEventTypeRepository method update.

@Override
public void update(final EventType eventType) throws InternalNakadiException, NoSuchEventTypeException {
    final EventType original = this.repository.findByName(eventType.getName());
    this.repository.update(eventType);
    try {
        this.cache.updated(eventType.getName());
    } catch (Exception e) {
        LOG.error("Failed to update cache for event type '" + eventType.getName() + "'", e);
        this.repository.update(original);
        throw new InternalNakadiException("Failed to update event type", e);
    }
}
Also used : InternalNakadiException(org.zalando.nakadi.exceptions.InternalNakadiException) EventType(org.zalando.nakadi.domain.EventType) DuplicatedEventTypeNameException(org.zalando.nakadi.exceptions.DuplicatedEventTypeNameException) NoSuchEventTypeException(org.zalando.nakadi.exceptions.NoSuchEventTypeException) InternalNakadiException(org.zalando.nakadi.exceptions.InternalNakadiException)

Example 18 with NoSuchEventTypeException

use of org.zalando.nakadi.exceptions.NoSuchEventTypeException in project nakadi by zalando.

the class EventTypeDbRepository method removeEventType.

@Override
@Transactional
public void removeEventType(final String name) throws NoSuchEventTypeException, InternalNakadiException {
    try {
        jdbcTemplate.update("DELETE FROM zn_data.event_type_schema WHERE ets_event_type_name = ?", name);
        final int deletedRows = jdbcTemplate.update("DELETE FROM zn_data.event_type WHERE et_name = ?", name);
        if (deletedRows == 0) {
            throw new NoSuchEventTypeException("EventType " + name + " doesn't exist");
        }
    } catch (DataAccessException e) {
        throw new InternalNakadiException("Error occurred when deleting EventType " + name, e);
    }
}
Also used : InternalNakadiException(org.zalando.nakadi.exceptions.InternalNakadiException) NoSuchEventTypeException(org.zalando.nakadi.exceptions.NoSuchEventTypeException) DataAccessException(org.springframework.dao.DataAccessException) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

NoSuchEventTypeException (org.zalando.nakadi.exceptions.NoSuchEventTypeException)18 InternalNakadiException (org.zalando.nakadi.exceptions.InternalNakadiException)14 EventType (org.zalando.nakadi.domain.EventType)10 ServiceUnavailableException (org.zalando.nakadi.exceptions.ServiceUnavailableException)9 InvalidCursorException (org.zalando.nakadi.exceptions.InvalidCursorException)7 NakadiCursor (org.zalando.nakadi.domain.NakadiCursor)6 NakadiException (org.zalando.nakadi.exceptions.NakadiException)6 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 PartitionStatistics (org.zalando.nakadi.domain.PartitionStatistics)5 Timeline (org.zalando.nakadi.domain.Timeline)5 TopicRepository (org.zalando.nakadi.repository.TopicRepository)5 TimelineService (org.zalando.nakadi.service.timeline.TimelineService)5 Map (java.util.Map)4 Optional (java.util.Optional)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 CursorError (org.zalando.nakadi.domain.CursorError)4 ServiceTemporarilyUnavailableException (org.zalando.nakadi.exceptions.runtime.ServiceTemporarilyUnavailableException)4 CursorConverter (org.zalando.nakadi.service.CursorConverter)4