Class OdysseyIntegrationManager

java.lang.Object
io.confluent.kafka.odyssey.OdysseyIntegrationManager
All Implemented Interfaces:
OdysseyManager, OdysseyReadManager, AutoCloseable

public final class OdysseyIntegrationManager extends Object implements OdysseyManager, AutoCloseable
Manages the integration between Kafka topic creation and Odyssey (Schema Registry) associations for K1.

This class owns and manages the lifecycle of all internal components. Call close() to release resources.

  • Constructor Details

    • OdysseyIntegrationManager

      public OdysseyIntegrationManager(OdysseyRequestManager odysseyRequestManager, TopicIdLookup topicIdLookup, String clusterId, org.apache.kafka.common.utils.internals.LogContext logContext, org.apache.kafka.common.utils.Time time, LsrcLookupService lsrcLookupService, org.apache.kafka.common.config.BrokerType brokerType, String schemaRegistryUrl)
      Test-only constructor. Production code should use OdysseyIntegrationManager.Builder, which constructs odysseyRequestManager and lsrcLookupService itself.
  • Method Details

    • handleCreateTopicsWithOdyssey

      public CompletableFuture<org.apache.kafka.common.message.CreateTopicsResponseData> handleCreateTopicsWithOdyssey(org.apache.kafka.common.requests.CreateTopicsRequest request, BiFunction<org.apache.kafka.common.message.CreateTopicsRequestData, Set<String>, CompletableFuture<org.apache.kafka.common.message.CreateTopicsResponseData>> topicCreator, org.apache.kafka.common.security.auth.KafkaPrincipal principal)
      Handles CreateTopics requests with Odyssey integration for K1.

      Schema Registry validation completes before any topic is created, and associations are created only after creation succeeds; a topic that fails validation is never created.

      Specified by:
      handleCreateTopicsWithOdyssey in interface OdysseyManager
      Parameters:
      request - the CreateTopics request, holding only authorized topics
      topicCreator - creates the given topics; its second argument names the subset whose external-schema type the same create operation must set to MAYBE
      principal - the request principal for namespace extraction and token acquisition
      Returns:
      CompletableFuture with the complete response
    • handleDescribeConfigsWithOdyssey

      public CompletableFuture<DescribeConfigsOdysseyResult> handleDescribeConfigsWithOdyssey(org.apache.kafka.common.message.DescribeConfigsResponseData kafkaResponse, List<String> topicNames, org.apache.kafka.common.security.auth.KafkaPrincipal principal, org.apache.kafka.common.ConfluentAssociationFetchMode fetchMode, boolean isClusterLink)
      Handles DescribeConfigs requests with Odyssey integration for K1.

      Flow:

      1. Resolve Schema Registry endpoint (via RM)
      2. Fetch schema associations from SR for all requested TOPIC resources
      3. Inject association data as config entries into the Kafka response

      Kafka configs are always returned regardless of SR errors. On SR failure, the relevant SR error code and error message are embedded in the Kafka error message.

      Specified by:
      handleDescribeConfigsWithOdyssey in interface OdysseyReadManager
      Parameters:
      kafkaResponse - The standard Kafka DescribeConfigs response to enrich
      topicNames - Topic names to fetch associations for (must be TOPIC resources only)
      principal - The Kafka principal for the request
      fetchMode - the requested association fetch mode (from the DescribeConfigs tagged field); DEFAULT means no associations are returned, for every caller — a caller that wants associations back must request ASSOCIATIONS_WITHOUT_SCHEMA explicitly
      isClusterLink - whether the request originated from a cluster link (present cluster-link id header). No longer affects the result — retained on the signature for compatibility with existing callers
      Returns:
      CompletableFuture with the enriched result; never completes exceptionally — SR errors are captured per-topic as failed OdysseyResult instances
    • handleDeleteTopicsWithOdyssey

      public CompletableFuture<List<DeleteResult>> handleDeleteTopicsWithOdyssey(Map<String, org.apache.kafka.common.Uuid> nameToId, Set<String> topicsWithAssociations, org.apache.kafka.common.security.auth.KafkaPrincipal principal)
      Description copied from interface: OdysseyManager
      Handles DeleteTopics requests with Odyssey integration for K1. The caller has already authorized each topic and resolved its UUID.

      topicsWithAssociations is the caller's classification of which topics may carry a Schema Registry association; this method does not classify. A superset is safe — those topics just pay a no-op SR call — but a subset orphans associations, since the topic is deleted right afterwards.

      Returns one DeleteResult per input topic, in nameToId iteration order.

      Specified by:
      handleDeleteTopicsWithOdyssey in interface OdysseyManager
    • notifyDeleteTopicsResult

      public void notifyDeleteTopicsResult(Set<org.apache.kafka.common.Uuid> associationDeletedTopicIds, Map<org.apache.kafka.common.Uuid, org.apache.kafka.common.requests.ApiError> idToError)
      Description copied from interface: OdysseyManager
      Reports per-topic results from the post-Odyssey Kafka delete so SR-committed-but-Kafka-failed topics — the orphan-event boundary — can be observed.
      Specified by:
      notifyDeleteTopicsResult in interface OdysseyManager
      Parameters:
      associationDeletedTopicIds - topics whose SR association was actually removed this request; the only orphan candidates. Callers must exclude bypass-SR (no-association) topics.
      idToError - per-topic Kafka delete outcomes
    • handleIncrementalAlterConfigsWithOdyssey

      public CompletableFuture<Void> handleIncrementalAlterConfigsWithOdyssey(Map<org.apache.kafka.common.config.ConfigResource, Map<String, Map.Entry<org.apache.kafka.clients.admin.AlterConfigOp.OpType, String>>> configChanges, Map<org.apache.kafka.common.config.ConfigResource, OdysseyManager.LargeAssociationPayloads> largePayloads, org.apache.kafka.common.security.auth.KafkaPrincipal principal, boolean validateOnly, ControllerConfigUpdater controllerConfigUpdater, Consumer<Map<org.apache.kafka.common.config.ConfigResource, org.apache.kafka.common.requests.ApiError>> responseDataUpdater, ExternalSchemaUpdater externalSchemaUpdater)
      Description copied from interface: OdysseyManager
      Handles IncrementalAlterConfigs requests with Odyssey integration for K1.

      SET ops upsert associations to SR; DELETE ops disassociate them. Non-Odyssey resources bypass the SR flow and go directly to the controller. Every per-resource result — illegal rejection, validation failure, SR-resolution failure, controller result, SR-upsert result — is delivered through responseDataUpdater, which is the sole channel for response writes and handles any caller-side translation (e.g. cluster link name mapping).

      When validateOnly is true, SR dry-run validation still runs, the controller call still runs (passed-through validateOnly by the caller's lambda), but the real SR upsert (updateAssociations) is skipped — no schema-association state changes in SR. Mirrors the CreateTopics-with-Odyssey behavior.

      Specified by:
      handleIncrementalAlterConfigsWithOdyssey in interface OdysseyManager
      Parameters:
      configChanges - preprocessed config changes per resource, keyed by op type
      largePayloads - association payloads the request delivered as tagged bytes, per resource; resolved into configChanges before classification
      principal - the request principal for namespace extraction and token acquisition
      validateOnly - if true, skip real SR upsert (dry-run validation still runs)
      controllerConfigUpdater - callback to apply config changes via the controller (Odyssey configs stripped); receives validateOnly explicitly so the controller call honours the same flag
      responseDataUpdater - consumer that receives each per-resource result (resource → ApiError) and writes it into the caller's response with any required translation
      externalSchemaUpdater - ExternalSchemaUpdater, invoked between the controller alter and the SR upsert
      Returns:
      CompletableFuture that completes after the final responseDataUpdater invocation; on failure, completes exceptionally with the error
    • close

      public void close()
      Closes this manager and releases all resources.

      This method closes:

      • OdysseyRequestManager (closes executor, metrics, and Token Platform client)
      • LsrcLookupService (closes metrics and RM client)
      Specified by:
      close in interface AutoCloseable