Record Class ConnectorContext

java.lang.Object
java.lang.Record
io.debezium.openlineage.ConnectorContext
Record Components:
connectorLogicalName - the logical name of the connector, typically used for identification
connectorName - the actual name of the connector type
taskId - the unique identifier for the connector task, defaults to "0" if not specified
config - the configuration object containing connector settings, may be null when created from headers

public record ConnectorContext(String connectorLogicalName, String connectorName, String taskId, String version, UUID runId, Map<String,String> config) extends Record
Represents the context information for a Kafka Connect connector, containing essential metadata required for connector operations and identification.

This record encapsulates connector identification details including the logical name, connector name, task ID, and configuration. It provides factory methods to create instances from different sources such as configuration objects and message headers.

Author:
Mario Fiore Vitale
  • Field Details

    • connectorLogicalName

      private final String connectorLogicalName
      The field for the connectorLogicalName record component.
    • connectorName

      private final String connectorName
      The field for the connectorName record component.
    • taskId

      private final String taskId
      The field for the taskId record component.
    • version

      private final String version
      The field for the version record component.
    • runId

      private final UUID runId
      The field for the runId record component.
    • config

      private final Map<String,String> config
      The field for the config record component.
    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • KEY_FORMAT

      private static final String KEY_FORMAT
      See Also:
  • Constructor Details

    • ConnectorContext

      public ConnectorContext(String connectorLogicalName, String connectorName, String taskId, String version, UUID runId, Map<String,String> config)
      Creates an instance of a ConnectorContext record class.
      Parameters:
      connectorLogicalName - the value for the connectorLogicalName record component
      connectorName - the value for the connectorName record component
      taskId - the value for the taskId record component
      version - the value for the version record component
      runId - the value for the runId record component
      config - the value for the config record component
  • Method Details

    • from

      public static ConnectorContext from(Map<String,String> configuration, String connectorTypeName, UUID runId)
      Creates a ConnectorContext instance from a configuration object and connector type name.

      This factory method extracts the topic prefix and task ID from the provided configuration. If no task ID is found in the configuration, it defaults to "0".

      Parameters:
      configuration - the configuration object containing connector settings
      connectorTypeName - the name of the connector type
      runId -
      Returns:
      a new ConnectorContext instance populated with configuration values
    • from

      public static ConnectorContext from(org.apache.kafka.connect.header.Headers headers)
      Creates a ConnectorContext instance from Kafka message headers.

      This factory method extracts Debezium-specific context headers to populate the connector context. It filters headers that start with the Debezium context header prefix and maps them for easy access. Note that the configuration parameter will be null when using this method.

      Warning: This method logs a warning indicating that the OpenLineage SMT cannot retrieve required Debezium headers.

      Parameters:
      headers - the Kafka message headers containing connector context information
      Returns:
      a new ConnectorContext instance with data extracted from headers, with config set to null
    • toEmitterKey

      public String toEmitterKey()
      Generates a unique emitter key for this connector context.

      The emitter key is formatted as "{connectorLogicalName}:{taskId}" and can be used to uniquely identify this connector instance for emitting events.

      Returns:
      a formatted string combining the connector logical name and task ID
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • connectorLogicalName

      public String connectorLogicalName()
      Returns the value of the connectorLogicalName record component.
      Returns:
      the value of the connectorLogicalName record component
    • connectorName

      public String connectorName()
      Returns the value of the connectorName record component.
      Returns:
      the value of the connectorName record component
    • taskId

      public String taskId()
      Returns the value of the taskId record component.
      Returns:
      the value of the taskId record component
    • version

      public String version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component
    • runId

      public UUID runId()
      Returns the value of the runId record component.
      Returns:
      the value of the runId record component
    • config

      public Map<String,String> config()
      Returns the value of the config record component.
      Returns:
      the value of the config record component