private boolean migrationFromJsonTypeFlagChangedToFalse(Topic updated, Topic previous) { return previous.wasMigratedFromJsonType() && !updated.wasMigratedFromJsonType(); }
private boolean migrationFromJsonTypeFlagChangedToTrue(Topic updated, Topic previous) { return !previous.wasMigratedFromJsonType() && updated.wasMigratedFromJsonType(); }
public KafkaTopics toKafkaTopics(Topic topic) { KafkaTopic primary = mapToKafkaTopic.andThen(appendNamespace).andThen(appendContentTypeSuffix).apply(topic); if (topic.wasMigratedFromJsonType()) { KafkaTopic secondary = mapToJsonKafkaTopic.andThen(appendNamespace).andThen(appendContentTypeSuffix).apply(topic); return new KafkaTopics(primary, secondary); } return new KafkaTopics(primary); }
@JsonCreator public TopicWithSchema(@JsonProperty("schema") String schema, @JsonProperty("name") String qualifiedName, @JsonProperty("description") String description, @JsonProperty("owner") OwnerId owner, @JsonProperty("retentionTime") RetentionTime retentionTime, @JsonProperty("jsonToAvroDryRun") boolean jsonToAvroDryRunEnabled, @JsonProperty("ack") Ack ack, @JsonProperty("trackingEnabled") boolean trackingEnabled, @JsonProperty("migratedFromJsonType") boolean migratedFromJsonType, @JsonProperty("schemaVersionAwareSerializationEnabled") boolean schemaVersionAwareSerializationEnabled, @JsonProperty("contentType") ContentType contentType, @JsonProperty("maxMessageSize") Integer maxMessageSize, @JsonProperty("auth") PublishingAuth publishingAuth, @JsonProperty("subscribingRestricted") boolean subscribingRestricted, @JsonProperty("offlineStorage") TopicDataOfflineStorage offlineStorage) { super(qualifiedName, description, owner, retentionTime, jsonToAvroDryRunEnabled, ack, trackingEnabled, migratedFromJsonType, schemaVersionAwareSerializationEnabled, contentType, maxMessageSize, publishingAuth, subscribingRestricted, offlineStorage); this.topic = convertToTopic(); this.schema = schema; }
public void ensureCreatedTopicIsValid(Topic created, CreatorRights creatorRights) { apiPreconditions.checkConstraints(created); checkOwner(created); if (created.wasMigratedFromJsonType()) { throw new TopicValidationException("Newly created topic cannot have migratedFromJsonType flag set to true"); } if (!creatorRights.allowedToManage(created)) { throw new TopicValidationException("Provide an owner that includes you, you would not be able to manage this topic later"); } }
public void updateTopic(TopicName topicName, PatchData patch, String modifiedBy) { groupService.checkGroupExists(topicName.getGroupName()); Topic retrieved = getTopicDetails(topicName); Topic modified = Patch.apply(retrieved, patch); topicValidator.ensureUpdatedTopicIsValid(modified, retrieved); if (!retrieved.equals(modified)) { Instant beforeMigrationInstant = clock.instant(); if (retrieved.getRetentionTime() != modified.getRetentionTime()) { multiDCAwareService.manageTopic(brokerTopicManagement -> brokerTopicManagement.updateTopic(modified) ); } topicRepository.updateTopic(modified); if (!retrieved.wasMigratedFromJsonType() && modified.wasMigratedFromJsonType()) { logger.info("Waiting until all subscriptions have consumers assigned during topic {} content type migration...", topicName.qualifiedName()); topicContentTypeMigrationService.waitUntilAllSubscriptionsHasConsumersAssigned(modified, Duration.ofSeconds(topicProperties.getSubscriptionsAssignmentsCompletedTimeoutSeconds())); logger.info("Notifying subscriptions' consumers about changes in topic {} content type...", topicName.qualifiedName()); topicContentTypeMigrationService.notifySubscriptions(modified, beforeMigrationInstant); } auditor.objectUpdated(modifiedBy, retrieved, modified); topicOwnerCache.onUpdatedTopic(retrieved, modified); } }