use of org.zalando.nakadi.exceptions.runtime.DbWriteOperationsBlockedException in project nakadi by zalando.
the class SubscriptionService method deleteSubscription.
public Result<Void> deleteSubscription(final String subscriptionId) throws DbWriteOperationsBlockedException {
if (featureToggleService.isFeatureEnabled(FeatureToggleService.Feature.DISABLE_DB_WRITE_OPERATIONS)) {
throw new DbWriteOperationsBlockedException("Cannot delete subscription: write operations on DB " + "are blocked by feature flag.");
}
try {
final Subscription subscription = subscriptionRepository.getSubscription(subscriptionId);
subscriptionRepository.deleteSubscription(subscriptionId);
final ZkSubscriptionClient zkSubscriptionClient = subscriptionClientFactory.createClient(subscription, "subscription." + subscriptionId + ".delete_subscription");
zkSubscriptionClient.deleteSubscription();
nakadiKpiPublisher.publish(subLogEventType, () -> new JSONObject().put("subscription_id", subscriptionId).put("status", "deleted"));
return Result.ok();
} catch (final NoSuchSubscriptionException e) {
LOG.debug("Failed to find subscription: {}", subscriptionId, e);
return Result.problem(e.asProblem());
} catch (final ServiceUnavailableException e) {
LOG.error("Error occurred when trying to delete subscription: {}", subscriptionId, e);
return Result.problem(e.asProblem());
} catch (final NoSuchEventTypeException | InternalNakadiException e) {
LOG.error("Exception can not occur", e);
return Result.problem(e.asProblem());
}
}
use of org.zalando.nakadi.exceptions.runtime.DbWriteOperationsBlockedException in project nakadi by zalando.
the class SubscriptionService method createSubscription.
public Subscription createSubscription(final SubscriptionBase subscriptionBase) throws TooManyPartitionsException, RepositoryProblemException, DuplicatedSubscriptionException, NoEventTypeException, InconsistentStateException, WrongInitialCursorsException, DbWriteOperationsBlockedException {
if (featureToggleService.isFeatureEnabled(FeatureToggleService.Feature.DISABLE_DB_WRITE_OPERATIONS)) {
throw new DbWriteOperationsBlockedException("Cannot create subscription: write operations on DB " + "are blocked by feature flag.");
}
subscriptionValidationService.validateSubscription(subscriptionBase);
final Subscription subscription = subscriptionRepository.createSubscription(subscriptionBase);
nakadiKpiPublisher.publish(subLogEventType, () -> new JSONObject().put("subscription_id", subscription.getId()).put("status", "created"));
return subscription;
}
Aggregations